gd-jpeg do not work properly

eXciTer

New member
Joined
Nov 20, 2009
Messages
3
Location
Belarus
After updating to custombuild1.1 phpinfo() prints about gd:
Code:
GD Support     enabled
GD Version     bundled (2.0.34 compatible)
FreeType Support     enabled
FreeType Linkage     with freetype
FreeType Version     2.3.11
GIF Read Support     enabled
GIF Create Support     enabled
JPG Support     enabled
PNG Support     enabled
WBMP Support     enabled
XBM Support     enabled
But when i try to work with .jpg-files (any .jpg file, i've test that) I see:
Code:
Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: gd-jpeg: JPEG library reports unrecoverable error: in /home/blablabla/domains/blablabla/public_html/test.php on line 23

Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: '/home/blablabla/domains/blablabla/public_html/uploads/blablabla.jpg' is not a valid JPEG file in /home/blablabla/domains/blablabla/public_html/test.php on line 23
(pathes in example are fake, but in fact they are absolutely correct)

Rebuilding libjpeg didn't bring a success.

For any case, there is my example code wich brings an error in output:
Code:
<?php
$sFileFullPath = "/home/blablabla/domains/blablabla/public_html/uploads/";
if (isset($_FILES['image']) and move_uploaded_file($_FILES['image']['tmp_name'],$sFileFullPath.$_FILES['image']['name'])){
    if (!($aSize=getimagesize($sFileFullPath.$_FILES['image']['name']))) {        
        return false;
    }    
    $img_src=false;
    switch ($aSize['mime']) {
        case 'image/png':
            $img_src=imagecreatefrompng($sFileFullPath.$_FILES['image']['name']);
            break;
        case 'image/gif':
            $img_src=imagecreatefromgif($sFileFullPath.$_FILES['image']['name']);
            break;
        case 'image/jpeg':
            $img_src=imagecreatefromjpeg($sFileFullPath.$_FILES['image']['name']);
            break;
        default:
            return false;
            break;
    }
    $img_dest=imagecreatetruecolor(100,100);        
    if (imagecopyresampled($img_dest,$img_src,0,0,0,0,100,100,$aSize[0],$aSize[1])) {                
            imagedestroy($img_src);
            switch ($aSize['mime']) {
                case 'image/png':
                    if (imagepng($img_dest,$sFileFullPath)) {
                        chmod($sFileFullPath,0666);
                        return;
                    }
                    break;
                case 'image/gif':
                    if (imagegif($img_dest,$sFileFullPath)) {
                        chmod($sFileFullPath,0666);
                        return;
                    }
                    break;
                case 'image/jpeg':
                    if (imagejpeg($img_dest,$sFileFullPath)) {
                        chmod($sFileFullPath,0666);
                        return;
                    }
                    break;
            }
    }
}
?>
 
gd jpeg do not work properly

Did yo implement the transaction in your program ?

Is it possible to see the code ?

PS: Quite often, when I break down the code that doesnt work to post it, I find my solution, who knows....
 
The problem hides in gd wich was installed via ports (FreeBSD 6.x).
Removing it with all dependencies and rebuilding custombuild resolved all my problems =)
 
Back
Top