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
Losslessly converting color JPEG to grayscale JXL #3516
Comments
I'm not sure if this could be implemented in JXL's lossless JPEG transcoding. |
Internally, JPEG XL stores grayscale and color images in the same way (grayscale images just happen to have all-zero chroma components). So compression-wise, there is not really anything to gain here. For the bit-exact reconstruction of the JPEG images, obviously we cannot silently change RGB to Grayscale since that would result in a different reconstructed JPEG file. It also would lead to problems when there's an ICC profile in the JPEG, since you would get a grayscale image with an RGB ICC color profile, which is an invalid combination. If you know the images are grayscale then as was mentioned above, you may want to use
If you're not interested in reconstructing the jpeg file, which would not match the original one anyway, and want to trim of some more bytes, you can add |
Note that you might get a slightly different gamma transfer function for greyscale files in the viewing application. The gamma for greyscale might be set to 2.2 instead of sRGB (sGray). This will result in a slight brightening of the blacks, which might go unnoticed. Some simple programs don't support ICC for greyscale to indicate a gamma. Greyscale uses 1/3-rd of the memory and opens sligthly faster. Even in normal JPEG color compresses down to nothing if absent. |
cjxl will automatically set sRGB transfer fubnction in untagged images, so this should not be an issue. |
When it comes to manga (grayscale Japanese comic) files, many of the final production files that publishers end up encoding are JPEGs, due to their inclusion in EPUB files. When doing so, the majority of publishers do not encode these as grayscale (8BPP) JPEGs, even though this would result in no loss of data.
For a project I am working on, I would like to losslessly convert these JPEG files to JXL files to reduce their size, and have done so using
cjxl input.jpg output.jxl
. I would like to, however, also reduce the colorspace of these images at the same time, making them grayscale. I have confirmed that the images unsurprisingly remain in color after the conversion:Would it somehow be possible to losslessly reduce the colorspace during the JPEG --> JXL conversion?
The text was updated successfully, but these errors were encountered: