Closed KrylosovM closed 2 years ago
I Just got this same thing trying to make this into a serverless function.
going to try this out with a build.
Right I've a patch for this. It was a bit more of a pain than I first thought, but it now works on my PC and I'm pretty happy
@KrylosovM @tjko My solution would likely benefit from feedback. I've made a heap of assumptions, but I feel pretty positive about it.
The latest commit adds a command line argument for --read-bytes
shortcode -B
which takes the number of bytes passed to stdin. It also checks that is larger than the minimum possible size for a valid JPEG, and detects if the input to stdin is larger than the buffer (defaults to 32MB).
It does change the behaviour so that -f
is not passed by default and that output is silenced when --stdin
or --stdout
arguments are provided.
This has now been implemented with commit: 05c3f85aa1330f88f20b86c9d535a72735ed33a1
Would be great if input file from stdin passed to stdout when result of optimization is larger than original. At the moment
--stdin
option enables--force
option that forces optimized file to stdout, even if it is larger than original.