JacobDev1 / xl-converter

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

Error F2 conversion failed (output not found) #62

Closed Dogstar359 closed 2 months ago

Dogstar359 commented 3 months ago

Question

Hello im trying to convert my jpg images to jxl and as the title describes i get this error on certain images, but not others. i cant seem to find out what this error is or if it is even bad. i tried looking at the log, and it seems there is an error.

JPEG bitstream reconstruction data could not be created. Possibly there is too much tail data.

Try using --jpeg_store_metadata 0, to losslessly recompress the JPEG image data without bitstream reconstruction data.

EncodeImageJXL() failed.

I tried adding --jpeg_store_metadata 0 to the cjxl JPEGXL additional encoder arguments line, but i still get this error. Is this a bug or am i doing something wrong?

can anyone help. Thankyou

The Docs

Dogstar359 commented 3 months ago

i dont understand i unzipped the file, and there is x86_64-w64-ranlib.exe, libssp-0.dll if i click on the x86_64-w64-ranlib.exe nothing happens. Do i copy the two files into the installation folder, if so where do i put them.

Dogstar359 commented 3 months ago

what do you mean select "gcc" in the installer menu?

Dogstar359 commented 3 months ago

Do you want me to uninstall, and then reinstall XL Converter?

JacobDev1 commented 3 months ago

No! Do not install anything without my knowledge. Users @pilot5657 and @swaggy111 shared a trojan virus.

VirusTotal

Dogstar359 commented 3 months ago

I figured it was after windows defender deleted it, also what they were saying didnt make any sense. Its just that they replied, and i thought it was a fix to my problem. I just dont know why some of my pictures sets compress without any errors, and others spit out this F2 error on completion. Anyway thankyou for your reply, and warning of the users you mentioned.

JacobDev1 commented 3 months ago

@Dogstar359 Please, use ESET Online Scanner to scan everything that's connected to your PC. Then scan other devices if you've connected them after the attack.

You fell for a social engineering attempt. The red flag was 2 profiles posting the exact same message. I reported the users.

I'll get back to solving your issue later. Please, scan your PC in the meantime.

Dogstar359 commented 3 months ago

will do. i have a feeling that my problem has to do with the images containing metadata, but when i strip the metadata it makes the jpg files way larger than the original image, thus when compressing to jxl the image files are larger than the original jpgs.

JacobDev1 commented 3 months ago

My apologies for the inconvenience.

Investigation

From what I could find:

Lumma Stealer (aka LummaC2 Stealer) is an information stealer written in C language that has been available through a Malware-as-a-Service (MaaS) model on Russian-speaking forums since at least August 2022.

description

Wayback Machine snapshot of this page is available for security researchers.

The issue

I think metadata could be the issue as well. I was going to suggest removing metadata first, but you've already tried that.

cjxl is a tool from libjxl. To have it fixed, you can try filing an issue to the libjxl repo. However, this requires familiarizing yourself with the installation and use of cjxl.

You can also send the problematic image with metadata to my email if you want me to investigate further. contact@codepoems.eu

Dogstar359 commented 3 months ago

Here is a log file of one of the images im trying to convert from jpg to jxl.

