Gif4J PRO for Java - Watermark GIF Images
Gif4J gif animation software logotype
Home Page for Gif4J Software java gif image processing products, solutions and services Products Page for java GIF image processing software Purchase java GIF image managing products Download Gif4J GIF image processing products Java imaging FAQs and Gif4J solutions support Contact Page Customer Area
Gif4J PRO java gif imaging class library logo

Construct a Watermark

The Watermark java class is used to prepare and apply (paint with the specified transparency) images as watermarks to the whole gif images, separate gif image frames and BufferedImage(-s). Absolute and relative (layout constraint based) positioning are supported.

The Watermark class constructors can be divided into 2 types according to the desired position type (absolute or relative): "absolute positioning" costructors contain Point parameter and "relative positioning" constructors contain layout constraint parameter.
Also you can specify watermark's transparency parameter which is represented by float value between 0 (absolutely transparent) and 1 (absolutely opaque). Default is 0.5f.

Below examples demostrate positioning and transparency opportunities (see examples/Watermarks and examples/ImageTour1):


(size: 150x150, 5 frames - each with different relative position and the last with "cover consecutively" watermark)




Note: If you load GIF images for displaying purposes (for example to display as image icons within a swing application) then you should use the standard Java API: java.awt.Toolkit#getImage, java.awt.Toolkit#createImage or javax.swing.ImageIcon.

Apply a Watermark to a BufferedImage

Below example demostrates creating and adding a text watermark to a BufferedImage:

Gif4J PRO Java Example: Add text watermark to a BufferedImage


import com.gif4j.Watermark;
import com.gif4j.TextPainter;

import java.awt.image.BufferedImage;
import java.awt.*;

   public BufferedImage addTextWatermarkToImage(BufferedImage image, String text) {
       //create new TextPainter
       TextPainter textPainter = new TextPainter(new Font("Verdana", Font.BOLD, 10));
       textPainter.setOutlinePaint(Color.WHITE);
       //render the specified text outlined
       BufferedImage renderedWatermarkText = textPainter.renderString(text,true);
       //create new Watermark
       Watermark watermark =
               new Watermark(renderedWatermarkText, Watermark.LAYOUT_BOTTOM_RIGHT);
       //apply watermark to the specified image and return the result
       return watermark.apply(image);
   }

Apply a Watermark to a GIF image

Below example demostrates creating and adding a text watermark to a GifImage:

Gif4J PRO Java Example: Add text watermark to a GifImage


import com.gif4j.Watermark;
import com.gif4j.TextPainter;
import com.gif4j.GifImage;

import java.awt.image.BufferedImage;
import java.awt.*;

    public GifImage addTextWatermarkToGifImage(GifImage gifImage, String text) {
        //create new TextPainter
        TextPainter textPainter = new TextPainter(new Font("Verdana", Font.BOLD, 10));
        textPainter.setOutlinePaint(Color.WHITE);
        //render the specified text outlined
        BufferedImage renderedWatermarkText = textPainter.renderString(text, true);
        //create new Watermark
        Watermark watermark =
                new Watermark(renderedWatermarkText, Watermark.LAYOUT_BOTTOM_RIGHT);
        //apply watermark to the specified gif image and return the result
        return watermark.apply(gifImage, true);
    }

Watermarked GIF Images (the test image is out logo)
watermarked left-top gif image using Java watermarked top-center gif image using Java
[LAYOUT_TOP_LEFT, 0.7f transparency] [LAYOUT_TOP_CENTER, 0.7f transparency]
watermarked right-top gif image using Java watermarked middle-left gif image using Java
[LAYOUT_TOP_RIGHT, 0.7f transparency] [LAYOUT_MIDDLE_LEFT, 0.7f transparency]
watermarked middle-center gif image using Java watermarked middle-right gif image using Java
[LAYOUT_MIDDLE_CENTER, 0.7f transparency] [LAYOUT_MIDDLE_RIGHT, 0.7f transparency]
watermarked botom-left gif image using Java watermarked bottom-center gif image using Java
[LAYOUT_BOTTOM_LEFT, 0.7f transparency] [LAYOUT_BOTTOM_CENTER, 0.7f transparency]
watermarked right-bottom gif image using Java watermarked consecutively gif image using Java
[LAYOUT_BOTTOM_RIGHT, 0.7f transparency] [LAYOUT_COVER_CONSECUTIVELY, 0.3f transparency]

Apply a Watermark to a separate GIF Image Frame

To apply watermark(s) to the specified frame you should add this frame to a gif image using the next methods:

    public GifImage addGifFrame(GifFrame frame, Watermark watermark
    public GifImage addGifFrame(GifFrame frame, MorphingFilter filter, Watermark watermark


(size: 160x120, animated gif image tour with separately watermarked frames)

Gif4J java gif imaging lib (professional)
Gif4J PRO
Overview
 
Gif4J Java Color Quantizer
Overview
Quality Measurements & Benchmark Testing
Test Online
 
Gif4J PRO Tutorial
Loading GIF Images
Creating GIF Images
Creating GIF Frames
Transform GIF Images
Saving GIF Images
Watermarking
Morphing Filters
Text Rendering
 
Gif4J java gif imaging lib (light)
Gif4J LIGHT
Overview
 
Gif4J LIGHT Tutorial
Creating GIF Images
Creating GIF Frames
Saving GIF Images
 
Home |  Privacy Policy |  Legal Information 
© Gif4J Software 2004-2017