Search code examples
imagesharp

Remove Exif data from image when using Imagesharp.web


I'm using imagesharp.web. Image width/height is reduced as expected, but size not reduced to fit for web applications(Size is more that 1 MB). I found that Exif data are there in the image contributing to this size.

Is there a way to remove Exif data from a image when we use Imagesharp.web?


Solution

  • You can set the Metadata.ExifProfile property to null during OnBeforeSaveAsync

    services.AddImageSharp(
        options => options.OnBeforeSaveAsync = f =>
        {
            f.Image.Metadata.ExifProfile = null;
            return Task.CompletedTask;
        });