crop jpg lossless

Samstag, November 19, 2011 - malenki at 19:55 in Software

At wikimedia commons I was hinted that lossless cropping of jpg files exist. Strange it didn’t come to my mind searching for something like that myself.

But the recommended tool cropgui has an at least unaesthetic flaw: the cropped image contains no EXIF data anymore.

Having had a second look at the site of the author I guessed he ran into the same ugly behaviour of jpegtran tools I hit myself some time ago:
Jpegtran discards all EXIF data if it is not explicitly told to keep them, which happens with the switch “-copy all”.

To fix this issue at the cropgui-script (until the author does it himself) just do the following:
in cropgui.py, replace the line

task.add([’nice’, ‘jpegtran’, ‘-crop’, cropspec, image_name], target)

with

task.add([’nice’, ‘jpegtran’, ‘-copy’, ‘all’, ‘-crop’, cropspec, image_name], target)