Skip to content

Instantly share code, notes, and snippets.

@farhan-raza
Created October 3, 2024 08:50
Show Gist options
  • Save farhan-raza/5756474ba6543d9ebce201ddf0b39c9f to your computer and use it in GitHub Desktop.
Save farhan-raza/5756474ba6543d9ebce201ddf0b39c9f to your computer and use it in GitHub Desktop.
Redact Images in Java | Redact JPG PNG BMP GIF TIFF Photos
final com.groupdocs.redaction.Redactor redactor = new com.groupdocs.redaction.Redactor(dataDir + "compare-annotations-pdf-java.jpg");
try
{
//Define the position on image
java.awt.Point samplePoint = new java.awt.Point(385, 485);
//Define the size of the area which need to be redacted
java.awt.Dimension sampleSize = new java.awt.Dimension(1793, 2069);
//Perform redaction
com.groupdocs.redaction.RedactorChangeLog result = redactor.apply(new com.groupdocs.redaction.redactions.ImageAreaRedaction(samplePoint,
new com.groupdocs.redaction.redactions.RegionReplacementOptions(java.awt.Color.BLUE, sampleSize)));
if (result.getStatus() != com.groupdocs.redaction.RedactionStatus.Failed)
{
//The redacted output will save as PDF
redactor.save();
};
}
finally { redactor.close(); }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment