[SOLVED] append colored text to an image

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
manit
Posts: 123
Joined: 2009-01-30T22:31:26-07:00

[SOLVED] append colored text to an image

Post 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 ?
Last edited by manit on 2019-06-24T21:53:28-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: append colored text to an image

Post 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).
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: append colored text to an image

Post 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.
manit
Posts: 123
Joined: 2009-01-30T22:31:26-07:00

Re: append colored text to an image

Post 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 .
manit
Posts: 123
Joined: 2009-01-30T22:31:26-07:00

Re: append colored text to an image

Post by manit »

That can be done using -border and -bordercolor option .
This thread is solved .
Post Reply