From 90a48abbec1eff28bafab0a6899e6c681ca6a1bd Mon Sep 17 00:00:00 2001 From: Shish Date: Fri, 22 Jan 2010 17:42:00 +0000 Subject: [PATCH] make convert.exe findable on windows --- ext/handle_pixel/main.php | 21 +++++++++++++++++++-- ext/image/main.php | 1 + 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/ext/handle_pixel/main.php b/ext/handle_pixel/main.php index 8c20274a..79aba5ee 100644 --- a/ext/handle_pixel/main.php +++ b/ext/handle_pixel/main.php @@ -74,8 +74,25 @@ class PixelFileHandler extends DataHandlerExtension { // convert to bitmap & back to strip metadata -- otherwise we // can end up with 3KB of jpg data and 200KB of misc extra... // "-limit memory $mem" broken? - exec("convert {$inname}[0] -geometry {$w}x{$h} -strip -quality {$q} jpg:$outname"); - #exec("convert {$inname}[0] -geometry {$w}x{$h} bmp:- | convert bmp:- -quality {$q} jpg:$outname"); + + // Windows is a special case, use what will work on most everything else first + if(in_array("OS", $_SERVER) && $_SERVER["OS"] != 'Windows_NT') { + $cmd = "convert {$inname}[0] -strip -thumbnail {$w}x{$h} jpg:$outname"; + } + else { + $imageMagick = $config->get_string("thumb_convert_path"); + + // running the call with cmd.exe requires quoting for our paths + $stringFormat = '"%s" "%s[0]" -strip -thumbnail %ux%u jpg:"%s"'; + + // Concat the command altogether + $cmd = sprintf($stringFormat, $imageMagick, $inname, $w, $h, $outname); + } + + // Execute IM's convert command, grab the output and return code it'll help debug it + exec($cmd, $output, $ret); + + log_debug('handle_pixel', "Generating thumnail with command `$cmd`, returns $ret"); return true; } diff --git a/ext/image/main.php b/ext/image/main.php index 643e5419..753cc348 100644 --- a/ext/image/main.php +++ b/ext/image/main.php @@ -95,6 +95,7 @@ class ImageIO extends SimpleExtension { $config->set_default_int('thumb_height', 192); $config->set_default_int('thumb_quality', 75); $config->set_default_int('thumb_mem_limit', parse_shorthand_int('8MB')); + $config->set_default_string('thumb_convert_path', 'convert.exe'); $config->set_default_bool('image_show_meta', false); $config->set_default_string('image_ilink', '');