ASP CLASSIC: center crop image

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
studion
Posts: 5
Joined: 2017-02-02T04:05:47-07:00
Authentication code: 1151

ASP CLASSIC: center crop image

Post 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?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: ASP CLASSIC: center crop image

Post by snibgo »

What version of IM are you using?
snibgo's IM pages: im.snibgo.com
studion
Posts: 5
Joined: 2017-02-02T04:05:47-07:00
Authentication code: 1151

Re: ASP CLASSIC: center crop image

Post 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?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: ASP CLASSIC: center crop image

Post 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.
snibgo's IM pages: im.snibgo.com
studion
Posts: 5
Joined: 2017-02-02T04:05:47-07:00
Authentication code: 1151

Re: ASP CLASSIC: center crop image

Post 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.
studion
Posts: 5
Joined: 2017-02-02T04:05:47-07:00
Authentication code: 1151

Re: ASP CLASSIC: center crop image

Post by studion »

Please, can you tell me if my command lines are ok?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: ASP CLASSIC: center crop image

Post 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?
snibgo's IM pages: im.snibgo.com
studion
Posts: 5
Joined: 2017-02-02T04:05:47-07:00
Authentication code: 1151

Re: ASP CLASSIC: center crop image

Post by studion »

newWidth = 253 px
newHeight = 357 px

The input image is over 1.000x1.000 px
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: ASP CLASSIC: center crop image

Post 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
snibgo's IM pages: im.snibgo.com
Post Reply