Hi all!
A few months ago I tried to parse PNG images in Mojo, and wrote up the results as a little library called Mimage.
Mimage is now available in the modular-community
channel, and can be installed with magic as:
magic add mimage
NOTE: this is currently supported on the latest stable version of MAX/Mojo (25.2).
I will try to keep this up to date with stable releases.
The goal of the library is to be able to read and write most common image file formats (PNG, JPEG, TIFF) in pure Mojo.
The library is very much still in it’s infancy and can only read PNGs, but if someone is looking for a fun project to contribute to, then please feel free to implement some of the other parts.
Some possible tasks:
- Implement the
zlib/DEFLATE
algorithm in Mojo - Implement PNG writing
- Implement JPEG parsing
- Add more test cases for PNG
- Support 16-bit PNG files
- Return
max.driver.Tensor
instead ofmax.tensor.Tensor
Most of the library is written in Mojo, but the lib does currently make a FFI call to zlib for decompressing PNG files.
The decompression should probably live in it’s own library as it is a pretty common algorithm used in more than just image parsing, likely together with CRC32 calculations, which I did implement in Mojo for this lib.
So if someone does write an equivalent to zlib in Mojo please let me know so I can use it and/or port over the CRC32 code.