Why can't I set label geometry when not appending it to another element/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
raehik
Posts: 3
Joined: 2016-01-05T04:16:27-07:00
Authentication code: 1151

Why can't I set label geometry when not appending it to another element/image?

Post by raehik »

I'm trying to create an image from scratch with a set size and background color, and a positioned label. I started with:

Code: Select all

convert -size 1366x768 -background black -fill white -gravity center -pointsize 100 label:"Text here" image.png
This successfully creates a black image with centered white text. I want to move the text to be offset from the center. However, I'm not able to move the label around with -geometry. Why is this not possible? Is there any way to position text over a background without using something like xc:black or overlaying it -- and why do they work while this doesn't?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Why can't I set label geometry when not appending it to another element/image?

Post by snibgo »

The "-geometry" setting is used by "-composite", and not much else.

"-annotate" includes arguments for xy placement. See http://www.imagemagick.org/script/comma ... p#annotate
snibgo's IM pages: im.snibgo.com
raehik
Posts: 3
Joined: 2016-01-05T04:16:27-07:00
Authentication code: 1151

Re: Why can't I set label geometry when not appending it to another element/image?

Post by raehik »

Thanks for the '-annotate' setting. Substituting the 'label:' command for a correctly-formed '-annotate' command doesn't work, however. I think '-annotate' only works when you're annotating an image: I'm making an image rather than overlaying a label on a pre-existing one. (I know I could do it the other way, but I want to know why I can't the first way.)
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Why can't I set label geometry when not appending it to another element/image?

Post by GeeMack »

raehik wrote:Thanks for the '-annotate' setting. Substituting the 'label:' command for a correctly-formed '-annotate' command doesn't work, however. I think '-annotate' only works when you're annotating an image: I'm making an image rather than overlaying a label on a pre-existing one. (I know I could do it the other way, but I want to know why I can't the first way.)
You need to create a canvas with "xc:". Try something like this...

Code: Select all

convert -size 1366x768 xc:black -fill white -gravity center -pointsize 100 -annotate +50+50 "Write your text here." image.png
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Why can't I set label geometry when not appending it to another element/image?

Post by snibgo »

I think '-annotate' only works when you're annotating an image: I'm making an image rather than overlaying a label on a pre-existing one. (I know I could do it the other way, but I want to know why I can't the first way.)
Anything ending with a colon (:) creates a new image. So "xc:", "label:", "caption:" each create a new image. When creating a new image, "-geometry" has no meaning.

Operations start with "-", so "-annotate" is an operation that modifies an image that must already exist.
snibgo's IM pages: im.snibgo.com
raehik
Posts: 3
Joined: 2016-01-05T04:16:27-07:00
Authentication code: 1151

Re: Why can't I set label geometry when not appending it to another element/image?

Post by raehik »

Thanks snibgo! Went through a lot of docs but didn't find that out. There are a lot of ways to go about what I was trying to do, but my command was:

Code: Select all

convert -size 1366x768 xc:black \
-pointsize 100 -gravity center -fill white -annotate +300+300 'Text here' outfile.png
Post Reply