3

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

mdelvecchio
  • 567
  • 1
  • 5
  • 25
  • 1
    If setting the `ExifProfile` property to null is not working and you are still somehow getting exif data saved in your thumbnail save then please raise an issue on the github repo https://github.com/SixLabors/ImageSharp/issues/new/choose as that is a bug and is all you need to do... please provide any reproduction steps include code samples and sample images (as much as you can) as it'll make investigating easier. – tocsoft Feb 12 '22 at 21:03
  • Will do. Yeah its reproducible every time w/ my source images & resulting output images. – mdelvecchio Feb 12 '22 at 22:40

1 Answers1

8

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;
mdelvecchio
  • 567
  • 1
  • 5
  • 25