read / write png files

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
ps_nithin
Posts: 14
Joined: Sat Jun 18, 2022 1:44 pm

read / write png files

Post by ps_nithin » Mon Jul 04, 2022 4:05 pm

Is there any way to read / write png files with micropython?

User avatar
karfas
Posts: 193
Joined: Sat Jan 16, 2021 12:53 pm
Location: Vienna, Austria

Re: read / write png files

Post by karfas » Mon Jul 04, 2022 4:22 pm

Of course, like any other file :D .

Way too less information here.
Where does your graphic data come from?
What is wrong with e.g. https://github.com/Ratfink/micropython- ... ter/png.py (first Google hit when searching "micropython PNG") ?
A few hours of debugging might save you from minutes of reading the documentation! :D
My repositories: https://github.com/karfas

ps_nithin
Posts: 14
Joined: Sat Jun 18, 2022 1:44 pm

Re: read / write png files

Post by ps_nithin » Mon Jul 04, 2022 4:27 pm

I want to read / write png files from flash storage. i am able to read png files with https://github.com/Ratfink/micropython- ... ter/png.py but that library does not allow me to write png files.

rkompass
Posts: 66
Joined: Fri Sep 17, 2021 8:25 pm

Re: read / write png files

Post by rkompass » Tue Jul 05, 2022 6:41 am

Just out of curiosity:
Did you try to comment out the Writer class?

ps_nithin
Posts: 14
Joined: Sat Jun 18, 2022 1:44 pm

Re: read / write png files

Post by ps_nithin » Tue Jul 05, 2022 8:28 am

I haven't tried that. :) But why would the author comment it out if it works good.

User avatar
karfas
Posts: 193
Joined: Sat Jan 16, 2021 12:53 pm
Location: Vienna, Austria

Re: read / write png files

Post by karfas » Tue Jul 05, 2022 11:00 pm

You didn't answer my question "Where does your graphic data come from?".
Depending upon your application, it might be sufficient to write files using a simpler format (TIFF, GIF) or render the PNG files elsewhere (e.g. in a web browser).
A few hours of debugging might save you from minutes of reading the documentation! :D
My repositories: https://github.com/karfas

ps_nithin
Posts: 14
Joined: Sat Jun 18, 2022 1:44 pm

Re: read / write png files

Post by ps_nithin » Wed Jul 06, 2022 2:48 am

In my case I want to read png file from onboard storage, run some image processing algorithms and write the output back to onboard storage as png file. Then view the output png from pc.

ps_nithin
Posts: 14
Joined: Sat Jun 18, 2022 1:44 pm

Re: read / write png files

Post by ps_nithin » Wed Jul 06, 2022 2:55 am

karfas wrote:
Tue Jul 05, 2022 11:00 pm
You didn't answer my question "Where does your graphic data come from?".
Depending upon your application, it might be sufficient to write files using a simpler format (TIFF, GIF) or render the PNG files elsewhere (e.g. in a web browser).
How can i write files in tiff / gif format. Is there a library for that? Also, how can I render png in a web browser without writing a png file?

Post Reply