Methods to save creating tempory images

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.

<?php 
$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"
?>

Tiled text watermarked example

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.

<?php 
$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

<?php 
$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.