Giter VIP home page Giter VIP logo

Comments (3)

jonsneyers avatar jonsneyers commented on June 13, 2024

These JPEGs contain two quantization tables but only use one. There is no way in jxl to store a quantization table that is not used, so it is impossible to reconstruct the jpeg bitstreams in this case. That's why JXL_ENC_ERR_JBRD is returned.

This is a limitation of the jpeg bitstream reconstruction specification: jpeg quantization tables are restored based on the corresponding quantization table in the jxl codestream, but in jpeg you can specify a quantization table and then never use it (which is of course just a waste of bytes, and I wonder why any jpeg encoder would ever want to do that), while in jxl you can only specify quantization tables that are actually used.

The jpeg image data itself can be represented just fine when JXL_ENC_ERR_JBRD is returned, it's just impossible to create the jpeg bitstream reconstruction data that will allow you to reconstruct the exact same jpeg file.

One option is to fall back in this case to encoding with JxlEncoderStoreJPEGMetadata set to false. Another option is to 'sanitize' the jpeg with a tool like jpegtran, which will remove the unused quantization table and create a (smaller) jpeg file that can actually be reconstructed.

From the libjxl point of view, I don't think there's much we can do here...

from libjxl.

John-P avatar John-P commented on June 13, 2024

Thank you for getting back to me. I hadn't realised that there was an unused table. I'm sure I can figure out a way to strip that out. I'll give jpegtran a try and see how that goes.

from libjxl.

John-P avatar John-P commented on June 13, 2024

jpegtran does appear to strip out these unused tables just fine, allowing the image to be repackaged using libjxl. Thank you for the help. As libjpeg and jpegtran didn't complain about these files, and they open as usual in an image viewer/web browser, it was hard to identify the issue.

It may be helpful to be a little more verbose/granular in the libjxl errors, if possible, to help identify files such as this. I found JxlEncoderError JXL_ENC_ERR_JBRD a bit too broad to be helpful. Also, I was not sure what is meant by "too much tail data" and a quick web search did not help me here. I think this means extra data appended to the JPEG file after an EOI marker but it would be nice to have this documented somewhere as I had to guess what this means.

EDIT: Maybe just a list and a brief explanation of some common causes of JXL_ENC_ERR_JBRD in the docs would be enough to be very helpful with debugging.

from libjxl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.