Its a Vista 32bit computer using XAMPP and the miff is working OK through a batch file and command box.
The error I get is:
This code used to run OK and it still does run up to the area marked ****** where I get the errors above. The cropped images are created and then the program exits.
I can resize to a jpg thumbnail and png but if I try to resize to a miff I get the above error again.
Code: Select all
<?php
//unlink('combined.png');
// Original image
$image = 'original/bridge.jpg';
exec("convert $image -thumbnail 800x800 output.png");
$image = "output.png";
// Amount of images in x
$qty_x = '5';
// Amount of images in y
$qty_y = '4';
// 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.jpg");
******
// Remove the .jpg from the filenames
foreach (glob("*.jpg") as $filename) {
$file = str_replace('.jpg', '', $filename );
$rotate = mt_rand(-5, 5);
exec("convert $filename -background none -rotate $rotate $file.miff");
$deviation = exec("convert $filename -format \"%[standard_deviation]\" info:");
//$deviation = exec("convert $filename -format \"%[fx:standard_deviation]\" info:");
echo "<img src=\"$filename\">".$deviation;
// Bridge below
if ( $deviation < '5800' ){
// small.jpg below
//if ( $deviation < '15700' ){
//if ( $deviation < '0.029' ){
$dim = exec("convert $file.miff -format \"%wx%h\" info:");
exec("convert -size $dim xc:none $file.miff");
}
}
// Delete tempory images
foreach (glob("*.jpg") as $filename) {
//unlink($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>0 ? $qty_x*($j)+$i : $i;
$offset_x= ( ($crop_x * $i ) + mt_rand(-1, 1));
$offset_y=( ($crop_y * $j ) + mt_rand(-1, 1));
$command .= " image-$n.miff -geometry +$offset_x+$offset_y -composite" ; }
}
// Produce the combined image
exec( "convert -size {$width}x{$height} xc:none $command -trim combined.png");
// Delete tempory images
foreach (glob("*.miff") as $filename) {
unlink($filename);
}
?>
<br><br>
<img src="combined.png">