Different gravity for translate and scale

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
rotem
Posts: 46
Joined: 2016-04-15T13:34:32-07:00
Authentication code: 1151

Different gravity for translate and scale

Post by rotem »

Hi all,

I'm trying to position a text with one gravity and the scale it with another, is that possible?

This is a command I'm currently using which isn't working

Code: Select all

convert -quality 100 input.jpg -font assets/grobold.ttf -pointsize 21 -stroke "none" -fill "white" -draw " gravity North translate 0,0 skewX 0 skewY 0 rotate 0 gravity Center scale 2,2 text 0,0 'Hello' " result.jpg
Thanks
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Different gravity for translate and scale

Post by fmw42 »

How is it not working? What results do you get? You can post to some place such as dropbox.com and put the URL here?

I would break it up. start with one argument and test, then add another argument and test, and so on. Find where it breaks.

Note, that -quality 100 should come properly at the end before your output, though in IM 6, it probably does not matter.

Please always provide your IM version and platform, since syntax differs and if an old version, there may be bugs.

Everything works fine for me without the gravity center and then with the gravity center using IM 6.9.5.4 Q16 Mac OSX. Note you did not specify a pointsize.

Code: Select all

convert -size 250x250 xc:white -font arial -pointsize 21 -fill "black" -pointsize 36 -draw "gravity North translate 0,0 skewX 0 skewY 0 rotate 0 scale 2,2 text 0,0 'Hello'" -quality 100 result2.jpg
In the above, the text is at the top center and is twice as large as without the scale

Code: Select all

convert -size 250x250 xc:white -font arial -pointsize 21 -fill "black" -pointsize 36 -draw "gravity North translate 0,0 skewX 0 skewY 0 rotate 0 gravity center scale 2,2 text 0,0 'Hello'" -quality 100 result3.jpg
In the above the text is in the center and is twice as large as without the scale.


Is this not what you expect. If not, what are you expecting?
rotem
Posts: 46
Joined: 2016-04-15T13:34:32-07:00
Authentication code: 1151

Re: Different gravity for translate and scale

Post by rotem »

Hey fmw42

I actually managed to find another solution to my main problem but let me answer all of your questions.

The version I'm using is 6.9.4-3 Q16 x86_64 2016-05-23.

The result for the this script

Code: Select all

convert -size 250x250 xc:white -font arial -pointsize 36 -fill "black" -draw "gravity North translate 0,0 skewX 0 skewY 0 rotate 0 gravity Center scale 2,2 text 0,0 'Hello'" -quality 100 result2.jpg
is this

Image

what I want to get is something more resemble to this

Image

since the scaling suppose to be executed after the positioning
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Different gravity for translate and scale

Post by fmw42 »

I get the text near the top and all visible with IM 6.9.5.4 Q16 Mac OSX (removed gravity center)

Code: Select all

convert -size 250x250 xc:white -font arial -pointsize 21 -fill "black" -pointsize 36 -draw "gravity North translate 0,0 skewX 0 skewY 0 rotate 0 scale 2,2 text 0,0 'Hello'" -quality 100 result2.jpg
rotem
Posts: 46
Joined: 2016-04-15T13:34:32-07:00
Authentication code: 1151

Re: Different gravity for translate and scale

Post by rotem »

Yeah but I want it to be like the second example.
I want that the first gravity will effect the translate and the second gravity the scale.

Is that possible?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Different gravity for translate and scale

Post by fmw42 »

Scale is scale. Gravity is not relevant, except for final positioning/justification. I am not sure what you actually want. I gave two examples. The first had the text at the top as you seemed to have wanted. The second had the same size text, but was ultimately in the center of the image. What do you want that is different from either of these?
rotem
Posts: 46
Joined: 2016-04-15T13:34:32-07:00
Authentication code: 1151

Re: Different gravity for translate and scale

Post by rotem »

Well, I'm building a scaling animation and if the gravity of the drawing is Center the animation looks better since the scaling occur in the same ratio from all directions but if I use different gravity (North for example) the scaling occur from the West, East & South directions and not the North which creates a kinda different animation.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Different gravity for translate and scale

Post by fmw42 »

rotem wrote:Well, I'm building a scaling animation and if the gravity of the drawing is Center the animation looks better since the scaling occur in the same ratio from all directions but if I use different gravity (North for example) the scaling occur from the West, East & South directions and not the North which creates a kinda different animation.

Can you provide the command and result that fails for say North?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Different gravity for translate and scale

Post by fmw42 »

Are you using the latest version of IM?
rotem
Posts: 46
Joined: 2016-04-15T13:34:32-07:00
Authentication code: 1151

Re: Different gravity for translate and scale

Post by rotem »

I'm not sure, I'm using ver 6.9.4-3 Q16 x86_64 2016-05-23. but I don't think there is a problem with IM, I actually think it working properly. I thought that maybe there is a way to tell the drawing to use different gravity for the scaling only.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Different gravity for translate and scale

Post by fmw42 »

All that does is change the final justification. Scaling is gravity insensitive.
rotem
Posts: 46
Joined: 2016-04-15T13:34:32-07:00
Authentication code: 1151

Re: Different gravity for translate and scale

Post by rotem »

I understand, thanks
Post Reply