Centering the Label of an Image doesn't work

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
laocoon
Posts: 3
Joined: 2017-11-27T02:38:30-07:00
Authentication code: 1152

Centering the Label of an Image doesn't work

Post by laocoon » 2017-11-27T02:55:31-07:00

Hey,

I'm having a problem with labeling an Image. I want to lower the label a little bit, so it sits nice in the center of the "label-box" (canvas?). I tried almost every example on the ImageMagick Text-Handling page (http://www.imagemagick.org/Usage/text/#label), but couldn't get it working.

So here is the code I'm using:

Code: Select all

montage \
-label "WEIHNACHTSFEIER CINEMAXX 2017" path/to/the/image.jpg \
-gravity center \
-font Times-Bold \
-pointsize 170 \
-fill DeepPink \
-geometry +0+0 \
-background black /home/pi/temp.jpg
This is what i get as an output:

Image

I want the label to sit a bit lower, so it is in the middle of the black background.

Thanks for your help!

snibgo
Posts: 9619
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Centering the Label of an Image doesn't work

Post by snibgo » 2017-11-27T04:10:27-07:00

What version of IM? If older than 6.9, I suggest you upgrade.
snibgo's IM pages: im.snibgo.com

laocoon
Posts: 3
Joined: 2017-11-27T02:38:30-07:00
Authentication code: 1152

Re: Centering the Label of an Image doesn't work

Post by laocoon » 2017-11-27T06:52:59-07:00

Thanks for the fast reply.

I had 6.8 installed, now i updated to 6.9.9.23 but my scripts aren't working anymore. Now i get the following Error:

Code: Select all

montage: no decode delegate for this image format 'JPEG' @error/constitute.c/ReadImage504.
montage: missing an image filename '/home/pi/temp.jpg' @error/montage.c/MontageImageCommand/1793.
I ran sudo make check before and it seemed like everything was ok. What is the problem now?

snibgo
Posts: 9619
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Centering the Label of an Image doesn't work

Post by snibgo » 2017-11-27T07:56:51-07:00

laocoon wrote:no decode delegate for this image format 'JPEG'
If it can't read JPEGs, that suggests a serious problem. What happens with:

Code: Select all

convert -list version
convert rose: r.jpg
convert r.jpg r2.jpg
convert rose: r.png
convert r.png r2.png
They should all work. Please paste the text output from "convert -list version". It should be something like:

Code: Select all

Version: ImageMagick 6.9.5-3 Q16 x86 2016-07-22 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Visual C++: 180040629
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib cairo flif freetype jng jp2 jpeg lcms lqr openexr pangocairo png ps rsvg tiff webp xml zlib
If you don't have delegates, that's the problem. How did you install? Did you build from source, without building delegates first?
snibgo's IM pages: im.snibgo.com

laocoon
Posts: 3
Joined: 2017-11-27T02:38:30-07:00
Authentication code: 1152

Re: Centering the Label of an Image doesn't work

Post by laocoon » 2017-11-27T08:40:29-07:00

Code: Select all

convert -list version
leads to following output:

Code: Select all

convert: unrecognized list type 'version' @ error/convert.c/ConvertImageCommand/2053
the rest of the commands you posted are working now.

I installed in the following way after downloading and unzipping:

Code: Select all

cd ImageMagick-*
sudo ./configure
sudo make
sudo make install
after that i researched on the delegate topic and downloaded from imagemagick/download/delegate/jpeg-9b, ran the same process with jpeg-9b and than reran the installation of imagemagick. Now I get no errors anymore, but the label isn't moving either, still keeps on the top of the black box.

When I type

Code: Select all

identify -version
I get:

Code: Select all

Version: ImageMagick 6.9.9-23 Q16 arme 2017-11-27
Copyright:....
License: ....
Features: Cipher DPC OpenMP
Delegates (built-in): freestyle jpg jpeg png zlib
Thanks for your help so far! Do you have any suggestions why the label isn't moving?

snibgo
Posts: 9619
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Centering the Label of an Image doesn't work

Post by snibgo » 2017-11-27T09:35:11-07:00

I don't know. With v6.9.5-3, I get:

Code: Select all

montage \
-label "WEIHNACHTSFEIER CINEMAXX 2017" toes.png \
-gravity center \
-font Times-New-Roman-Bold \
-pointsize 170 \
-fill DeepPink \
-geometry +0+0 \
-background black out.jpg
Image
My image is too small for the text, but it spaces correctly. -label "W" gives:
Image
Maybe there is a problem with your font. Do other fonts work correctly?
snibgo's IM pages: im.snibgo.com

User avatar
fmw42
Posts: 22486
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: Centering the Label of an Image doesn't work

Post by fmw42 » 2017-11-27T11:07:44-07:00

Delegates (built-in): freestyle jpg jpeg png zlib
You need fontconfig to use font names and the font needs to be in your type.xml file. Otherwise, use the path to the font file itself with suffix.

I suggest you re-install but before you do, make sure you have installed all the delegates you need such as PNG, Ghostscript, etc. See snigbo's list for example.

What is your platform and how did you install ImageMagick?

Post Reply