Weedpacket;11010003 wrote:What is $img, seeing as you're completely covering the background with it? (Both source and background images are given as being w×h pixels, and the source image is being positioned with its top-left corner coinciding with the top-left corner of the background.)
Thank you for reply.
img is the orginal img created, maybe let me post the code.
actually I think that the problem is on crop image function. I check the resized image, and it is fine. However, after the image is cropped, it gives me a black background image. I have no idea why. 😕
function ak_img_thumb($target, $newcopy, $w, $h, $ext) {
list($w_orig, $h_orig) = getimagesize($target);
$src_x = ($w_orig / 2) - ($w / 2);
$src_y = ($h_orig / 2) - ($h / 2);
$ext = strtolower($ext);
$img = "";
if ($ext == "gif"){
$img = imagecreatefromgif($target);
} else if($ext =="png"){
$img = imagecreatefrompng($target);
} else {
$img = imagecreatefromjpeg($target);
}
$tci = imagecreatetruecolor($w, $h);
$bg = imagecolorallocate($tci, 255, 255, 255);
imagefill($tci, 0, 0, $bg);
imagecopyresampled($tci, $img, 0, 0, $src_x, $src_y, $w, $h, $w, $h);
if ($ext == "gif"){
imagegif($tci, $newcopy);
} else if($ext =="png"){
imagepng($tci, $newcopy);
} else {
imagejpeg($tci, $newcopy, 90);
}
}