GroupDocs.Redactions prodives 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 fr Java since version 21.6 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 Java 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:
Java
finalRedactorredactor=newRedactor("D:\\test.jpg");try{//Define the position on image
java.awt.PointsamplePoint=newjava.awt.Point(385,485);//Define the size of the area which need to be redacted
java.awt.DimensionsampleSize=newjava.awt.Dimension(1793,2069);//Perform redaction
RedactorChangeLogresult=redactor.apply(newImageAreaRedaction(samplePoint,newRegionReplacementOptions(java.awt.Color.BLUE,sampleSize)));if(result.getStatus()!=RedactionStatus.Failed){//The redacted output will save as PDF
redactor.save();};}finally{redactor.close();}
To enable OCR-processing and search for a text using regular expressions, you have to implement IOcrConnector interface and pass the instance to RedactorSettings constructor. For more details, see OCR Usage Basics article.
In the example above MyCustomOcrConnector class implements IOcrConnector interface.
Clean image metadata
GroupDocs.Redaction for Java allows you to change image metadata (e.g. edit EXIF data of an image or act as an “EXIF eraser”).
The following example demonstrates how to edit exif data (erase them) from a photo or any other image:
finalRedactorredactor=newRedactor("D:\\photo.jpg");try{RedactorChangeLogresult=redactor.apply(newEraseMetadataRedaction(MetadataFilters.All));if(result.getStatus()!=RedactionStatus.Failed){//The redacted output will save as PDF
redactor.save();};}finally{redactor.close();}
If the redaction cannot be applied to this type of files, e.g. BMP image, RedactorChangeLog.getStatus() will be RedactionStatus.Skipped.
Redact embedded images
You can redact image area within all kinds of embedded images inside a document. You can both use ImageAreaRedaction class and any type of TextRedaction (regular expression, exact phrase), if the OCR is enabled in RedactorSettings (see OCR Usage Basics article).
The following example demonstrates how to redact all embedded images within a Microsoft Word document: