brendan-duncan / image

Dart Image Library for opening, manipulating, and saving various different image file formats.
MIT License
1.14k stars 255 forks source link

Support PNM #617

Closed liquidiert closed 3 months ago

liquidiert commented 4 months ago

Hi! I would love to see support for PNM type images :)

brendan-duncan commented 4 months ago

Those formats are still being used?

liquidiert commented 4 months ago

I currently work with old SANE scanners that output PNM images. So sadly yes

brendan-duncan commented 4 months ago

They're very simple formats so it won't be a problem to add at least decoders for them, when I can squeeze in some free time to work on it. Please remind me if it gets to be too long and I forget.

liquidiert commented 4 months ago

Thanks a lot!

brendan-duncan commented 3 months ago

I finally got to this, but it will probably still be some time before I can do a release. I added PmnDecoder class, decodePnm and decodePnmFile functions.

It should support PBM, PGM, and PPM ascii and binary variants. PNM has some weird variants, like 16-bit (which most things don't support) or partial color value ranges (0...128 instead of 0...255, for example), which the current code doesn't do a good job with yet. Hopefully your scanner makes sane regular PNM images.

liquidiert commented 3 months ago

Yeah it's a bit of a mess.... Thanks for your efforts!

brendan-duncan commented 3 months ago

I'll go ahead and close this. Feel free to open a new issue if there are issues with the PNM implementation.