Remove Watermark Image Filter

Remove watermark

         You can utilize the `Remove Watermark` image filter using the Aspos.Imaging graphic library for Java to eliminate unwanted marks from your images and photos. This library features the WatermarkRemover Java class, which includes the `paintOver` method for manipulating watermarks.

         In the example below, we start by loading a PNG image with a watermark. We proceed to create a graphic path object that defines the location and shape of the watermark. In our case, the watermark is enclosed within an elliptical shape, and the coordinates for this ellipse need to be defined before image processing. To remove the watermark, we pass the loaded image to the `paintOver` method, along with an object containing WatermarkOptions. In this case, we utilize the `Content-Aware Fill` algorithm option with the ellipse shape path as a mask parameter. Additionally, we set the maximum painting attempts to 4. This implies that the algorithm will generate 4 images and select the best result.

Java code example:

package com.aspose.imaging.examples.ModifyingImages;
import com.aspose.imaging.*;
import com.aspose.imaging.examples.Logger;
import com.aspose.imaging.examples.Utils;
import com.aspose.imaging.fileformats.png.PngImage;
import com.aspose.imaging.shapes.EllipseShape;
import com.aspose.imaging.watermark.WatermarkRemover;
import com.aspose.imaging.watermark.options.ContentAwareFillWatermarkOptions;
public class RemoveWatermarkFilter
{
public static void main(String[] args)
{
Logger.startExample();
String baseFolder = Utils.getSharedDataDir() + "Png";
String imageFilePath = baseFolder + "/ball.png";
String outputFilePath = Utils.getOutDir() + "/result.png";
try (Image image = Image.load(imageFilePath))
{
PngImage pngImage = (PngImage)image;
GraphicsPath mask = new GraphicsPath();
Figure firstFigure = new Figure();
firstFigure.addShape(new EllipseShape(new RectangleF(350, 170, 570 - 350, 400 - 170)));
mask.addFigure(firstFigure);
ContentAwareFillWatermarkOptions options = new ContentAwareFillWatermarkOptions(mask);
options.setMaxPaintingAttempts(4);
RasterImage result = WatermarkRemover.paintOver(pngImage, options);
result.save(outputFilePath);
}
Logger.endExample();
}
}