Multi photos

Multi photos example
<?php // Original image
$image $input14;

// Amount of images in x
$qty_x '4';

// Amount of images in y
$qty_y '3';

// Get the size of the original image
$size getimagesize($image);

// Size to crop the images to 
// code modified as per sugestion of Dave to prevent problems with left over parts of the divided image.
$crop_x round$size[0]/$qty_x 0.5);
$crop_y round$size[1]/$qty_y 0.5 );

// Canvas for combined images - it will be trimmed to the finished image size in the code
$width = ( $size[0] * 1.5 );
$height = ( $size[1] *1.5 );

// Crop the image
exec("convert $image -crop {$crop_x}x{$crop_y} image-%d.miff"); 

// Remove the .miff from the filenames
foreach (glob("*.miff") as $filename) {
$file str_replace('.miff'''$filename );
exec("convert $filename -background black +polaroid $file.png"); 

// Delete tempory images
foreach (glob("*.miff") as $filename) {

// Set $command variable
$command "";

// Loop through generating the image layout
for ($j 0$j $qty_y$j++) { 

  for (
$i 0$i $qty_x$i++) {    $n $j>$qty_x*($j)+$i $i
$offset_x= ( ($crop_x $i ) + rand(225));
$offset_y=( ($crop_y $j ) + rand(225));
$command .= " image-$n.png -geometry +$offset_x+$offset_y -composite" ;  } 

// Produce the combined image
exec"convert -size {$width}x{$height} xc:#262b38 $command -trim combined.jpg"); 

// Delete tempory images
foreach (glob("image-*.png") as $filename) {

Dividing an image up so it looks like it is made up of a lot of smaller photos. The image rotations and spacings are random within certain limits so the final image will be slightly different everytime. This code needs running in a directory of its own as it is setup to delete ALL the tempory png images created. Any other png images in the folder will be deleted as well. You could get around this in other ways but the code would not be as "portable".