-o stdout bug on Windows

Discussions on NConvert - the command line tool for image conversion and manipulation

Moderators: XnTriq, helmut, xnview

xupefei
Posts: 2
Joined: Sun Aug 12, 2018 12:11 pm

-o stdout bug on Windows

Post by xupefei »

Hi,

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?

Thanks!
User avatar
xnview
Author of XnView
Posts: 44936
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Re: -o stdout bug on Windows

Post by xnview »

you want only \r?
Pierre.
xupefei
Posts: 2
Joined: Sun Aug 12, 2018 12:11 pm

Re: -o stdout bug on Windows

Post 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.
User avatar
xnview
Author of XnView
Posts: 44936
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Re: -o stdout bug on Windows

Post by xnview »

right, i'll fix it
Pierre.