THESE CODES ARE PROVIDED FOR AN EXAMPLE OF HOW TO USE IMAGEMAGICK WITH PHP. CARE SHOULD BE TAKEN WHEN ACCEPTING USER INPUT.
I TAKE NO RESPONSABILTY FOR ANY PROBLEMS THAT MAY OCCURE WHEN USING ANY OF THIS CODE.
IT IS UP TO YOU TO SECURE THE CODE AND VALIDATE USER INPUT.
You could also save your images to the server temp folder where they will be automaticaly cleaned up.
This uses the imagemagick miff ( a version of a bit map image ) which saves the image into the memory and then the Unix "pipe".
This uses the image created in the first part of the code in the second part of the code.
Note the extra - after -tile and before the image name; I belive this is to "balance" the code as you are using the image in the memory rather than calling a new one.
$cmd = " -size 140x80 xc:none -fill grey -gravity NorthWest ".
" -draw \"text 10,10 \"Copyright\" \" -gravity SouthEast ".
" -draw \"text 5,15 \"Copyright\" \" miff:- | composite ".
" -tile - $input14 ";
exec("convert $cmd tiled_text.jpg"
This method again saves the tempory image into the memory; you can call the image whatever you like - in this case its called image.
Once the image is saved into the memory you can call it as many times as you like.
$cmd = "input.jpg -write mpr:image +delete ".
" \( mpr:image -thumbnail x480 -write 480_wide.jpg \) ".
" \( mpr:image -thumbnail x250 -write 250_wide.jpg \) ".
" \( mpr:image -thumbnail x100 -write 100_wide.jpg \) ".
" \( mpr:image -thumbnail 64x64! -write 64_square.jpg \) ".
" \( mpr:image -colorspace Gray -write black_white.jpg \)";
exec("convert $cmd ");
This method is "cloning" the image and using it multiple times
$cmd = " input.jpg \( -clone 0 -thumbnail x480 -write 480_wide.jpg +delete \)".
" \( -clone 0 -thumbnail x250 -write 250_wide.jpg +delete \) ".
" \( -clone 0 -thumbnail x100 -write 100_wide.jpg +delete \) -thumbnail 64x64! null: ";
exec("convert $cmd 64_square.jpg ");
So far I have not found a way to use the tempory images in the memory once you have left exec( ); the image should still be in memory as shell examples I have seen can still access them.