-
Notifications
You must be signed in to change notification settings - Fork 592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make the jpeg encoder work with non-memory and non RGB8 images #1223
Conversation
…te slice This change allows users to encode jpeg images from other sources than memory, thus finally allowing the encoding of images that do not fit in memory. This also allows users to make the encoder work in a streaming fashion. (see image-rs#1219) This also finally allows encoding images from other pixel formats than 8-bit RGB. The conversion to 8bit YCbCr (used in JPEG) is done on the fly during encoding.
I'm not sure how being generic over |
Hi @HeroicKatora ! In dezoomify-rs, I handle missing image parts by writing black pixels in them. But this is up to the application developer to choose what to do. Anyway, I really don't think it's excessive to ask for image pixels to be infaillibly accessible when encoding an image. What do you think about the PR overall? |
Do we know whether this change leads to any performance regression? |
Any I/O operation is fallible be it disk failure, network failure, or data corruption. The strategy of using replacement pixels doesn't sound too bad for your application, it seems like a reasonable fallback. It only doesn't seem generically applicable. On the PR itself I'm fine with the interface. It even seems to add support for |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The performance doesn't seem too bad overall, and we have a likely fix in the pipeline. Overall, this unlocks many interesting possibilities for the jpeg encoder. Besides images stored externally (for which I don't consider this interface perfect but for which it is better than nothing) this includes lazily computed images. That's definitely note-worthy.
This also only adds little additional API: a single method. The only problem is that of color conversion but we already require the methods from Pixel
alone so it should not be the concern of this PR. Any replacement is likely to have an alternative trait bound available and requires a major version anyways.
Awesome! Thank you for merging. Would you be interested in a pull request adding the |
Change the JPEG encoder to work on a GenericImageView instead of a byte slice
This change allows users to encode jpeg images from other sources
than memory, thus finally allowing the encoding of images that
do not fit in memory.
This also allows users to make the encoder work in a streaming fashion.
(see #1219)
This also finally allows encoding images from other pixel formats than
8-bit RGB. The conversion to 8bit YCbCr (used in JPEG) is done on the fly
during encoding.
I need this change for dezoomify-rs.
I license past and future contributions under the dual MIT/Apache-2.0 license,
allowing licensees to chose either at their option.