Page 1 of 1

ASP CLASSIC: center crop image

Posted: 2017-02-02T04:14:00-07:00
by studion
Hi, I'm using ImageMagck to generate thumbnails from a big image on my classic asp site.

This is my resize command that works correctly:
imageMagick.Convert "1-thumb.jpg", "-resize=" & newWidth & "x" & newHeight, "1-thumb.jpg"

My goal is to create thumbnails with the same size so I control, with an IF procedure, if my image is larger than 253 px and then I crop it:
imageMagick.Convert "1-thumb.jpg", "-gravity Center", "-crop" , newWidth & "x" & newHeight & "+0+0", "+repage", "1-thumb.jpg"

If I put the command like the tutorial tell me the server return to me this error:
ImageMagickObject.MagickImage.1 error '80041771'
convert: 410: unrecognized option `-gravity Center' @ error/convert.c/ConvertImageCommand/1783:

If I modify the command like this:
imageMagick.Convert "1-thumb.jpg", "-gravity", " Center", "-crop" , newWidth & "x" & newHeight & "+0+0", "+repage", "1-thumb.jpg"
it works but the image will be cropped from the left side and not from the center.

Can you help me?

Re: ASP CLASSIC: center crop image

Posted: 2017-02-02T07:22:02-07:00
by snibgo
What version of IM are you using?

Re: ASP CLASSIC: center crop image

Posted: 2017-02-02T07:26:35-07:00
by studion
The version of IM is 7.0.4-6-Q16.

Is it possible that this function doesn't work because it is deprecated on website that use ASP?

Re: ASP CLASSIC: center crop image

Posted: 2017-02-02T07:43:45-07:00
by snibgo
I know nothing about ASP. With recent version of IM, as you have, I don't know why cropping from the center doesn't work.

Of course, you are overwriting the file, so when it has cropped once, re-running the code won't crop again.

Re: ASP CLASSIC: center crop image

Posted: 2017-02-02T07:59:44-07:00
by studion
I have 3 passages for an image:
1) I pick the original, large size, image and I rename it,
2) I resize the renamed image only on height (width proportional),
3) If the width is over 253 px I crop the resized image.

All the process works correctly, incluse crop but it start from the default side, left top, and not on center.

Re: ASP CLASSIC: center crop image

Posted: 2017-02-02T08:00:29-07:00
by studion
Please, can you tell me if my command lines are ok?

Re: ASP CLASSIC: center crop image

Posted: 2017-02-02T08:21:15-07:00
by snibgo
I don't use ASP, so can't advise on that.

The IM parts look okay, but what are the values of newWidth and newHeight? And what size is the input image?

Re: ASP CLASSIC: center crop image

Posted: 2017-02-02T08:41:13-07:00
by studion
newWidth = 253 px
newHeight = 357 px

The input image is over 1.000x1.000 px

Re: ASP CLASSIC: center crop image

Posted: 2017-02-02T09:21:54-07:00
by snibgo
I suggest you try it as a command, at your shell:

Code: Select all

convert 1-thumb.jpg -gravity Center -crop 253x357+0+0 +repage out.jpg