Link
Skip to main content

Adding Watermark to an image

What does it do?

The Watermark operation will add a provided watermark to an image, the watermark be text, a shape or an image. It takes several parameters depending on the watermark you would like to add. All watermarks must specify the watermark position enum as input which you can select from FitToImage, Center and USE_SHAPE_COORDINATES.

Add a text watermark to a BufferedImage in Java

ImageProcessingOperations operations = new ImageProcessingOperations();

// You can chain several operations here such as scale, blur, etc
operations.watermark("Watermark Text", Color.BLUE, new Font("Arial", Font.BOLD, 30), FitToImage); 
        
// Apply the operations to a BufferedImage
BufferedImage modifiedImage = operations.apply(BufferedImage originalImage);

View Javadoc for the watermark operation

Additional Code Examples

Process and convert between image formats using the following code examples:

Using File

File inputFile = new File("path/to/file");
File outputFile = new File("path/to/output-Watermarked-file");
JDeli.convert(inputFile, outputFile, operations);

Using InputStream and OutputSteam

final InputStream inputStream = new FileInputStream(inputFile);
final OutputStream outputStream = new FileOutputStream(outputFile);
final String outputFormat = "format"; // format of the output file eg. png, jpeg,...;
JDeli.convert(inputStream, outputStream, outputFormat, operations);

Using byte[]

byte[] inputData = Files.readAllBytes(Paths.get("/path/to/file"));
final String outputFormat = "format"; // format of the output file eg. png, jpeg,...;
byte[] outputData = JDeli.convert(inputData, outputFormat, operations);

Get started with JDeli in 3 steps

  1. Fill in the form to download the trial jar →
  2. Copy the code snippets as instructed on the next page
  3. Build your solution using our docs

Learn more about JDeli

Start Your Free Trial