Page 1 of 1

How to zoom with convert crop and resize

Posted: 2007-10-12T19:46:35-07:00
by Pyx
I using the Bash command line and ImageMagick 6.2.4.5

If I type;

convert Starter.ppm -resize 100% -crop 725x200+275+450 Result1.ppm

This command cuts out the size and the area of Starter.ppm that I want and saves it in Result1.ppm

If I type;

convert Starter.ppm -resize 200% -crop 725x200+275+450 Result2.ppm

This command does cut the size of Starter.ppm that I want BUT it "zooms in" upwards and to the left of Starter.ppm
saved in Result1.ppm

I DO want to zoom in but, I DO NOT want to move upwards and to the left in the result. How do I avoid this ?

Re: How to zoom with convert crop and resize

Posted: 2007-10-13T00:19:07-07:00
by Bonzo
It is to do with your offset +275+450 which is the distance from the top left corner. It will be different in both examples as you are cropping after resizing.

I would change +275+450 to +550+900 or do the crop first then resizing.

Re: How to zoom with convert crop and resize

Posted: 2007-10-16T18:03:54-07:00
by anthony
The crop offset is for the top left corner, and you have fixed this.

You can in the latest versions of IM do a zoom centered on a particular point using
the ScaleRotateTranslate distortion method.

Code: Select all

   convert Starter.ppm  -interpolate bicubic \
                -set option:distort:viewport 724x200-362-100 \
                -distort SRT '275,450  2 0 0,0'    result.ppm
The 'viewport' is what part of the distorted image space you are looking at
and is basically the 'crop' which is centered on the origin.

the distrort SRT operation, centers its scales and rotates to 275,450 (or whatever you want), the doubles the image size '2' (zoom), does no rotate '0', then moves that
center rto the origin (0,0) wcih is the middle of your viewing window or 'viewport'.

yes it looks complex, but it will work, and will let you pan, zoom, and rotate the image all in one operation.
See IM Examples, Distorts, General Distortion Operator, for details...
http://imagemagick.org/Usage/distorts/#distort

CAVAT! -distort is still in development. As a consequence, I have not finished the quality handling of its scaling (resize) filters. However as you are zooming, the -interpolation setting is the filter control, and not minification filters I am currently working on.