How to remove EXIF data without recompressing the JPEG?
exiftool does the job for me, it's written in perl so should work for you on any o/s
https://exiftool.org/
usage :
exiftool -all= image.jpg
UPDATED - as PeterCo explains below this will remove ALL of the tags. if you just want to remove the EXIF tags then you should use
exiftool -EXIF= image.jpg
With imagemagick:
convert <input file> -strip <output file>
ImageMagick has the -strip parameter, but it recompresses the image before saving. Thus, this parameter is useless for my need.
This topic from ImageMagick forum explains that there is no support for JPEG lossless operations in ImageMagick (whenever this changes, please post a comment with a link!), and suggests using jpegtran (from libjpeg):
jpegtran -copy none -progressive image.jpg > newimage.jpg
jpegtran -copy none -progressive -outfile newimage.jpg image.jpg
(If you are unsure about me answering my own question, read this and this and this)
You might also want to look into Exiv2 -- it's really fast (C++ and no recompression), it's command line, and it also provides a library for EXIF manipulation you can link against. I don't know how many Linux distros make it available, but in CentOS it's currently available in the base repo.
Usage:
exiv2 rm image.jpg