Page 1 of 1

Resize image to exact 64x64 Pixels

Posted: 2009-05-15T03:14:58-07:00
by Achim74
Hello !

I hope I can explain in my poor english what I would like to do.

I want to resize a picture to exactly 64x64 Pixels without loosing aspect ratio by cropping either the width or height.

- The aspect ratio should be kept
- If the height or width is greater than 64 the picture should be cropped from the center
- Important too: If a image is smaller than 64px it should be also resized (make bigger) to 64x64

I used this code before:

Code: Select all

$command = "/usr/bin/convert $resized -resize 50% +profile \"*\" ".$dest_folder."images/avatar/temp.jpg";
passthru($command);
$command = "/usr/bin/convert ".$dest_folder."images/avatar/temp.jpg -gravity Center -crop 64x64+0+0  +profile \"*\" $output";
passthru($command);
But it resizes sometimes only one side to 64 .. so you get 64x45 or something ...

Can somebody help me please ... any help is appreciated .. Thank you very much !

PS: This don't work for me .. which version do I need ? I have 6.2.4

Code: Select all

widthxheight^  	Minimum values of width and height given, aspect ratio preserved.

Re: Resize image to exact 64x64 Pixels

Posted: 2009-05-15T08:56:22-07:00
by fmw42
You need IM v6.3.8-3 to use -resize with ^

Add +repage after your crop

Re: Resize image to exact 64x64 Pixels

Posted: 2009-05-15T12:34:14-07:00
by Achim74
Thank you for your reply. Unfortunately there is no possibility to install a newer version on this host. Is there a workaround ?

Greetings

Re: Resize image to exact 64x64 Pixels

Posted: 2009-05-15T15:27:12-07:00
by fmw42
You can script it by testing the image sizes. I wrote a bash script before the ^ option was available. See squareup at http://www.fmwconcepts.com/imagemagick/index.html