Page 1 of 1

-o stdout bug on Windows

Posted: Sun Aug 12, 2018 12:17 pm
by xupefei

I am currently testing NConvert on windows, and want to avoid temporary file creation by redirecting output to the stdout. When collecting the output from stdout, the 0x0a in the output is always being converted to 0x0d+0x0a (\r\n) by Windows, which means that Windows treats the output as a string.

Can you forcibly set the output to binary (i.e., "setmode(fileno(stdout),O_BINARY)") in such case, so that Windows will not do such conversion?


Re: -o stdout bug on Windows

Posted: Mon Aug 13, 2018 7:43 am
by xnview
you want only \r?

Re: -o stdout bug on Windows

Posted: Tue Aug 14, 2018 12:33 pm
by xupefei
There should be any conversion at all, not limited to \x0a. All \x0a has been converted to \x0d\x0a when outputting to stdout -- which means that although nconvert is outputting binary data to stdout, Windows still treats it as a normal string and perform an automatic conversion.
There are of course lots of \x0a's in an image. Windows's conversion destroys the output file.

You can reproduce this issue by executing the command in Windows's cmd.exe:

Code: Select all

nconvert.exe -silent -o stdout -out png xxxx.jpg > result.png
As a comparison, dcraw.exe handle this issue by refusing to output binary data to the terminal. It only works when you have redirected the output to a file by xxxxx > out.bin.

Re: -o stdout bug on Windows

Posted: Tue Aug 14, 2018 2:30 pm
by xnview
right, i'll fix it