GroupDocs.Redactions provides a set of features to redact data of sensitive nature from images of various formats like JPG, PNG, TIFF and others. See full list at supported document formats article.
GroupDocs.Redaction supports two ways of redacting images, both in separate image files and embedded images:
You can put a colored box over a given area, such as header, footer, or an area, where customer’s data are expected to appear.
You can use any 3-rd party OCR engine to process the image, search it for text and redact sensitive data within the image.
GroupDocs.Redaction for Python via .NET also allows you to change image metadata (e.g. edit EXIF data of an image or act as an “EXIF eraser”).
Redact image area
In order to redact image area, you have to use ImageAreaRedaction class:
Python
importgroupdocs.redactionasgrimportgroupdocs.redaction.optionsasgroimportgroupdocs.redaction.redactionsasgrrimportgroupdocs.pydrawingasgrddefrun():# Define the position on imagesample_point=grd.Point(385,485)# Define the size of the area which need to be redactedsample_size=grd.Size(1793,2069)# Define color of redactioncolor=grd.Color.from_argb(255,220,20,60)# Specify the redaction optionsrepl_opt=grr.RegionReplacementOptions(color,sample_size)img_red=grr.ImageAreaRedaction(sample_point,repl_opt)# Load the document to be redactedwithgr.Redactor("source.jpg")asredactor:# Apply the redactionresult=redactor.apply(img_red)if(result.status!=gr.RedactionStatus.FAILED):# By default, the redacted document is saved in PDF formatresult_path=redactor.save()
The following example demonstrates how to edit exif data (erase them) from a photo or any other image:
Python
importgroupdocs.redactionasgrimportgroupdocs.redaction.optionsasgroimportgroupdocs.redaction.redactionsasgrrdefrun():print("\n[Example Basic Usage] # clean_image_metadada.py : Clean all image metadata")# Specify the redaction options to remove all metadataer_opt=grr.EraseMetadataRedaction(grr.MetadataFilters.ALL)# Load the document to be redactedwithgr.Redactor("source.jpg")asredactor:# Apply the redactionresult=redactor.apply(er_opt)# Save the redacted documentso=gro.SaveOptions()so.add_suffix=Trueso.rasterize_to_pdf=Falseresult_path=redactor.save(so)
You can redact image area within all kinds of embedded images inside a document.
The following example demonstrates how to redact all embedded images within a Microsoft Word document:
Python
importgroupdocs.redactionasgrimportgroupdocs.redaction.optionsasgroimportgroupdocs.redaction.redactionsasgrrimportgroupdocs.pydrawingasgrddefrun():# Define the position on imagesample_point=grd.Point(516,311)# Define the size of the area which need to be redactedsample_size=grd.Size(170,35)# Define color of redactioncolor=grd.Color.from_argb(255,220,20,60)# Specify the redaction optionsrepl_opt=grr.RegionReplacementOptions(color,sample_size)img_red=grr.ImageAreaRedaction(sample_point,repl_opt)# Load the document to be redactedwithgr.Redactor("source.docx")asredactor:# Apply the redactionresult=redactor.apply(img_red)if(result.status!=gr.RedactionStatus.FAILED):# By default, the redacted document is saved in PDF formatresult_path=redactor.save()
Along with full featured .NET library we provide simple, but powerful free Apps.
You are welcome to perform redactions for various document formats like PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX, Emails and more with our free online Free Online Document Redaction App.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.