Search code examples
phpgdcherokee

Using GD with php to make thumbnails returns an internal server error


I am using GD to make thumbnails as required on my php site, but whenever I run the function:

include('resize-class.php');
function getThumbnail($album,$name){
    if ($name != ""){
    $file = dirname(__FILE__).'/pics/'.$album.'/'.$name.'.jpg';
    $thumb = substr($file,0,-4).'-thumb.jpg';
    if (!file_exists($thumb)){
        $newThumb = new resize($file);
        $newThumb -> resizeImage(100,100,"crop");
        $newThumb -> saveImage($thumb);
    }
    $thumbi = pathinfo($thumb);
    $thumb = '<img src="pics/'.$album.'/'.$thumbi['basename'].'" />';
    }else{
        $thumb = "";
    }
    return $thumb;
}

Where resize-class.php is the snippet used in this tutorial: http://net.tutsplus.com/tutorials/php/image-resizing-made-easy-with-php/

Cherokee error log gets the following error:

[25/12/2010 00:16:30.759] (error) handler_fcgi.c:83 - Parsing error: unknown version

And an empty jpeg is created and the rest of the script completes (so the user sees a broken image icon instead of the desired thumbnail). The script worked fine on my windows machine using Abyss web server but when I ran it on Debian using cherokee and php-cgi it didn't work. And I made sure that extension=gd.so is set in php.ini in /etc/php5/cgi/ and /etc/php5/cli/.

phpinfo() shows that the GD module is loaded, but otherwise I don't know why it isn't working. You can view the phpinfo() here


Solution

  • A quick Google search on the error message suggested that a similar error was caused by a Cherokee update and a restart fixed it. Perhaps restarting the whole machine would work? Otherwise there isn't anything invalid with the code and you have a very new version of PHP - and since the rest of hte script completes, definitely a configuration issue somewhere.