magick icon indicating copy to clipboard operation
magick copied to clipboard

Crop issue with this library

Open TimothyYe opened this issue 9 years ago • 1 comments

Hi quirekey,

I crop an image with imagemagick command line: convert 552def3c7b88432e7b88218028efa97e.jpg -crop 225x225+105+32 output.jpg

I got a square image with size: 225*225

But with the same image file, when I use this library to crop an image with following go code:

cropStr := fmt.Sprintf("%dx%d+%d+%d", w, h, x, y)
fmt.Println("crop string is:" + cropStr)
image.Crop(cropStr)
fmt.Println("width is: " + strconv.Itoa(image.Width()))
fmt.Println("height is: " + strconv.Itoa(image.Height()))

Then I got a rectangle image, not a square image.

The output is:

crop string is:225x225+105+32
width is: 225
height is: 150

TimothyYe avatar Apr 10 '15 08:04 TimothyYe

I had the same problem. I fixed it by writing my geometry like so:

225x225!+105+32

From the imagemagick docs: widthxheight! Width and height emphatically given, original aspect ratio ignored.

http://www.imagemagick.org/script/command-line-processing.php#geometry

I agree that this is surprising though given how convert works.

horgh avatar Nov 16 '16 18:11 horgh