What is causing the imagecreatetruecolor () error?

I'm pretty sure my gdlib is enabled since the function imagecreafromjpeg()

precedes the part where I am calling imagecreatruecolor()

and no error is thrown from it
however the script breaks down to pieces (or rather fails with no error message and just returns false) where imagecreatruecolor()

...
how can i find the reason for the refusal?

if ($filetype=='jpg' || $filetype=='jpeg')
    $src_img = imagecreatefromjpeg($name);      
if ($filetype=='png')
    $src_img = imagecreatefrompng($name);       
if($src_img===false){ return false;}

$orig_w = imageSX($src_img);
$orig_h = imageSY($src_img);
$new_w = ($orig_w > $new_w) ? $new_w : $orig_w;
$new_h = ($orig_h > $new_h) ? $new_h : $orig_h;
$dst_img = imagecreatetruecolor($new_w,$new_h);

      

+2


source to share


2 answers


Create a phpinfo file to check your GD version. imagecreatetruecolor () is only available in version 2.0.1 or newer (they recommend 2.0.28).



Try " function_exists (" imagecreatetruecolor ") ".

0


source


There was the same problem. What I did was put error_report (E_ALL) before my imagecreatetruecolor and found it needed more memory. Just updated my php.ini to 256mb and it works fine now.



0


source







All Articles