Chris-2k
07-27-2012, 04:46 PM
Hi
hope some one can help me fix, here is how i call it:
create_thumb($aConfig, $files, $new_name, $thumbDir .'/'. $album_id .'/');
and here's the func:
function create_thumb(array $aConfig, $image_file, $name, $thumbDir) {
$iDimension = getimagesize($image_file);
$type = $iDimension[2];
echo 'Type: '. $type;
if ($type == "image/jpeg") { $tempThumb = imagecreatefromjpeg($image_file); }
elseif ($type == "image/bmp") { $tempThumb = imagecreatefromwbmp($image_file); }
elseif($type == "image/png") { $tempThumb = imagecreatefrompng($image_file); }
elseif ($type == "image/gif") { $tempThumb = imagecreatefromgif($image_file); }
$width = $iDimension[0]; // uploaded image width
$height = $iDimension[1]; // uploaded image height
$ratio = $width / $height; // calculate the ratio
if ($ratio > 1 ) {
$newW = $aConfig['custom_pixels'];
$newH = $aConfig['custom_pixels'] / $ratio;
} else {
$newH = $aConfig['custom_pixels'];
$newW = $aConfig['custom_pixels'] * $ratio;
}
$thumb = imagecreatetruecolor($newW, $newH);
//the resizing is going on here!
imagecopyresampled($thumb, $tempThumb, 0, 0, 0, 0, $newW, $newH, $width, $height);
//finally, save the image
imagejpeg($thumb, $thumbDir .'/thumb_' . $name);
// clean up
imagedestroy($thumb);
imagedestroy($tempThumb);
}
I don't see the problem, any help............
Thanks.
hope some one can help me fix, here is how i call it:
create_thumb($aConfig, $files, $new_name, $thumbDir .'/'. $album_id .'/');
and here's the func:
function create_thumb(array $aConfig, $image_file, $name, $thumbDir) {
$iDimension = getimagesize($image_file);
$type = $iDimension[2];
echo 'Type: '. $type;
if ($type == "image/jpeg") { $tempThumb = imagecreatefromjpeg($image_file); }
elseif ($type == "image/bmp") { $tempThumb = imagecreatefromwbmp($image_file); }
elseif($type == "image/png") { $tempThumb = imagecreatefrompng($image_file); }
elseif ($type == "image/gif") { $tempThumb = imagecreatefromgif($image_file); }
$width = $iDimension[0]; // uploaded image width
$height = $iDimension[1]; // uploaded image height
$ratio = $width / $height; // calculate the ratio
if ($ratio > 1 ) {
$newW = $aConfig['custom_pixels'];
$newH = $aConfig['custom_pixels'] / $ratio;
} else {
$newH = $aConfig['custom_pixels'];
$newW = $aConfig['custom_pixels'] * $ratio;
}
$thumb = imagecreatetruecolor($newW, $newH);
//the resizing is going on here!
imagecopyresampled($thumb, $tempThumb, 0, 0, 0, 0, $newW, $newH, $width, $height);
//finally, save the image
imagejpeg($thumb, $thumbDir .'/thumb_' . $name);
// clean up
imagedestroy($thumb);
imagedestroy($tempThumb);
}
I don't see the problem, any help............
Thanks.