php - Trying to keep transparency in png copyimage -
i trying keep transparency of image if there after gets resampled keep on coming black background? $image_copy new image , gets displayed afterwards.
$new_width = round($new_width, 0); $new_height = round($new_height, 0); $image_r = imagecreatetruecolor( $new_width, $new_height ); imagealphablending( $image_r, false ); imagesavealpha( $image_r, true ); imagecopyresampled( $image_r, $image, 0, 0, 0, 0, $new_width, $new_height, $image_width, $image_height); imagedestroy($image); if ($new_width > $width) $offset_width = ($new_width - $width) / 2; if ($new_height > $height) $offset_height = ($new_height - $height) / 2; $image_copy = imagecreatetruecolor($width, $height); imagecopy($image_copy, $image_r, 0, 0, $offset_width, $offset_height, $width, $height); imagedestroy($image_r); imagepng($image_copy,"{$filename}.png", 9) any great?
maybe want check link, hope helpful
Comments
Post a Comment