Labeling images with Imagemagick
I sometimes need to place simple text on images. In one example, I created several versions of the same image with each having a different size. Then I use a HTML <picture> construct to serve up the "correct" image for a given screen size. here's an example:
<picture> <source srcset="wullenweber-800.webp" media="(min-width: 800px)" type="image/webp"> <source srcset="wullenweber-600.webp" media="(min-width: 600px)" type="image/webp"> <source srcset="wullenweber-400.webp" media="(min-width: 400px)" type="image/webp"> <source srcset="wullenweber-200.webp" media="(min-width: 200px)" type="image/webp"> <img src="wullenweber-200.webp" alt="Wullenweber Antenna"> </picture>
I wanted to label the images with their horizontal size in the lower lefthand corner. Here's the Imagemagick command to place 12 point white text in the lower-lefthand corner of the image:
convert -gravity southwest -pointsize 12 -fill white -draw 'text 0,0 "800"' image.webp image.webp