I have a working application to change some of the metadata of my scanned images. This was working good, until we added a pre-process to automatically crop the borders of the images with GIMP console.
We change multiple fields in the EXIF data, and this still works correct. But if I want to change any IPTC field, I get the error "Property is corrupted."
For the non cropped images, I can change EXIF and IPTC without any problem. For the cropped images, I can change EXIF without any problem. If I change anything in IPTC info, I get an exception.
Am I doing something wrong? Or is there maybe an other solution on how to change the EXIF/IPTC data of the images?
As found in other posts, I extract the BitmapMetadata from the image. And I clone it, to be editable. After that I add padding to be able to add extra information.
As far as I can see, there looks nothing wrong with the metadata. And in other tools like IrfanView or EXIFTool, I can change the IPTC Headline correct.
I have created a test project where the issue is shown. Included with an example image before and after crop.
If isJpg Then
oMetaData.SetQuery("/app13/{ushort=0}/{ulonglong=61857348781060}/iptc/{str=Headline}", "TEST_HEADLINE")
Else
oMetaData.SetQuery("/ifd/{ushort=33723}/{str=Headline}", "TEST_HEADLINE")
End If
System.ArgumentException: Property is corrupted. ---> System.Runtime.InteropServices.COMException: The bitmap property size is invalid. (Exception from HRESULT: 0x88982F42)
Example project
How to edit image file metadata. To edit the metadata on image files, do the following: Right-click the file and select Properties. In the image properties, click on the Details tab.
How to View Metadata in Photoshop. 1 Open the image for which you want to check the metadata. 2 Head to the File menu, then click File info. You can also press Ctrl + Alt + Shift + I on Windows and Command + Option + Shift + I on Mac. 3 From here, you can copy or edit the metadata. 4 Click OK to save your changes.
Fortunately, images are one of the easiest file types to change metadata in, because they are accessible for editing without any outside software systems. To edit the metadata of a digital photo, follow this sequence:
To remove your personal metadata information, do the following: On the Details tab of the picture, click the Remove Properties and Personal Information link. Select Create a copy with all possible properties removed or you can also select Remove the following properties from this file, and select the properties you want to remove.
Meta data is a hierarchy, so you cannot write everything using only paths, you'll have to use intermediate BitmapMetadata
objects.
The official documentation for all this is located here: Native Image Format Metadata Queries which is part of WIC or Windows Imaging Component documentation, the underlying Windows imaging technology that WPF uses.
The doc says this for TIFFs:
/ifd/iptc or /ifd/{ushort=33723} / IPTC / VT_UNKNOWN - A query reader/writer
The obscure VT_UNKNOWN (for "Variant Type IUnknown") in fact means iptc
is an object that can read and write meta data (aka: a BitmapMetadata
in WPF parlance), the start of a meta data sub tree.
So what you must do is something like this:
Dim iptc As BitmapMetadata = New BitmapMetadata("iptc")
iptc.SetQuery("/{str=Headline}", "TEST_HEADLINE")
oMetaData.SetQuery("/ifd/iptc", iptc)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With