Menu

#423 ufraw-batch creates a corrupted JPEG when setting the output to stdout on Windows because all bytes with the value 0A are being replaced by 0D 0A (\r\n)

open
nobody
None
5
2018-08-29
2018-08-29
No

I am writing a Java program which displays RAW images by using ufraw-batch to convert them to JPEG files and then reading them with Java’s ImageIO.

While this works fine on Linux and MacOS, when I tried to run my program on Windows Java complained about an invalid input file.

Upon further inspection I discovered that ufraw-batch in fact produces different files from the same source file depending on whether the output is set to a file or to "-" (stdout). After comparing the output files in a hex editor I found out that the stdout output incorrectly handled all bytes with the value (which would equal \n) by adding a preceding 0D (\r) byte. This makes me believe that for some reason the stdout output of ufraw-batch has it’s \n characters converted to \r\n on Windows which explains the corrupted files. This occurs when reading ufraw-batch’s output from Java and also when calling the same command from the command line and redirecting the process’s output to a file. Setting the output to a file however produces a valid JPEG.

As a workaround I will now filter the ufraw-batch output to remove \r, but it would be great if this bug could be fixed.

Discussion


Log in to post a comment.