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:
- Extract the ICC profile
- Strip EXIF data and image profile
- Add the ICC profile back
$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 useexiftool -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 newBitmap
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
How to Use Session Variables in Wordpress
How to Wrap Text Using Imagick in PHP So That It Is Drawn as Multiline Text
How to Auto-Resize a Div with CSS While Keeping Aspect Ratio
SQL Select * from Multiple Tables
How to Save/Redirect Output from Laravel Artisan Command
Display Custom Data on Woocommerce Admin Order Preview
No Hint Path Defined for [Mail] Laravel 5.4
Replacing Backslashes with Forward Slashes with Str_Replace() in PHP
PHP to Check If a Url Contains a Query String
Check If a String Is All Caps in PHP
Why a Full Stop, "." and Not a Plus Symbol, "+", for String Concatenation in PHP
Check Image Dimensions (Height and Width) Before Uploading Image Using PHP
Phpstorm: How to Add Method Stubs from a Pecl Library That PHPstorm Doesn't Currently Support
Php-Paypal-Error: 14077410:Ssl Routines:Ssl23_Get_Server_Hello:Sslv3 Alert Handshake Failure