coobird / thumbnailator

Thumbnailator - a thumbnail generation library for Java
MIT License
5.08k stars 780 forks source link

How to add a watermark in text? #180

Closed wraptor closed 2 years ago

wraptor commented 2 years ago

Expected behavior

how can i make watermark , base on word,not image,like this i input string "example.com/xxxx", and generate watermark in image image

Environment

coobird commented 2 years ago

The Caption filter can be used to add text on an image. They can be added by using the addFilter method.

Here's an example:

Font font = ...
Color color = ...
Thumbnails.of("/path/to/image")
    .size(100, 100)
    .addFilter(new Caption("my text", font, color, 0.5f, Positions.BOTTOM_RIGHT, 5))
    .toFile("/path/to/thumbnail");
wraptor commented 2 years ago

thanks.