Hi,
We are using GroupDocs.Metadata 21.8.0. and the .Net version is 4.7.2. We tried removing EXIF data using this approach but the resultant image still contains the EXIF data. Can you tell us if it is a known issue or any additional thing we need to implement?
this is the code we have added.
string file_extension = Path.GetExtension(file.Key);
MemoryStream output = new MemoryStream(file.Value.StreamToByteArray());
if (file_extension != ".jpg" && file_extension != ".jpeg")
{
return output;
}
try
{
using (Metadata metadata = new Metadata(file.Value))
{
IExif root = metadata.GetRootPackage() as IExif;
if (root != null)
{
root.ExifPackage = null;
output.Flush(); // tried both with/without this
output.SetLength(0); // tried both with/without this
metadata.Save(output);
}
}
return output;
}
@shrey
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): METADATANET-4016
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
Please use two different streams, input and output. Below is a code example:
// Open an input stream for reading from the input file.
FileStream inputStream = new FileStream(inputPath, FileMode.Open);
// Check the file extension; if it's not a JPEG, exit the process.
if (file_extension != ".jpg" && file_extension != ".jpeg")
{
return;
}
// Create or open an output stream for writing to the output file.
FileStream outputStream = new FileStream(outputPath, FileMode.OpenOrCreate);
// Create a Metadata object to work with the input stream's metadata.
using (Metadata metadata = new Metadata(inputStream))
{
// Get the root package of metadata as an Exif package.
IExif exifPackage = metadata.GetRootPackage() as IExif;
// If the Exif package is found, remove it from the metadata.
if (exifPackage != null)
{
exifPackage.ExifPackage = null;
// Save the modified metadata to the output stream.
metadata.Save(outputStream);
}
}
Hi @atir.tahir,
I don’t think it is an output stream issue. It was different only in the first example. Still, I tried to simplify the example and tried to directly save the file but the metadata doesn’t get removed. attaching the image of the resultant metadata.
The attached file does not have EXIF content. For other files the code that we provided earlier works correctly. The content is deleted.
Please try again using this code example.zip (608 Bytes) and this input.jpg (876.2 KB) file.
Hi,
looks like this editor itself removes the EXIF. since the same file present in my system has the metadata. also, the file suggested by you also doesn’t have any metadata. image.png (27.7 KB)
The file you shared has an EXIF section, we tested it using the code example provided earlier, the section is deleted correctly.
Could you please share a short video explaining steps to reproduce the issue?