GroupDocs.Redaction provides features to redact sensitive data from images (JPG, PNG, TIFF, BMP, GIF, and others). See the full list in Supported document formats.
You can redact images both as separate files and as embedded images inside documents:
Put a colored box over a given area (header, footer, or a region where customer data appears).
Use a third-party OCR engine to search text on the image and redact matches.
You can also change image metadata (for example edit EXIF or act as an “EXIF eraser”) where the format exposes metadata.
For multi-page or layout-aware scenarios, combine image-area redaction with page filters (PageRangeFilter, PageAreaFilter). Coordinates follow the page (or visible image) placement when the bitmap size differs from the on-page shape.
Redact image area
In order to redact image area, you have to use ImageAreaRedaction class:
Node.js
constredaction=require('@groupdocs/groupdocs.redaction');constjava=require('java');constColor=java.import('java.awt.Color');constDimension=java.import('java.awt.Dimension');constPoint=java.import('java.awt.Point');constredactor=newredaction.Redactor('D:\\test.jpg');try{//Define the position on image
constsamplePoint=newPoint(385,485);//Define the size of the area which need to be redacted
constsampleSize=newDimension(1793,2069);//Perform redaction
constresult=redactor.apply(newredaction.ImageAreaRedaction(samplePoint,newredaction.RegionReplacementOptions(Color.BLUE,sampleSize)));if(result.getStatus()!==redaction.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 Node.js via 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:
constredaction=require('@groupdocs/groupdocs.redaction');constredactor=newredaction.Redactor('D:\\photo.jpg');try{constresult=redactor.apply(newredaction.EraseMetadataRedaction(redaction.MetadataFilters.All));if(result.getStatus()!==redaction.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: