I need to optimize some images, but not change their name.
jpegtran -copy none -optimize image.jpg > image.jpg
However, this seems to crea
Without sponge, another alternative with lower HDD or SSD writing access is to use the /dev/shm to save the temporary file and then overwrite it locally right away.
jpegtran -copy none -optimize image.jpg > /dev/shm/tmp.jpg && cat /dev/shm/tmp.jpg > ./image.jpg
The concept can be easily adapted into any script, perhaps with caveats about the temporary filename not being the same, in order to avoid collisions if there are multiple instances running at the same time. It's possibly interesting to think about some unique filename pattern generation scheme, perhaps something along the lines of ${originalfilename}-jpgtrantmp-$$.