PHP GD Gives Black Background On imagecropauto() Function

Viewed 161

checkout image here When there is bundle version of GD library on cpanel the code works fine. But when same code running on vestacp with GD 2.2.5 its generate the black background when using imagecropauto()

$datai = "data:image/png;base64,BAS64IMGSTRINGHERE";
$datai = str_replace("data:image/png;base64,","",$datai);

$datai = base64_decode($datai);
$im = imagecreatefromstring($datai);

//When i skip this function its working fine. 
$cropped = imagecropauto($im, IMG_CROP_DEFAULT);
if ($cropped !== false) { 
    imagedestroy($im);    
    $im = $cropped;       
}

imagesavealpha($im, true);
imagepng($im, "img-crop.png");
imagedestroy($im);

Hope you guys have solution. Thank you.

0 Answers
Related