I’m curling an image and just trying to display it on my pico display pack 2.0 using pngdec. (text and everything works fine, its just images that i’m stuggling with). The image itself is 6.2kB according to chrome.
I have a bunch of garbage collection enabled to help determine how much memory is available.
After curling the image and saving it as a variable, gc.mem_free says: 132256
After enabling graphics, gc.mem_free says: 55504
(I’m not 100% sure what those numbers even mean… I assume that’s the memory that pngdec will be accessing )
Initial mem: 140416
Path: i/teamlogos/ncaa/500/145.png
Actual URL: https://a.espncdn.com/combiner/i?img=i/teamlogos/ncaa/500/145.png&h=100&w=100
After curling image mem: 132256
After graphics mem: 55504
Traceback (most recent call last):
File "<stdin>", line 76, in <module>
MemoryError: memory allocation failed, allocating 48156 bytes
Can anyone thats much more familiar with python help me figure out what I’m doing wrong? I feel like I should be able to display this relatively small image if I can get pngdec working. I’ve tried png.open(image) as well as png.open_file(image) and also tried tried opening the exact contents that urequests had(image_data = r.content ) as well as converting it to bytestream (image = io.BytesIO(image_data) ). I can’t seem to get any png to display.
Hmm, what version of the micropython firmware are you using? I’m getting more initial memory running on whatever-is-currently-on-my-pico (v1.22, apparently).
The pngdec creation (PNG(graphics)) does seem to eat a chunk of memory, and with you starting so low you’re simply running out.
The baked in pngdec doesn’t have an open method - you probably want open_RAM, which will happily take r.content as long as you don’t close the request first.