Sure thing, here's the part of the script that deals with ImageMagick, assume that $image_name is set to an image that exists (which in my case it is, I can echo $image_name within an <img> and get a picture)
Code: Select all
// check if resized image already exists
$cache = "$cache_path/$image_name";
//echo "$image_name<br />$cache";
if (!file_exists($cache)) {
// there is no cached image yet, so we'll need to create it first
$source_image = $image_name;
$target_image = $cache;
list ($resized_width,$resized_height) = get_resized_width_height($image_size);
//echo "$resized_height/$resized_width<br />";
$imginfo = getimagesize($source_image);
$orig_width = $imginfo[0];
$orig_height = $imginfo[1];
if (($orig_width/$resized_width) > ($orig_height/$resized_height)){
$ratio = $orig_height/$resized_height;
}else{
$ratio = $orig_width/$resized_width;
}
//echo "$resized_height/$resized_width<br />";
$new_width = $orig_width/$ratio;
$new_height = $orig_height/$ratio;
$top = round(($new_height - $resized_height)/2);
$left = round(($new_width - $resized_width)/2);
if ($top == "-0"){
$top = 0;
}
if ($left == "-0"){
$left = 0;
}
$crop_command = ("-crop $resized_width"."x"."$resized_height+$left+$top"); // remove excess from left and right
$resize_command = ("-resize ".(100/$ratio)."%");
$command = "$resize_command $crop_command";
$command = "$resize_command";
//exit ($command);
$convert = $convert_path.' "'.$source_image.'" '.$command.' "'.$target_image.'"';
//exit($convert);
ob_start();
system($convert);
ob_end_clean();
}
// there should be a file named $cache now
//echo '<img src="'.$cache.'" />';
if (!file_exists($cache)) {
die('Image conversion failed.');
}
When this runs through, I get 'Image conversion failed', but no other errors (display_errors is set to 'on')
The directory permissions are 755 for the cache directory.
The bizarre thing is that the site already had an image.php file that seemingly worked perfectly - I took a copy of this and added in some extra database reading stuff, and this seems to be where things have gone awry.