coobird / thumbnailator

Thumbnailator - a thumbnail generation library for Java
MIT License
5.16k stars 786 forks source link

Rotate Caption / Watermark #178

Closed rider87 closed 1 year ago

rider87 commented 3 years ago

Hi,

I want to rotate the text of my Watermark... How is this possible?

Thanks

coobird commented 3 years ago

You could pre-rotate an image and use it as a watermark.

// Pre-rotate image used as watermark.
BufferedImage watermark = Thumbnails.of("/path/to/watermark")
    .size(100, 100)
    .rotate(90)
    .asBufferedImage();

// Use the pre-rotated watermark to make thumbnail
Thumbnails.of("/path/to/image")
    .size(400, 400)
    .watermark(Positions.BOTTOM_RIGHT, watermark, 0.5f);
    .toFile("/path/to/thumbnail")

Generally, watermarks are static, so any kind of processing necessary on the watermark can be performed ahead of time. The watermark methods reflect that common use case.

coobird commented 1 year ago

Question answered. Closing for no follow-up activity.