etemesi254 / zune-image

A fast and memory efficient image library in Rust
Other
311 stars 29 forks source link

Add lossless transform #216

Open eugenesvk opened 1 month ago

eugenesvk commented 1 month ago

Jpeg has this fantastic option to do some image transformations losslessly, mostly rotate and crop (well, beyond the loss of the data you crop out :)) Would be great if Zune image woud be able to losslessly manipulate jpegs

(this would also help some fully replace turbojpeg with your great memory-safe library https://github.com/woelper/oculante/issues/264)

etemesi254 commented 1 month ago

This would be fantastic to have, but it's not that easy in the face value.

The problems are also pointed out in libjpeg-turbo at https://github.com/libjpeg-turbo/libjpeg-turbo/blob/main/transupp.h

But basically, jpeg images have very weird scaling factors that make for a lot of problems,the decoder is written in a certain manner that handles this, with some hacks to handle esoteric configurations, the code is complex, complicated and full of long explanations of why things are like that, and without care will break,(it does sometimes, see the other issues relating to jpeg), and I am generally right now against adding new features unless either wanted by a large majority or sometimes sponsored.

But in case there is a big need for this, I can guide one on where to write hooks that can enable this, further discussion is welcome

lilith commented 3 days ago

Most natural (from camera) images are multiples of 8x8, but I can't say I would bother with this for non-multiple-of-8 images.