[INFO] [runProcess] ('C:\Program Files (x86)\XL Converter\_internal\bin\win\cjxl.exe', 'E:\Temp\0_0009.jpg', '-q', '100', '-e', '9', '--lossless_jpeg=1', '--num_threads=14', 'E:\Converted\.\0_0009_5e4.jxl') [DEBUG] [Worker #0] Started [DEBUG] [runProcess] JPEG XL encoder v0.10.2 e148959 [AVX2,SSE4,SSE2]

Encoding [JPEG, lossless transcode, effort: 9]

JPEG bitstream reconstruction data could not be created. Possibly there is too much tail data.

Try using --jpeg_store_metadata 0, to losslessly recompress the JPEG image data without bitstream reconstruction data.

EncodeImageJXL() failed.

[INFO] [Worker #0 - Convert] ('C:\Program Files (x86)\XL Converter\_internal\bin\win\cjxl.exe', 'E:\Temp\0_0009.jpg', '-q', '100', '-e', '9', '--lossless_jpeg=1', '--num_threads=14', 'E:\Converted\.\0_0009_5e4.jxl') [DEBUG] [Worker #0] Finished [DEBUG] Active Threads: 0 [INFO] [runProcess] ('C:\Program Files (x86)\XL Converter\_internal\bin\win\cjxl.exe', 'E:\Temp\0_0009.jpg', '-q', '100', '-e', '9', '--lossless_jpeg=1', '--num_threads=14', '--jpeg_store_metadata', '0', 'E:\Converted\.\0_0009_74e.jxl') [DEBUG] [Worker #0] Started [DEBUG] [runProcess] Unknown argument: --jpeg_store_metadata

Use 'C:\Program Files (x86)\XL Converter_internal\bin\win\cjxl.exe -h' for more information

[INFO] [Worker #0 - Convert] ('C:\Program Files (x86)\XL Converter\_internal\bin\win\cjxl.exe', 'E:\Temp\0_0009.jpg', '-q', '100', '-e', '9', '--lossless_jpeg=1', '--num_threads=14', '--jpeg_store_metadata', '0', 'E:\Converted\.\0_0009_74e.jxl') [DEBUG] [Worker #0] Finished [DEBUG] Active Threads: 0

After searching the internet it seems that it is to do with the tail data, as when i use exiftool 12.93 with GUI to remove the metadata, and try again it still throws out an error.

JacobDev1 commented 3 months ago

I see.

Edge cases like this happen. cjxl will not be able to process every JPEG.

This is an issue with cjxl, not my program specifically. This is why I suggested filing an issue to the libjxl repo.

You could try checking if the JPEG is correct by using ImageMagick. It's included in xl-converter/bin/win/magick.exe.

magick identify image.jpg

If no errors appear, that's an edge case with cjxl.

Dogstar359 commented 3 months ago

This is what i get when i run ImageMagick

C:\Program Files (x86)\XL Converter_internal\bin\win>magick identify 0_0009.jpg 0_0009.jpg JPEG 6720x4480 6720x4480+0+0 8-bit sRGB 2.58512MiB 0.000u 0:00.001

could you give me the link to libjxl repo as im not sure which one. Is it libxj (jonathan) or libxj/elasticsearch ?

JacobDev1 commented 3 months ago

ImageMagick did not detect any errors.

This is the official libjxl repo https://github.com/libjxl/libjxl

To get cjxl.exe go to:

The following will recompress your JPEG by default:

cjxl input.jpg output.jxl
JacobDev1 commented 3 months ago

Note: If you're trying to file an issue to libjxl, you should provide the input image. Make sure you're comfortable with it, if not, then don't file an issue. It's extremely difficult to troubleshoot this type of problem without the input data.

Dogstar359 commented 3 months ago

yea thats the problem, the images are of family and friends and are kind of personal. i tried the command and it throws out which seems to be the same as XL Converters Log.

E:\libjxl>cjxl 0_0009.jpg 0_00091.jxl -v JPEG XL encoder v0.10.3 4a3b22d [AVX2,SSE2] Note: Implicit-default for JPEG is lossless-transcoding. To silence this message, set --lossless_jpeg=(1|0). Read JPEG image with 2710692 bytes. Encoding [JPEG, lossless transcode, effort: 7] JPEG bitstream reconstruction data could not be created. Possibly there is too much tail data. Try using --jpeg_store_metadata 0, to losslessly recompress the JPEG image data without bitstream reconstruction data. EncodeImageJXL() failed.

i also tried adding --jpeg_store_metadata 0 but then get this error.

E:\libjxl>cjxl 0_0009.jpg 0_00091.jxl --jpeg_store_metadata 0 Unknown argument: --jpeg_store_metadata Use 'cjxl -h' for more information

it a shame as most of the large collection of images seem to encode no problem, i dont know what could be so different about these images.

JacobDev1 commented 3 months ago

Without the input image it's next to impossible for the engineers to troubleshoot this problem. Generally, you should not file this type of issue if you're not prepared to share the input as it just wastes engineering time.

Some ways of providing equivalent input data:

  1. Create a sample image. Read metadata using ExifTool and figure out the writing program used. Use that to recreate the problematic image.
  2. This is purely hypothetical. Perhaps you could use jpegtran to crop that JPEG so it's indiscernible. Of course as long as it exhibits the same behavior. I've never tried it though.

I'm afraid I can't help you there.

JacobDev1 commented 3 months ago

As a side note, this is what the error message is supposed to say:

        fprintf(stderr,
                "JPEG bitstream reconstruction data could not be created. "
                "Possibly there is too much tail data.\n"
                "Try using --allow_jpeg_reconstruction 0, to losslessly "
                "recompress the JPEG image data without bitstream "
                "reconstruction data.\n");

In the logs there is jpeg_store_metadata instead of allow_jpeg_reconstruction which is quite strange. Still, using it would defeat the purpose of recompression. Just a mental note.

JacobDev1 commented 3 months ago

I saw your libjxl issue. You mentioned the need for "resaving" a JPEG without losing quality.

The most common way to do that is to use jpegtran which is why I suggested it. However, the size may get slightly bigger.

Dogstar359 commented 3 months ago

I just tried again using the above --allow_jpeg_reconstruction 0 in XL Converter, and it processed the image without error. Does this mean it worked ? I mean the image seems fine, and its smaller than the original.

Does this reconstruction change the fidelity of the images or are they the same as the original ? As i am archiving my photographs to save space.

If its the case ill close the thread.

Thankyou for your help by the way i probably come across as a major pain.

JacobDev1 commented 3 months ago

It does not change how the image is displayed. The quality is the same.

However, you lose the ability to reconstruct the new JPEG XL image back to the original JPEG with no quality loss. Converting JXL -> JPEG will no longer be possible without re-encoding (losing quality) with --allow_jpeg_reconstruction 0.

Please give some thought to whether you're comfortable with this.

Dogstar359 commented 3 months ago

will a future update possibily fix this problem or is this a problem with the jpgs itself. i mean i can always skip compressing those groups of photos. Its just that im not really an expert, i used jxl format because i can keep the integrity of the images, but make them smaller. Its just that it seems to be newer jpgs the older collection of photos ive have seem to convert fine, it just means newer photograps ill not be able to convert to jxl which sucks.

JacobDev1 commented 3 months ago

Whether this gets fixed is all up to the libjxl devs. I regularly update cjxl, so the fix would carry over.

Problems like that are usually related to images being encoded in an uncommon way. Similar issues should be expected.

My recommendation is don't use -allow_jpeg_reconstruction 0 and skip the problematic images for now. ~20% space saved is not worth losing the ability to access the original JPEG.

Dogstar359 commented 3 months ago

i have the original jpegs backed up so no problem, ill leave it for them time being. Again Thankyou for your help, and Thankyou for dealing with the trojan virus problem. By the way i scanned my computer with ESET Online Scanner, and luckily there were no threats so all good.

JacobDev1 commented 3 months ago

You're welcome. I'm glad to hear your system is safe.

JacobDev1 commented 2 months ago

This problem could be related to the fact the reconstruction data cannot store unused quantization tables. This is a limitation of the JPEG bitstream reconstruction specifications itself.

However, without access to the input data, it's impossible to tell what is really going on.

You could try to rewrite those images with jpegtran. This should discard any unnecessary data.

For easy and pleasant installation of command line utilities I recommend using Scoop.

Here is how to install jpegtran with it.

scoop install git
scoop install libjpeg-turbo

Now, you have access to jpegtran. You can rewrite image like this.

jpegtran -copy all -optimize source.jpg > destination.jpg

Here is how you install cjxl:

scoop install libjxl

[!NOTE] cjxl should not be expected to create reconstruction data for every type of JPEG. It's incredible for what it can do already. Edge cases will happen.

Dogstar359 commented 2 months ago

i tried jpegtran this afternoon with commands similiar to the one you posted, it seems to be working there are no bitstream errors in the produced jxl files, and they seem to decode fine back into jpgs which is great, its just that it is slow going as its command line so one image at a time. I dont suppose there is a gui for jpegtran because that would certainly speed things up.

Dogstar359 commented 2 months ago

i also found out from libjxl github that it does seem to be a problem with the jpg images, something to do with edge case, and that there is more information stored in the jpg images than the jxl format can handle so a bitstream error occurs, and it seems the best way to deal with it like you said is to remove the extra hopefully useless data so its not an issue with either XL Converter or libjxl.

JacobDev1 commented 2 months ago

There is no GUI for it that I'm aware of.

If you have a lot of files to process, don't run the commands by hand. Use a script.

Something like:

@echo off

if "%1"=="" goto :usage
goto :main

:main
set "input_dir=%~f1"
set "output_dir=%input_dir%\output"
mkdir "%output_dir%" 2> nul
for %%F in ("%input_dir%\*.jpg" "%input_dir%\*.jpeg") do (
    jpegtran -copy all -optimize "%%F" > "%output_dir%\%%~nxF"
)
echo Finished processing to %output_dir%
goto :eof

:usage
echo Usage: %0 <input_folder>

Copy this code, save it as script.bat in the folder with JPEGs.

Then run it:

script.bat .

Remember the dot at the end. You can modify how jpegtran is run by changing its options in the for loop.

Ukhryuk-Hai commented 2 months ago

I have encountered a few situations where image files were huge because there were a lot of zeros at the end of the file. These images were downloaded from the Internet using a specific program, and I assume that it glitched at that moment. They usually open without problems in viewers, but when trying to convert them, problems may arise. One of these JPG files was 4+ Gigabytes in size, although it should have been about 3 Megabytes. The easiest way is to open it in a HEX editor and look at it.

Dogstar359 commented 2 months ago

I had a look at my images to see if there were extra zeros at the end of the images, unforunately there were none, my images are from a kodak digital camera i had, i cant remember the model. Its ok i managed to use jpegtran, and then convert them to jxl format. The images did grow in size by a few kilobytes each. Looking on various forums it seems when optimizing the huffman tables in the image it can cause the file size to grow. I dont know why though, this is all new to me, and im learning as i go.

Dogstar359 commented 2 months ago

Thankyou JacobDev1 for your script, i have managed to convert all of my problematic images using jpegtran, and are now converting them to jxl format.