Skip to content
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

Lossless transcoding of lossless, arithmetic, hdr legacy JPEG #2685

Open
gitoss opened this issue Jul 26, 2023 · 4 comments
Open

Lossless transcoding of lossless, arithmetic, hdr legacy JPEG #2685

gitoss opened this issue Jul 26, 2023 · 4 comments
Labels
colorspace relates to hte use of color spaces, ICC profiles, etc documentation Improvements or additions to documentation unrelated to 1.0 Things that need not be done before the 1.0 version milestone

Comments

@gitoss
Copy link

gitoss commented Jul 26, 2023

Describe the bug
The official JPEG-XL website states "Lossless JPEG transcoding: about 20% smaller" - however, this some perfectly in-spec jpeg encoding methods are not supported and result only in a cryptic error message "JxlEncoderAddJPEGFrame() failed".

To Reproduce
Encode 1. lossless jpeg (cjpeg -lossless 7), 2. arithmetic jpeg (cjpeg -arithmetic), 3. hdr jpeg (cjpeg -precision 12) and convert with cjxl --lossless_jpeg=1. I've attached respective samples.

Expected behavior
Expected behavior would either be a verbose error message (lossless | arithmetic | hdr not supported) or ideally a lossless conversion to jxl. The arithmetic encoding is easy to remove tough (jpegtran -optimize).

Environment

Additional context
... the sample jpeg won't show inline at all or not in all browers, use the direct links.
https://github.com/libjxl/libjxl/assets/10775306/7905df08-0fc2-400e-a64b-66f3221bce0b
https://github.com/libjxl/libjxl/assets/10775306/7e4980f2-58c8-4f71-8816-c78a98207bc4
https://github.com/libjxl/libjxl/assets/10775306/21223d30-2c6d-47c6-9185-495a984ca79b

sample-hdr12
sample-lossless
sample-arithmetic

@gitoss
Copy link
Author

gitoss commented Jul 26, 2023

Another case seem to be cmyk legacy jpeg files: #2542 #2580

@antermin
Copy link

antermin commented Jul 27, 2023

See also: #1172

We don't intend to support all of the original JPEG spec, nor all of JPEG XT. For lossless JPEG recompression, we only support the de facto JPEG format, i.e. what is commonly implemented in browsers, image viewers, image editors, etc. This includes the JFIF and Exif file formats with a payload that is baseline or progressive Huffman-coded, 1 or 3 components, with or without the YCbCr color transform, and with chroma subsampling that is 4:4:4, 4:2:2 or 4:2:0.

Other things that are in the original JPEG spec but are not considered part of the 'de facto' standard are outside the scope of lossless JPEG recompression in JPEG XL, for the simple reason that they are many orders of magnitude more rare, and it would have been a significant complication to extend the bitstream reconstruction procedure to also accomodate for that. This includes arithmetic coding, lossless, hierarchical, strange subsampling factors, and CMYK (JXL does support CMYK, but not lossless recompression of CMYK JPEGs).


a verbose error message (lossless | arithmetic | hdr not supported)

I agree that cjxl should output better error messages. (#2580)

@gitoss
Copy link
Author

gitoss commented Jul 27, 2023

Right, I didn't see #1172 - that doesn't mention 12-bit jpeg though :-)

I'm leaving the ticket open until a master "better error messages" ticket references it, or it's resolved with an at least slightly less cryptic error message in the code.

@wwinniww
Copy link

wwinniww commented Aug 2, 2023

Mentioning HDR JPEG,
are there plans to support lossless conversation of files in Ultra HDR Image format from Google to JXL?

https://developer.android.com/guide/topics/media/platform/hdr-image-format

@mo271 mo271 added documentation Improvements or additions to documentation unrelated to 1.0 Things that need not be done before the 1.0 version milestone labels Aug 2, 2023
@mo271 mo271 added the colorspace relates to hte use of color spaces, ICC profiles, etc label Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
colorspace relates to hte use of color spaces, ICC profiles, etc documentation Improvements or additions to documentation unrelated to 1.0 Things that need not be done before the 1.0 version milestone
Projects
None yet
Development

No branches or pull requests

4 participants