danielgtaylor / jpeg-archive

Utilities for archiving JPEGs for long term storage.
1.17k stars 121 forks source link

Only read input once #85

Closed rikonor closed 6 years ago

rikonor commented 6 years ago

I was having trouble using stdin/stdout for input/output to jpeg-recompress.

Digging a little bit deeper and with the help of @pope I realized that jpeg-recompress actually reads the input multiple times, so by the second read the input is already drained. This is why it works fine with files, but not with pipes/stdin.

The fix adds new decodeFiletype and decodeFile versions that take a buffer instead of reading the file themselves.

rikonor commented 6 years ago

Hey @lfos, thanks for the review.

I'm sorry but I won't have time to touch this in the next few weeks. If you're open to it, I'm fine with you taking over the PR and making changes as you see fit.

lfos commented 6 years ago

Merged to pu (with some minor changes). Thanks!