Merge 4 IM calls, into 1?

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
wwftdg
Posts: 10
Joined: 2013-01-10T08:40:49-07:00
Authentication code: 6789

Merge 4 IM calls, into 1?

Post 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?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Merge 4 IM calls, into 1?

Post 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");
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Merge 4 IM calls, into 1?

Post 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
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply