Page 1 of 1

[SOLVED] append colored text to an image

Posted: 2019-06-08T19:06:07-07:00
by manit
hi,
I am using
$ display --version
Version: ImageMagick 6.8.9-9 Q16 x86_64 2018-09-28 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules OpenMP
Delegates: bzlib cairo djvu fftw fontconfig freetype jbig jng jpeg lcms lqr ltdl lzma openexr pangocairo png rsvg tiff wmf x xml zlib
on 64bit ubuntu OS
Distributor ID: Ubuntu
Description: Ubuntu 16.04.5 LTS
Release: 16.04
Codename: xenial

My requirement is that
I want to add colored text with white background to bottom of file .
Can this be done using one command rather than creating a separate text image then using append ?

Re: append colored text to an image

Posted: 2019-06-08T19:36:03-07:00
by fmw42
You can do that by splicing white at the bottom, then using -annotate, then splicing a bit more.

Code: Select all

convert logo: -background white -gravity south -splice 0x20 -fill red -pointsize 18 -annotate +0+0 "testing" -splice 0x5 result.png
or you can use montage.

Code: Select all

montage -label "testing" logo: -background white -fill red -pointsize 18 -tile x1 -geometry +0+0 result.png

Here I use the ImageMagick internal image logo: (replace logo: with your image.suffix).

Re: append colored text to an image

Posted: 2019-06-08T19:38:56-07:00
by GeeMack
manit wrote: 2019-06-08T19:06:07-07:00My requirement is that
I want to add colored text with white background to bottom of file .
Can this be done using one command rather than creating a separate text image then using append ?
Within a single command you can create a label with colored text on a white background, and append that label to the bottom of your input image. A command like this should get you started...

Code: Select all

convert input.png -background white -fill red -pointsize 24 label:"Any text." -gravity south -append result.png
That will read your input image, then create a label and add it to the bottom of the input image. The label will have red text on a white background. When you use "-append", the excess space beyond the label will also use the color you set for the background. There are several options available to tweak the text size, font, alignment, etc.

Re: append colored text to an image

Posted: 2019-06-24T16:11:32-07:00
by manit
Geemack,
That works for me .
Can you enclose that text in rectangle before addition so that I have separated rows at bottom of image .
Actually I am pointing a straight line to bottom of image .

Re: append colored text to an image

Posted: 2019-06-24T21:52:59-07:00
by manit
That can be done using -border and -bordercolor option .
This thread is solved .