How to Remove Exif from a Jpg Without Losing Image Quality

How to remove exif from a JPG without losing image quality?

Consider keeping the ICC profile (which causes richer colors) while removing all other EXIF data:

  1. Extract the ICC profile
  2. Strip EXIF data and image profile
  3. Add the ICC profile back

In PHP + imagick:

$profiles = $img->getImageProfiles("icc", true);

$img->stripImage();

if(!empty($profiles))
$img->profileImage("icc", $profiles['icc']);

(Important note: using the ImageMagick 3.1.0 beta, the result I got from getImageProfiles() was slightly different from the documentation. I'd advise playing around with the parameters until you get an associative array with the actual profile(s).)

For command line ImageMagick:

convert image.jpg profile.icm
convert image.jpg -strip -profile profile.icm output.jpg

Images will get recompressed of course if you use ImageMagick, but at least colors stay intact.

Hope this helps.

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

How can I remove metadata from an image (JPG) without losing quality?

Ok, I finaly found a solution by using Apache "commons-imaging":

https://svn.apache.org/repos/asf/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/examples/WriteExifMetadataExample.java

    public void removeExifMetadata(final File jpegImageFile, final File dst)
throws IOException, ImageReadException, ImageWriteException {
OutputStream os = null;
try {
os = new FileOutputStream(dst);
os = new BufferedOutputStream(os);

new ExifRewriter().removeExifMetadata(jpegImageFile, os);
} finally {
if (os != null) {
try {
os.close();
} catch (final IOException e) {

}
}
}
}

Remove EXIF data from JPG using PHP

Use gd to recreate the graphical part of the image in a new one, that you save with another name.

See PHP gd


edit 2017

Use the new Imagick feature.

Open Image:

<?php
$incoming_file = '/Users/John/Desktop/file_loco.jpg';
$img = new Imagick(realpath($incoming_file));

Be sure to keep any ICC profile in the image

    $profiles = $img->getImageProfiles("icc", true);

then strip image, and put the profile back if any

    $img->stripImage();

if(!empty($profiles)) {
$img->profileImage("icc", $profiles['icc']);
}

Comes from this PHP page, see comment from Max Eremin down the page.

Python: Remove Exif info from images

You can try loading the image with the Python Image Lirbary (PIL) and then save it again to a different file. That should remove the meta data.

Easy way to clean metadata from an image?

  • The .NET way: You may want to try your hand at the System.Windows.Media.Imaging.BitmapEncoder class - more precisely, its Metadata collection. Quoting MSDN:

Metadata - Gets or sets the metadata that will be associated with this
bitmap during encoding.

  • The 'Oops, I (not so accidentally) forgot something way: Open the original bitmap file into a System.drawing.Bitmap object. Clone it to a new Bitmap object. Write the clone's contents to a new file. Like this one-liner:

    ((System.Drawing.Bitmap)System.Drawing.Image.FromFile(@"C:\file.png").Clone()).Save(@"C:\file-nometa.png");

  • The direct file manipulation way (only for JPEG): Blog post about removing the EXIF area.

How do I clear an Image's EXIF data with ImageSharp?

Turns out there are two different types of metadata - EXIF and XMP. It is necessary to set both objects to null to remove them all:

image.Metadata.ExifProfile = null;
image.Metadata.XmpProfile = null;


Related Topics



Leave a reply



Submit