Add Watermark to Images using Java

Add watermark to images in Java

Watermark is a convenient way of protecting the content and claiming the copyrights. By applying a watermark to digital documents or images, you can avoid unauthorized usage or theft. In accordance with that, this article covers how to automate watermarking feature for images within Java applications. Particularly, you will learn how to add watermark to images using Java. This can be useful especially when you need to add a watermark to a batch of images.

Java API to Add Watermark to Images

In order to add a watermark to images, we’ll use Aspose.Imaging for Java. It is an image processing API that lets you manipulate a wide range of image formats from within your Java applications. You can either download the API’s JAR or install it within your Maven-based applications using the following configurations.

<repository>
    <id>AsposeJavaAPI</id>
    <name>Aspose Java API</name>
    <url>https://repository.aspose.com/repo/</url>
</repository>
<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-imaging</artifactId>
    <version>20.12</version>
    <classifier>jdk16</classifier>
</dependency>

Add Watermark to Images using Java

The following are the steps to add a watermark to the images using Aspose.Imaging.

The following code sample shows how to add watermark to an image using Java.

Add Diagonal Watermark to images in Java

In certain cases, the watermark is applied to the images diagonally. For such cases, Aspose.Imaging for Java provides watermark transformation options using which you can rotate the watermark. The following are the steps to add a diagonal watermark to an image.

The following code sample shows how to add a diagonal watermark to image using Java.

Get a Free API License

You can get a free temporary license in order to try the API without evaluation limitations.

Conclusion

Watermark is used to protect digital documents and images from unauthorized or illegal usage. In order to protect digital images, this article covered how to add a watermark to images using Java. Furthermore, you have seen how to apply the transformation to the watermarks. You can explore more about the Java image processing API using the documentation.

See Also