You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've used a personnal script with more or less same feature. As your code looks better I'll change to it :)
A feature miss in my use cas overwrite option. In many case I assume optimization should be done on the original file. Is it possible to add this behavior ?
Thanks
The text was updated successfully, but these errors were encountered:
camlafit
added a commit
to camlafit/shrinkpdf
that referenced
this issue
May 23, 2023
Hi, thanks for the suggestion. I think it often makes sense to overwrite the original file, but adding that feature is more difficult than it looks.
Overwriting the input file requires creating a temporary file to hold the outputs, because I assume Ghostscript requires the input and output files to be distinct. In any case we need to keep a copy of the original file in case the output turns out to be larger, and we want to restore the original file.
Temporary files are really difficult to create in a portable way in Posix shell. Even worse, to do it properly you'd need to trap signals to clean up the temporary file if the user aborts the script. It quickly becomes a major headache and complication, requiring a lot of machinery and probably sacrificing cross-platform portability.
So that's why I haven't implemented this seemingly obvious and useful feature. I've chosen to keep the script simple and focused, and this feature just invites too much complexity. The end user can probably script around it easily by creating a small wrapper script that works on their platform (using some non-portable tool like mktemp), but I don't think there's an easy way to supply that functionality out of the box.
I'd be interested in seeing a pull request that implements this in a portable way though.
Hi
I've used a personnal script with more or less same feature. As your code looks better I'll change to it :)
A feature miss in my use cas overwrite option. In many case I assume optimization should be done on the original file. Is it possible to add this behavior ?
Thanks
The text was updated successfully, but these errors were encountered: