JacobDev1 / xl-converter

Easy-to-use image converter for modern formats. Supports multithreading, drag 'n drop, and downscaling.
https://codepoems.eu/xl-converter
Other
147 stars 4 forks source link

Please add an option to automatically convert YUV -> RGB for JPG -> JXL. #46

Closed Ukhryuk-Hai closed 3 weeks ago

Ukhryuk-Hai commented 1 month ago

Let's say I'm doing a conversion and sometimes there are files left that the program couldn't process. If these are damaged files and they can still be opened in the viewer, then I leave them as is. But often the remainder may contain a certain number of YUV encoded files, which can still be processed by the converter. And then all that remains is to open each file sequentially, look at the encoding type and sort it manually, then convert it to PNG in XnConvert, and only then use XL-Convert.

So why not automate the entire process? I have previously indirectly suggested something similar, but perhaps during this time you have ideas on how to implement it.

JacobDev1 commented 1 month ago

The program already supports YUV color space. If you spot a problem, file a bug report (using a template).

The feature you've described falls far outside of this program's scope.

XL Converter version 1.0.2 will be able to log encoder text output to file, so you can read the error messages.

In the meantime, try to convert the problematic images with cjxl, which should give you more insight.

Ukhryuk-Hai commented 1 month ago

So, I tried to create a Python script with ChatGPT that detected the color space and moved non-RGB files into a subfolder. After two hours, several libraries and ExifTool, the best result is the correct recognition of a single file. Now I understand why you don't want to take on this 😂

All that remains is to simply give all the remaining unprocessed files to XnConvert and hope that it can convert at least some of them (to PNG).

JacobDev1 commented 1 month ago

Without errors returned by cjxl during conversion or the actual images, I cannot help you.

Alternatively, you could use FFmpeg to generate a sample image with the matching specs and post that command.

JacobDev1 commented 1 month ago

Your problem most likely lies elsewhere. The images you have issues with might either have a corrupted color profile or use a non-standard color space.

JPEG encoders commonly use YCbCr, which is derived from YUV. Other color spaces may be used as well.

During encoding, the color space is transformed into YCbCr. After subsampling and quantization, this data ends up as DCT coefficient in the actual file. The DCT coefficients represent frequency components; they do not store the color data directly.

When a JPEG image is decoded, YCbCr is transformed into the resulting color space (like RGB) based on the color profile.

Some image processing tools might display the resulting color space (typically sRGB) even if DCT coefficients were encoded using a different color space.

As a sidenote: XnConvert can work with some partially corrupted images. This does not mean the source image is fine, or that you should expect any program to just read it. Most transcoders stop processing when an image cannot be properly decoded.

JacobDev1 commented 3 weeks ago

I cannot identify the problem, so I'll close the issue.

The majority of JPEGs use YCbCr coefficients.

XL Converter v1.0.2 features logging to file (Settings -> Advanced -> Logging). You can use that to investigate this problem further.