Page 1 of 1

Merge 4 IM calls, into 1?

Posted: 2013-01-25T18:50:08-07:00
by wwftdg
I am currently 4 system calls in PHP for some image resizing scripts. I think this may work more stable if I can convert it into one command. Anyone know if this is possible?

step 1 (resize image down)

Code: Select all

system(binary_system_path()."convert $source -limit memory 1 -limit map 1 -thumbnail x800\> -bordercolor '#ffffff' -border 0 -gravity center -crop x800+0+0 +repage -strip -quality 90 -profile $rgbProfile $thumb");
step 2 (check for max width)

Code: Select all

system(binary_system_path()."convert $thumb -limit memory 1 -limit map 1 -thumbnail '200X' $thumb");
step 3 (check for Minimum width)

Code: Select all

system(binary_system_path()."convert $thumb -limit memory 1 -limit map 1 -gravity center -background '#ffffff' -extent 200x".$tHeight." $thumb");
Step 4 (check for Minimum height)

Code: Select all

system(binary_system_path()."convert $thumb -limit memory 1 -limit map 1 -gravity center -background '#ffffff' -extent ".$tWidth."x100 $thumb");
The basic objective is take an uploaded image, and size it down, then make sure its:
- size down to a maximum of 800px tall
- not wider than 200px
- at least 200px wide
- at least 100px tall

- - -
Anybody got any ideas?

Re: Merge 4 IM calls, into 1?

Posted: 2013-01-25T20:20:58-07:00
by fmw42
Just string all the commands together without a convert between them

system(binary_system_path()."convert $source -limit memory 1 -limit map 1 -thumbnail x800\> -bordercolor '#ffffff' -border 0 -gravity center -crop x800+0+0 +repage -strip -quality 90 -profile $rgbProfile -thumbnail '200X' -gravity center -background '#ffffff' -extent 200x".$tHeight." -gravity center -background '#ffffff' -extent ".$tWidth."x100 $thumb");

Re: Merge 4 IM calls, into 1?

Posted: 2013-01-28T16:59:06-07:00
by anthony
But you make like to format it in the code to make it more readable.
See PHP code formating for IM
Rubble Web, Examples of how to write ImageMagick code
http://www.rubblewebs.co.uk/imagemagick ... xplain.php

Also... IM Examples, PHP API
http://www.imagemagick.org/Usage/api/#php_example