1

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.

1 Answer 1

6

You can use jpegtran -copy none -optimize for that.

13
  • 1
    You beat me to it! But yes, jpegtran is a life-saver.
    – Wyatt Ward
    Apr 17, 2017 at 23:38
  • 1
    @Tom Sometimes, -progessive result in smaller files than -optimize. Apr 21, 2017 at 14:34
  • 1
    @user2233709 progressive JPEGs however don't work well with lepton and guetzli, which may not appear like a problem but the developers of those projects also brought up that progressive doesn't work well on mobile devices. Just a heads up.
    – LiveWireBT
    Apr 21, 2017 at 23:42
  • 1
    @user2233709 github.com/dropbox/lepton a tool dropbox developed to store JPEGs more efficiently in their data centers, quite useful if you want to backup a large amount of JPEGs and want to reduce the file size of the backup by ~10-20%, back and forth conversion also helps identifying broken files (you won't be able to convert them, but you know which one are broken then) github.com/google/guetzli the latest released research project from Google in the line of zopfli and brotli trying to improve a particular compression technology (or inventing a new one)
    – LiveWireBT
    Apr 22, 2017 at 13:43
  • 1
    @LiveWireBT Thanks for pointing these. Aren’t they better options than my suggested jpegtran? Should’t you propose them in a answer? Apr 22, 2017 at 13:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .