We're sorry GroupDocs doesn't work properply without JavaScript enabled.

Free Support Forum - groupdocs.com

How to remove metadata from an image file C#

I need to remove metadata from an image file which I am reading as a FileStream

var loadOption = new LoadOptions(GroupDocs.Metadata.Common.FileFormat.Jpeg);
using (var metadata = new Metadata(fileStream, loadOption))
{
   var affected = metadata.Sanitize();
   metadata.Save(outStream);
}

Error: ‘metadata.Sanitize()’ threw an exception of type 'System.NotSupportedException’
The metadata from the image i used can be deleted by this link so the image is a valid image, but i can’t remove the metadata using the above code.

1 Like

@Sriram14

We successfully reproduced this issue by loading an image as a Stream. Therefore, we’ve logged it in our internal issue tracking system with ID METADATANET-3939. It’ll be now further investigated. You’ll be notified in case of any update.

thanks for the reply

1 Like

@Sriram14

You are welcome.

Hi @Atir_Tahir,
When can we expect this issue to be fixed.

@Sriram14

Please note that all free support issues are assisted on first come first serve basis. Your issue is still under investigation. However, we’ll notify you as there’s any progress on it.

1 Like

@Sriram14

Please try the following code and if issue persists, share the problematic file with us.

using GroupDocs.Metadata;
using GroupDocs.Metadata.Options;
using System.IO;

namespace metadata_tester
{
    class Program
    {
        static void Main(string[] args)
        {
			License lic = new License();
			lic.SetLicense(@"D:/License.lic"); 
            Stream fileStream = File.Open(@"D:/sample.jpg", FileMode.Open, FileAccess.ReadWrite);
            var loadOption = new LoadOptions(GroupDocs.Metadata.Common.FileFormat.Jpeg);
            using (var metadata = new Metadata(fileStream, loadOption))
            {
                var affected = metadata.Sanitize();
                 //save output/result to stream or file
                //metadata.Save(outStream);
            }
        }
    }
}

If your source file is a PNG, please set FileFormat to Png as follows:

var loadOption = new LoadOptions(GroupDocs.Metadata.Common.FileFormat.Png);

Where can i get the License file or How to generate it ?

1 Like

@Sriram14

You can avail a temporary license.

Steps to Download the License

  • Go to the purchase wizard
  • Sign in to your account
  • Select product website (e.g. groupdocs.com)
  • Select product family (e.g. GroupDocs.Metadata)
  • Go for an individual product (e.g. GroupDocs.Metadata for .NET)
  • Select license type (e.g. Developer small business)
  • Add to the cart and the proceed to the cart
  • At checkout time, press on Get temporary license

Once you have it, follow this documentation article or the code below to apply the license:

// initialize License
License lic = new License();
// apply license
lic.SetLicense("GroupDocs.Metadata.lic");