I have some JPEG files uploaded by users. I need to be sure they are clean. Sure, I can just recompress them to JPEG again and I will get clean files but either I will loose quality or files will be bigger.So how can I repack JPEG files? I mean how can I loslessy copy body of the compressed JPEG but strip anything else (all comments, EXIF, zero bytes appended to files etc.)? I have seen some JPEG files with ZIP files appended to them. People use them to post as a JPEG but then they download, unpack the ZIP and have some special content hidden from site moderators. I want to avoid that too.
How can I repack JPEG?
jpeg
You can use jpegtran -copy none -optimize for that.