简体   繁体   中英

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

I found a GitHub issue showing how to remove an Image's exif data by setting its ExifProfile to null:

 SixLabors.ImageSharp.Image image = Image.Load(imagePath);

 //remove exif
 image.Metadata.ExifProfile = null;
    
 //resize
 image.Mutate(x => x.Resize(width, height));
    
 //save
 SixLabors.ImageSharp.Formats.Jpeg.JpegEncoder encoder = new SixLabors.ImageSharp.Formats.Jpeg.JpegEncoder();
    
 encoder.Quality = 30; 
                        
 image.Save(thumbnailPath, encoder);

...but it doesn't seem to work for me -- the saved jpeg's are the same size, and my when inspected by my OS they show me all the camera's EXIF settings. When I do this same inspection on images created from another utility the OS does not show me all the EXIF settings...so I'm inclined to say this ImageSharp technique is not scrubbing them correctly.

Any idea?

https://github.com/SixLabors/ImageSharp/issues/400

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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM