TIF - Bit Depth will be affected when removing metadata in .NET

We verified 18.6 has fixed the original problem we have reported. But we found that for the TIF file, the remove info feature cleared the “camera serial number” field, which I assume would affect the ‘Size’ field being reduced from “896” to “893”.

Please have a check. Thanks.

@Glority_Developer,

It is the expected behavior as the metadata attached to a file also contributes to the file’s size and removing metadata from the file reduces its size. In case of removing XMP metadata from a tiff image using TiffFormat.RemoveXmpData, GroupDocs.Metadata removes all XMP data and hence the size of the resultant file is reduced.

Hi,

Do you know what is TiffExifInfo.BodySerialNumber? We thought it was Camera Serial Number.

But using Aspose v19.3, we can’t remove Camera Serial Number for TIF files.

We don’t want to use “tiffFormat.RemoveXmpData()” function, since we may want to only remove Camera Serial Number and don’t want to affect other properties. Do you have any suggestion?

@Glority_Developer,

The BodySerialNumber and CameraSerialNumber are different properties. The BodySerialNumber is an ExifIfdInfo property whereas CameraSerialNumber is a property of Microsoft Photo Schema (XMP properties used by Microsoft).

You can easily remove MicrosoftPhoto:CameraSerialNumber by accessing the MicrosoftPhoto XMP Package, as shown in the following code snippet:

using (TiffFormat tiff = new TiffFormat("D:\\MetadataStorage\\Flowerboy_orginal.tif"))
{
        // get xmp wrapper
        XmpPacketWrapper xmpPacket = tiff.GetXmpData();

        // create xmp wrapper if not exists
        if (xmpPacket == null)
        {
                xmpPacket = new XmpPacketWrapper();
        }

        // check if MicrosoftPhoto schema exists using namespace URI
        if (xmpPacket.ContainsPackage("http://ns.microsoft.com/photo/1.0/"))
        {
               // get MicrosoftPhoto package using namespace URI
               var package = xmpPacket.GetPackage("http://ns.microsoft.com/photo/1.0/");

               // remove value
               package.Remove("MicrosoftPhoto:CameraSerialNumber");
        
               // update value
               //package.AddValue("MicrosoftPhoto:CameraSerialNumber", "New SN");        

               // update XMP package
               tiff.SetXmpData(xmpPacket);
               tiff.Save("D:/MetadataStorage/Flowerboy_orginal_output.tif");
        }
}