Image overlay + labels with wordwrap

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Fauxs82
Posts: 1
Joined: 2018-07-04T08:09:10-07:00
Authentication code: 1152

Image overlay + labels with wordwrap

Post by Fauxs82 » 2018-07-04T08:47:09-07:00

Hi All,

Am new to the IM world and trying to figure out how to achieve something specific. I've checked forums/guides and managed to get this far but now have hit a wall.

I am using the below big command to generate an image with coloured background, scaled logo overlay in lower left corner with text at right side with different fonts/colours. So far I have what I need with one exception. I would like to keep the positioning but set one of the fields to wrap text so to avoid it disappearing out of picture boundaries.
Specifically line:

Code: Select all

 \( -font CircularPro-Bold.ttf -fill "#15BDF8" -gravity NorthEast -pointsize 30 -annotate +450+600 'A very long title for testing purposes, hopefully this will fit on the screen!' \) \
I understand that using the caption option is better for word wrapping, despite trying for several days however I am unable to figure it out. Wondering if someone could point me in the correct direction?

Code: Select all

convert -size 1920x1080 xc:#CBF0FE \
 \( logo.png -resize 50% \) -gravity SouthWest -geometry +100+100 -composite \
 \( -font CircularPro-Book.ttf -fill "#0D1F52" -gravity NorthWest -pointsize 30 -annotate +1500+200 ':   ID-number' \) \
 \( -font CircularPro-Book.ttf -fill "#0D1F52" -gravity NorthWest -pointsize 30 -annotate +1500+250 ':    Length' \) \
 \( -font CircularPro-Book.ttf -fill "#0D1F52" -gravity NorthWest -pointsize 30 -annotate +1500+300 ':    Name' \) \
 \( -font CircularPro-Book.ttf -fill "#0D1F52" -gravity NorthWest -pointsize 30 -annotate +1500+350 ':    Outlet' \) \
 \( -font CircularPro-Book.ttf -fill "#0D1F52" -gravity NorthWest -pointsize 30 -annotate +1500+400 ':    ISO#' \) \
 \( -font CircularPro-Bold.ttf -fill "#15BDF8" -gravity NorthEast -pointsize 30 -annotate +450+200 '123456-ABCD' \) \
 \( -font CircularPro-Bold.ttf -fill "#15BDF8" -gravity NorthEast -pointsize 30 -annotate +450+250 '1.5m' \) \
 \( -font CircularPro-Bold.ttf -fill "#15BDF8" -gravity NorthEast -pointsize 30 -annotate +450+350 'Outlet Location #1' \) \
 \( -font CircularPro-Bold.ttf -fill "#15BDF8" -gravity NorthEast -pointsize 30 -annotate +450+400 'DNK' \) \
 \( -font CircularPro-Bold.ttf -fill "#15BDF8" -gravity NorthEast -pointsize 40 -annotate +450+500 'V.1' \) \
 \( -font CircularPro-Bold.ttf -fill "#15BDF8" -gravity NorthEast -pointsize 30 -annotate +450+600 'A very long title for testing purposes, hopefully this will fit on the screen!' \) \
 -flatten blank2.png
--Version---
Version: ImageMagick 7.0.8-2 Q16 x86_64 2018-06-19 https://www.imagemagick.org
Copyright: © 1999-2018 ImageMagick Studio LLC
License: https://www.imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules
Delegates (built-in): bzlib freetype jng jpeg ltdl lzma png tiff xml zlib

------

Many thanks.

User avatar
fmw42
Posts: 23420
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Image overlay + labels with wordwrap

Post by fmw42 » 2018-07-04T09:38:19-07:00

With caption: (or label:) you have to create a new image with transparent background with the text in it. Then you have to composite that image over your background. See http://www.imagemagick.org/Usage/text/.

Post Reply