ImageOptim / mozjpeg-rust

Safe Rust wrapper for the MozJPEG library
https://lib.rs/mozjpeg
Other
75 stars 19 forks source link

Fix 'Compress::set_color_space' bug #9

Closed ffuugoo closed 4 years ago

ffuugoo commented 4 years ago

Compress::set_color_space used to set mozjpeg_sys::jpeg_compress_struct::input_components, instead of mozjpeg_sys::jpeg_compress_struct::num_components.

I've removed this line completely, cause MozJPEG's jpeg_set_colorspace sets this field itself.

kornelski commented 4 years ago

libjpeg has separate settings for input and output colorspaces, and has conversion built-in.

The intention here is to set both input and output to the same colorspace, so that there's no conversion in the library. The bug here is probably that it doesn't set in_color_space too.

I suppose there could be separate set_input_colorspace and set_output_colorspace to clear this up and allow them to be sparate.

ffuugoo commented 4 years ago

@kornelski Oh, well. My intent here was to use those conversion routines. But setting only input_components without also setting in_color_space is definitely a bug.

(Also, it segfaults while using conversions, so original idea was not completely wrong. ¯_(ツ)_/¯)