Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Imagemagick: how to add border with text just below the image?

I need to add borders around photos and below the photo I want to append text. However, so far I can either add borders or add text, but they don't work togeter.

original photo

What I mean is, for appending text:

convert photo.jpg -background White label:"A nice memory" -background White -gravity east -append result.jpg

This adds a white strip with text at the bottom right of the image:

Photo with text

and for adding border:

convert photo.jpg -bordercolor Green -border 5%x10% result.jpg

enter image description here

It adds a nice green border around the photo. However, if I want them together:

convert photo.jpg -bordercolor Green -border 5%x10% -background White label:"A nice memory" -background White -gravity east -append result.jpg

enter image description here

it first adds a border, then an extra strip of space below the lower border with text. I guess I have to explicitly tell it to have border and text together. Is this possible?

Expected:

Expected result

(Important: I want the text to be right aligned with the photo as if there's no border)

Thanks!

like image 407
hzxu Avatar asked Sep 18 '25 09:09

hzxu


1 Answers

convert input.jpg -bordercolor Green -border 5%x10% -gravity southeast -annotate +0+0 "Some text" result.jpg
like image 81
Bonzo Avatar answered Sep 21 '25 09:09

Bonzo