This example shows how to make advanced search for Image signature in the document and further image signatures analyzes with saving image content
using(Signaturesignature=newSignature("sampleSignaed.docx")){// setup search optionsImageSearchOptionssearchOptions=newImageSearchOptions(){// enable grabbing image content featureReturnContent=true,// set minimum size if neededMinContentSize=0,// set maximum size if neededMaxContentSize=0,// specify exact image type to be returnedReturnContentType=FileType.JPEG,};// search documentList<ImageSignature>signatures=signature.Search<ImageSignature>(searchOptions);Console.WriteLine($"\nSource document ['{fileName}'] contains following image signature(s).");// output signaturesforeach(ImageSignatureimageSignatureinsignatures){Console.Write($"Found Image signature at page {imageSignature.PageNumber} and size {imageSignature.Size}.");Console.WriteLine($"Location at {imageSignature.Left}-{imageSignature.Top}. Size is {imageSignature.Width}x{imageSignature.Height}.");}//Save signature imagesstringoutputPath=System.IO.Path.Combine(Constants.OutputPath,"SearchForImageAdvanced");if(!Directory.Exists(outputPath)){Directory.CreateDirectory(outputPath);}inti=0;foreach(ImageSignatureimageSignatureinsignatures){Console.Write($"Found Image signature at page {imageSignature.PageNumber} and size {imageSignature.Size}.");Console.WriteLine($"Location at {imageSignature.Left}-{imageSignature.Top}. Size is {imageSignature.Width}x{imageSignature.Height}.");stringoutputFilePath=System.IO.Path.Combine(outputPath,$"image{i}{imageSignature.Format.Extension}");using(FileStreamfs=newFileStream(outputFilePath,FileMode.Create)){fs.Write(imageSignature.Content,0,imageSignature.Content.Length);}i++;}}
More resources
GitHub Examples
You may easily run the code above and see the feature in action in ourΒ GitHub examples: