开发者

problem in creating thumb picture in php

开发者 https://www.devze.com 2023-03-10 18:34 出处:网络
I am using following function to create thumb picture in php function createThumbnail($img,$imgPath,$newPath,$newWidth,$newHeight,$quality)

I am using following function to create thumb picture in php

function createThumbnail($img,$imgPath,$newPath,$newWidth,$newHeight,$quality)
{
    $path=$imgPath."/".$img;
    echo $pa开发者_运维百科th;
    $original = imagecreatefromjpeg($path);

    if($original)
    {
        echo "occur1";
        list($width, $height, $type, $attr) = getimagesize("$imgPath/$img");
        $tempImg = imagecreatetruecolor($newWidth, $newHeight) or die("Cant create temp image");
        imagecopyresized($tempImg, $original, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height)        or die("Cant resize copy");
        imagejpeg($tempImg, "$newPath/$img", $quality) or die("Cant save image");

        // Clean up.
        imagedestroy($original);
        imagedestroy($tempImg);
        return true;
    }
    else
    {
        echo "oc";
        return false;
    }
}

when calling this function it showing black screen.i am displaying echo statement before and after

$original = imagecreatefromjpeg($path);

it shows only first echo statement second echo statement not displaying.What is the problem.


Try using if (file_exists($path)) echo 'file exists!'; just after the echo $path; line.

//edit:

So it exists, does if (function_exists('imagecreatefromjpeg')) echo 'function exists'; also echo something?

Otherwise it could be a problem with right filetype or something I read on http://php.net/manual/en/function.imagecreatefromjpeg.php, it says that certain canon powershots let this function crash.

Also, is your error reporting on? Try adding ini_set('display_errors', 1); error_reporting(E_ALL); to the beginning of the script.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号