CenterGravity not working.

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
rpatelob
Posts: 62
Joined: 2017-04-17T22:17:01-07:00
Authentication code: 1151

CenterGravity not working.

Post by rpatelob »

Code: Select all

convert ./cylinderize_1_20264.mpc -gravity center -crop 2000x443.089+0+0 +repage ./cylinderize_1_20264.mpc

Code: Select all

 MagickSetImageGravity(wand, CenterGravity);
    MagickCropImage(wand, 2000, 443, 0, 0);
    MagickResetImagePage(wand,"2000x443+0+0");
    MagickWriteImage(wand,"Fred_single_color1_36.png");
But somehow MagickSetImageGravity isn't working.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: CenterGravity not working.

Post by snibgo »

MagickCropImage() isn't sensitive to gravity.
snibgo's IM pages: im.snibgo.com
rpatelob
Posts: 62
Joined: 2017-04-17T22:17:01-07:00
Authentication code: 1151

Re: CenterGravity not working.

Post by rpatelob »

snibgo wrote: 2017-04-18T00:36:41-07:00 MagickCropImage() isn't sensitive to gravity.
How can I do it then?
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: CenterGravity not working.

Post by Bonzo »

A bit of a pain but could you write some code to calculate the co ordinates for the crop?
rpatelob
Posts: 62
Joined: 2017-04-17T22:17:01-07:00
Authentication code: 1151

Re: CenterGravity not working.

Post by rpatelob »

Bonzo wrote: 2017-04-18T02:45:21-07:00 A bit of a pain but could you write some code to calculate the co ordinates for the crop?
Could you please check http://stackoverflow.com/questions/4347 ... ot-working link? There is a source image too
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: CenterGravity not working.

Post by snibgo »

As Bonzo says, you need to calculate the x and y offsets.

To centralise the composite, the x-offset is the difference in the image widths, divided by two. Likewise for the y-offset.
snibgo's IM pages: im.snibgo.com
rpatelob
Posts: 62
Joined: 2017-04-17T22:17:01-07:00
Authentication code: 1151

Re: CenterGravity not working.

Post by rpatelob »

snibgo wrote: 2017-04-18T11:20:33-07:00 As Bonzo says, you need to calculate the x and y offsets.

To centralise the composite, the x-offset is the difference in the image widths, divided by two. Likewise for the y-offset.
Yes, I did that as an alternate option, as gravity creates a problem. Thank you!
Post Reply