views:

1097

answers:

4

I want to remove the EXIF information (including thumbnail, metadata, camera info... everything!) from JPEG files, but I don't want to recompress it, as recompressing the JPEG will degrade the quality, as well as usually increasing the file size.

I'm looking for a Unix/Linux solution, even better if using the command-line. If possible, using ImageMagick (convert tool). If that's not possible, a small Python, Perl, PHP (or other common language on Linux) script would be ok.

There is a similar question, but related to .NET.

+2  A: 

exiftool does the job for me, it's written in perl so should work for you on any o/s

https://owl.phy.queensu.ca/~phil/exiftool/

usage :

exiftool -all= image.jpg
oedo
Care to edit your post and add an example command-line?
Denilson Sá
sure :) although it's pretty simple
oedo
Some other interesting options: "-o outfile.jpg" or "-out outfile.jpg", "-overwrite_original" or "-overwrite_original_in_place", "-P" or "-preserve", "-r" or "-recurse"
Denilson Sá
A: 

With imagemagick:

convert <input file> -strip <output file>
JayM
Sorry, but -strip does not work as expected, since ImageMagick still recompress the JPEG file.
Denilson Sá
Note, by the way, that "-strip" might be useful if someone is doing other transformations with the file. Also note that "-thumbnail 123x456" is ALMOST equivalent to "-strip -resize 123x456".
Denilson Sá
+1  A: 

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 image.jpg > newimage.jpg
jpegtran -copy none -outfile newimage.jpg image.jpg

(If you are unsure about me answering my own question, read this and this and this)

Denilson Sá
A: 

Edit the ImageMagick source code to make -strip behave the way you want it to. Recompile. Done.

Himbo