Page 1 of 1

-gravity Centre -crop 100x100 no output

Posted: 2017-06-02T22:14:12-07:00
by astrobob
Hi all

I have hundreds of images from time lapse astronomy of Jupiter that I have rotated by different angles to correct for telescope rotation. They are saved as tifs but have different canvas sizes depending on how much they are rotated. Now all I need to do is crop a rectangle from the middle of each to make into a video of Jupiters moons and red spot moving. I have a vbs script that has successfully used IM to rotate the 700 or so images the correct amount but I cannot get the cropping to work properly.

I am using 64 bit windows 10 with ImageMagick 7.0.5-7 x64 2017-05-20

I have experimented with the syntax from the windows command line: (in.tif is a 3508x4492 image)

magick C:\IMtest\in.tif -crop 1280x720 C:\IMtest\out.tif

crops ok but of course gets the top left corner of the original image

What I want is

magick C:\IMtest\in.tif -gravity Center -crop 1280x720 C:\IMtest\out.tif

but I still get the top left corner of the image. -gravity Centre has no effect on the crop.

What am I doing wrong?

Bob

Re: -gravity Centre -crop 100x100 no output

Posted: 2017-06-02T22:17:18-07:00
by astrobob
Ah ha!

I have just hit the answer

magick C:\IMtest\in.tif -gravity Center -crop 1280x720+0+0 C:\IMtest\out.tif works!

It needs the offsets specified.

Re: -gravity Centre -crop 100x100 no output

Posted: 2017-06-03T08:13:53-07:00
by GeeMack
astrobob wrote: 2017-06-02T22:17:18-07:00I have just hit the answer

magick C:\IMtest\in.tif -gravity Center -crop 1280x720+0+0 C:\IMtest\out.tif works!

It needs the offsets specified.
The "-crop" operator can output one or more images depending on the input image dimensions, the crop arguments, the gravity setting, and the offset arguments. Also keep in mind the "-extent" operator which works a lot like "-crop" but is sometimes simpler to use and will output just a single image.

The "-extent" operator obeys "-gravity" and will modify the size of the viewport, cropping it smaller or adding more area filled with the "-background" color as necessary. It can take arguments that include offsets, but with most common uses of "-extent" they won't be needed. Your command would look something like this...

Code: Select all

magick C:\IMtest\in.tif -gravity Center -extent 1280x720 C:\IMtest\out.tif
Find out more about using "-extent" at THIS link.