Metadata signature for Image document is an electronic signature based on image metadata standard. Most image formats support metadata specification or EXIF. Image metadata is dictionary map with unique whole short identifier in range 0-65535, Some identifiers are reserved by EXIF specification. From signature perspective image metadata may content any hidden value of standard (int,char, string) or custom type (user defined class), be encrypted and decrypted back by known key over Search method.
GroupDocs.Signature provides ImageMetadataSignature class to specify Metadata e-signature for image documents. Image document metadata contains pair with unique identifier Id and its Value. Image document metadata could keep big amount of data that provides ability to keep serialized custom objects with additional encryption in there.
Here are the steps to add metadata signatures into Image with GroupDocs.Signature:
Create new instance of Signature class and pass source document path as a constructor parameter.
This example shows how to sign png image with metadata e-signatures
fromdatetimeimportdatetimefromgroupdocs.signatureimportSignaturefromgroupdocs.signature.optionsimportMetadataSignOptionsfromgroupdocs.signature.domainimportImageMetadataSignaturedefsign_png():withSignature("sample.png")assignature:options=MetadataSignOptions()# Image metadata entries are identified by a number, not a namemetadata_id=41996# Add several Image Metadata signatures with values of different typesoptions.add(ImageMetadataSignature(metadata_id,"Mr.Scherlock Holmes"))# textoptions.add(ImageMetadataSignature(metadata_id+1,datetime.now()))# date and timeoptions.add(ImageMetadataSignature(metadata_id+2,123456))# whole numberoptions.add(ImageMetadataSignature(metadata_id+3,123.456))# floating-point number# Sign the image and save the resultresult=signature.sign("signed.png",options)print(f"Signed with {len(result.succeeded)} metadata signature(s):")foriteminresult.succeeded:print(f" {item.id}")if__name__=="__main__":sign_png()
sample.png is the sample file used in this example. Click here to download it.