Page 1 of 1
Positioning element(text,image)
Posted: 2018-12-17T22:42:54-07:00
by dt59
Please, how do I specify the x and y offset(that is top left) of an element(-annotate, xc, -draw -label), absolutely to the size of the background am putting the element.
the element may be like these:
but I will want to first apply the x and y offset before using -gravity to set the alignment of the text, i want to avoid the -gravity affecting the x and y offset.
Hope my question is not ambiguous. Thanks
Re: Positioning element(text,image)
Posted: 2018-12-17T23:41:34-07:00
by fmw42
gravity tells annotate to position the x,y relative to nw, n, ne, e, se, s, sw, w corners or the center of the image. If you want north west corner (top left), then either leave -gravity off, since nw is the default or specify -gravity northwest. Then if you need to do other things aftewards, you can change the gravity value. -draw does not respect gravity. label: will respect gravity. You do not want to use -label as that is for meta data. xc does not respect gravity as it creates a new image. Perhaps if you explained what you are trying to do, we could help further.
________________________
Please, always provide your IM version and platform when asking questions, since syntax may differ.
Also provide your exact command line and your images, if possible.
See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at
http://www.imagemagick.org/discourse-se ... f=1&t=9620
If using Imagemagick 7, then see
http://imagemagick.org/script/porting.php#cli
For novices, see
http://www.imagemagick.org/discourse-se ... f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
https://github.com/ImageMagick/usage-markdown
https://imagemagick.org/script/porting.php#cli
Re: Positioning element(text,image)
Posted: 2018-12-18T14:44:44-07:00
by dt59
Thanks Fred, your post has really educated me.
Here is what am trying to achieve, Please use the link below(uploaded image)
https://drive.google.com/file/d/1mcYrB ... p=sharing
Version: ImageMagick 7.0.6-3 Q16 x64 2017-07-24 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
Re: Positioning element(text,image)
Posted: 2018-12-18T15:40:47-07:00
by fmw42
What tool are you using to create the text and position it. Is the text from an image or not? See the following link and the various methods of creating or adding text:
https://imagemagick.org/Usage/text/
Annotate and draw add text to an existing image. Note that -annotate respects gravity, but -draw does not. Looks like you are trying to add text with offsets from the top left corner. That would be the default or for -annotate you can add -gravity northwest. In -annotate you specify the offsets as arguments. With -draw, you specify the argument in the draw command for the offsets of the text.
With label: and caption:, you create a new image with a transparent background. Then you composite it over the background image with -geometry to position it.
A little more description of what you are trying or you command line that you have tried would be helpful.
Example:
Code: Select all
magick logo.png -fill black -font arial -pointsize 32 -annotate +150+200 "TESTING" logo_annotate.png
Re: Positioning element(text,image)
Posted: 2018-12-21T17:18:32-07:00
by dt59
Hi Fred, I later got a way round the problem I was trying to solve, yes. thanks sir.
but what if am using the caption image operator, how do i specify the x and y offset of the paragraph.
Re: Positioning element(text,image)
Posted: 2018-12-21T17:23:33-07:00
by fmw42
dt59 wrote: ↑2018-12-21T17:18:32-07:00
Hi Fred, I later got a way round the problem I was trying to solve, yes. thanks sir.
but what if am using the caption image operator
What is your exact question regarding caption:?
Note that caption: creates a new image of the text, which must be composited over the background image using -gravity and -geometry.
Here is an example:
Input:
Unix syntax (for windows remove the two \ )
Code: Select all
convert logo.png \( -background none -size 200x -pointsize 32 -gravity center -fill pink caption:"THIS IS SOME TESTING OF CAPTION" \) -gravity northwest -geometry +150+200 -compose over -composite logo_caption.png
See
https://imagemagick.org/Usage/text/#caption
https://imagemagick.org/Usage/compose/#geometry
https://imagemagick.org/Usage/layers/#convert
Re: Positioning element(text,image)
Posted: 2018-12-21T17:27:34-07:00
by dt59
fmw42 wrote: ↑2018-12-21T17:23:33-07:00
dt59 wrote: ↑2018-12-21T17:18:32-07:00
Hi Fred, I later got a way round the problem I was trying to solve, yes. thanks sir.
but what if am using the caption image operator
What is your exact question regarding caption:?
how do I specify the x and y offset of the paragraph
Re: Positioning element(text,image)
Posted: 2018-12-21T17:33:21-07:00
by fmw42
See my edited answer above