OS: Microsoft Windows XP Professional Version 2002 Service Pack 2 & Service Pack 3
Webserver: Apache httpd 2.2.17 & 2.2.19 (Apache.org win32 VC6 builds)
PHP: 5.2.4 & 5.2.17
I use some crappy old XP Pro SP2 machine as a webserver. ImageMagick thumbnails weren't working in my new Shimmie install, even though they are still working in my outdated install. I did some debugging (tested 2.3.1 & git trunk).
I wanted to check the parameters sent to convert.exe. I found it (line 98), outputted it to .bat and found it executed perfectly through the command prompt, resulting in a thumbnail. The syntax is valid, wtf? After tweaking around with the section, I found that convert wouldn't execute through exec() on my machine unless "convert" was entered without surrounding quotes.
Examples:
$cmd is "convert" "images/84/8434054aae547c4882941613956c0ad6[0]" -crop 461x700 +repage -flatten -strip -thumbnail 192x192 jpg:"thumbs/84/8434054aae547c4882941613956c0ad6" -- No thumbnail
$cmd is "convert.exe" "images/84/8434054aae547c4882941613956c0ad6[0]" -crop 461x700 +repage -flatten -strip -thumbnail 192x192 jpg:"thumbs/84/8434054aae547c4882941613956c0ad6" -- No thumbnail
$cmd is convert "images/84/8434054aae547c4882941613956c0ad6[0]" -crop 461x700 +repage -flatten -strip -thumbnail 192x192 jpg:"thumbs/84/8434054aae547c4882941613956c0ad6" -- A wild thumbnail appears!
$cmd is convert.exe "images/84/8434054aae547c4882941613956c0ad6[0]" -crop 461x700 +repage -flatten -strip -thumbnail 192x192 jpg:"thumbs/84/8434054aae547c4882941613956c0ad6" -- Also works
In the meantime I've added a string replace below sprintf to unquote convert.
$cmd = sprintf($format, $convert, $inname, $size[0], $size[1], $w, $h, $outname);
$cmd = str_replace(""convert"", "convert", $cmd);
It works perfectly after that.
Oh, and I'm not sure if my OS is supposed to fail this check, but it does:
if(in_array("OS", $_SERVER) && $_SERVER["OS"] == 'Windows_NT')
The default thumb_convert_path if I did pass it, convert.exe, would still fail because of the quotes added later..
The strange thing is that if I add quotes around convert in my old Shimmie install, it executes fine:
exec("convert {$inname}[0] -geometry {$w}x{$h} -quality {$q} jpg:$outname"); -- Original, works
exec(""convert" {$inname}[0] -geometry {$w}x{$h} -quality {$q} jpg:$outname"); -- This also works
Is PHP being stupid?
If PHP is at fault, it's unfortunate that it occurs in the last release of 5.2. 5.3.5 (VC6) and 5.3.6 (VC9) appear to break Shimmie entirely.