Page 1 of 1

Individually resizable crop lines

Posted: 2016-06-08T20:48:46-07:00
by dylantovey
We have an installation of magento that includes significant integration with imagemagick to resize images.

A previous developer developed an option that allows users to crop in proportionate rectangles - as per the attached screenshot. Users can move the crop lines around - and also pull it out (but it resizes as a proportionate rectangle)

http://imgur.com/zpUKpQl

We have a new developer and are trying to develop the codebase so users can individually drag in crop lines (and not have the overall crop resized proportionately)

Just wondering if anybody knows what this function is called within imagemagick. The developer is happy to work out the specifics - but wasn't sure where to start :-)

Cheers

Dylan

Re: Individually resizable crop lines

Posted: 2016-06-08T21:28:29-07:00
by snibgo
The ImageMagick crop command-line option is "-crop WxH+X+Y". See http://www.imagemagick.org/script/comma ... s.php#crop

If you mean "function" as in C-programming, it is CropImage() in transform.c

Re: Individually resizable crop lines

Posted: 2016-06-08T21:29:03-07:00
by fmw42
See -crop at http://www.imagemagick.org/Usage/crop/#crop. You have to draw your box to some arbitrary size, then get the top left x,y and the width and height of your box. Then you would feed those to -crop WxH+X+Y +resize. Then you would feed that to -repage. But -resize will try to resize proportionally and so if the aspect of the box is not the same as that of the original image, then the resize will not end up the size you specified unless you either distort it (using !) or crop it further by making it bigger (using ^) or pad it. See
http://www.imagemagick.org/script/comma ... php#resize
http://www.imagemagick.org/script/comma ... p#geometry
http://www.imagemagick.org/Usage/thumbnails/#pad
http://www.imagemagick.org/Usage/thumbnails/#cut

Re: Individually resizable crop lines

Posted: 2016-06-08T21:49:09-07:00
by dylantovey
Thanks guys - that is some great points to get him started.

Regards

Dylan

Re: Individually resizable crop lines

Posted: 2016-06-08T22:12:28-07:00
by snibgo
Another way of crop + resize together is with "-distort SRT" at the command line, or the functions in distort.c. However, for a real-time follow-the-mouse resize, ScaleImage() etc are probably faster. (You could do quick-and-dirty resizing while the user is holding down the mouse button, then slower but proper resize when the mouse button is released.)