Page 1 of 1
Special crop and resize
Posted: 2009-05-17T02:46:34-07:00
by mattalexx
I wrote down what I need to accomplish and scanned it in:
So I would provide width of the square (25) and the command would take care of the rest.
It would be cool if I could do the whole thing in one command. Is that possible?
Re: Special crop and resize
Posted: 2009-05-17T03:18:33-07:00
by Bonzo
How are you going to know what the shortest side is ?
Code: Select all
convert input.jpg -gravity center -crop 25x25+0+0 output.jpg
Re: Special crop and resize
Posted: 2009-05-17T03:22:30-07:00
by mattalexx
Bonzo wrote:How are you going to know what the shortest side is ?
I was hoping the command would figure it out.
Bonzo wrote:
Code: Select all
convert input.jpg -gravity center -crop 25x25+0+0 output.jpg
This is cropping which is cool, but I need the image to be resized also so that the shortest side is 25 pixels,
Re: Special crop and resize
Posted: 2009-05-17T04:53:49-07:00
by Bonzo
What does this give you?
Code: Select all
convert output.jpg -resize 25x25^ -gravity center -crop 25x25+0+0 result.jpg
See
http://www.imagemagick.org/script/comma ... p#geometry
Re: Special crop and resize
Posted: 2009-05-17T04:56:57-07:00
by mattalexx
Code: Select all
convert: invalid argument for option `25x25^': -resize.
Re: Special crop and resize
Posted: 2009-05-17T05:16:55-07:00
by Bonzo
How are you running the code - command line, php etc.
Re: Special crop and resize
Posted: 2009-05-17T05:22:22-07:00
by mattalexx
Bonzo wrote:How are you running the code - command line, php etc.
Linux command line, yes.
Re: Special crop and resize
Posted: 2009-05-17T10:04:05-07:00
by fmw42
convert input.jpg -resize '25x25^' -gravity center -crop 25x25+0+0 +repage result.jpg
but need IM v6.3.8-3 or higher
Re: Special crop and resize
Posted: 2009-05-17T13:06:34-07:00
by mattalexx
fmw42 wrote:convert input.jpg -resize '25x25^' -gravity center -crop 25x25+0+0 +repage result.jpg
but need IM v6.3.8-3 or higher
Code: Select all
mattserver ~: convert --version
Version: ImageMagick 6.3.7 02/19/08 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2008 ImageMagick Studio LLC
mattserver ~: convert image.jpg -resize '25x25^' -gravity center -crop 25x25+0+0 +repage result.jpg
convert: invalid argument for option `25x25^': -resize.
mattserver ~:
Damn -- one point off! I wish there were some way to upgrade IM on my client's production server. But alas, there is not.
Am I SOL?
Re: Special crop and resize
Posted: 2009-05-17T15:28:46-07:00
by fmw42
Damn -- one point off! I wish there were some way to upgrade IM on my client's production server. But alas, there is not.
Am I SOL?
Not completely out of luck. You can script it easy enough. I already have one called squareup at
http://www.fmwconcepts.com/imagemagick/index.html.
I wrote the script before the ^ notation was available for -resize.
Re: Special crop and resize
Posted: 2009-05-17T15:32:06-07:00
by mattalexx
fmw42 wrote:Damn -- one point off! I wish there were some way to upgrade IM on my client's production server. But alas, there is not.
Am I SOL?
Not completely out of luck. You can script it easy enough. I already have one called squareup at
http://www.fmwconcepts.com/imagemagick/index.html.
I wrote the script before the ^ notation was available for -resize.
That looks great! Thank you.
Re: Special crop and resize
Posted: 2009-05-19T12:30:47-07:00
by mattalexx
Hey I just tried it and it works exactly right. Thanks again!