0

How can I get Windows CMD to understand this type of things, what I have in bash:

cjpeg /jpg/image.jpg | jpegtran -optimize > result/jpg/image.jpg

I want to pipe the output of one MozJPEG command into another.

P.S.

Before I used 'temp' folder in my script.

cjpeg -quality 80 /jpg/image.jpg > /temp/image.jpg
jpegtran -optimize /temp/image.jpg > /result/jpg/image.jpg

Run first command - save result in temp. After this, take file from 'temp' and pass it into second command - save final result. But it creates unnecessary actions and garbage in folders :(

Will be appreciated for any help and advices!

Daniel Petrov
  • 95
  • 3
  • 12
  • 2
    The Windows Command Processor `cmd.exe` is designed to execute internal commands of `cmd.exe` and executables and process text files. It is not designed for processing binary data. It might work to use `cjpeg -quality 80 "C:\Folder Path\jpg\image.jpg" | jpegtran -optimize -outfile "C:\Folder Path\result\jpg\image.jpg"`, but I have myself never used `COMMAND.COM` or `cmd.exe` to pipe binary data output by one executable to __STDOUT__ to the __STDIN__ if another executable. I don't know if that data redirection works in this case with binary data. – Mofi Dec 05 '22 at 07:16
  • @Mofi WOW! It is work. I wasted whole day looking for answer... Thank you so much! – Daniel Petrov Dec 05 '22 at 08:05

0 Answers0