How to Set Watermark in TIFF using Java

This short tutorial provides guidance on how to set watermark in TIFF using Java. You can watermark TIFF image in Java by setting the watermark string, font, brush, string format, and position of the watermark on the TIFF image. The output TIFF image can be saved to disc or OutputStream as per the requirement.

Steps to Set Watermark in TIFF using Java

  1. Configure the project by adding the Aspose.Imaging library from the Maven Repository to watermark the TIFF
  2. Load the sample TIFF image into the Image class object
  3. Initialize a Graphics object with the sample TIFF image
  4. Instantiate a Font class object for the watermark string
  5. Instantiate a brush and set the color and opacity of the watermark string
  6. Set the properties of the watermark text using a StringFormat object
  7. Render the string using graphics object on the TIFF with above font, brush, and string format
  8. Save the TIFF image having a watermark on it

In this step-by-step process to secure TIFF image by adding watermark in Java, we load the sample TIFF image into an Image class object and then instantiate a Graphics object using this image. We also set the font, brush color and opacity, and string format of the watermark string. This string is rendered at the specified position on the image using the Graphics object.

Code to Watermark TIFF in Java

In the above code, the Image class object is used for loading the sample TIFF image however, you can load any other type of image as well and save it with the same image type after adding a watermark. The drawString() function of the Graphics class is used to render the formatted string with particular font and brush at user-defined coordinates on the sample TIFF image.

Other than this option to add watermark in TIFF using Java you can also perform different types of conversions like described in the article on how to convert Bitmap to PNG in Java. Note that for setting a watermark on an image, there is no need for any other third-party tool or software.

 English