gif 썸네일 생성 때 발생할 수 있는 오류 수정

This commit is contained in:
chicpro
2015-03-03 16:45:02 +09:00
parent dca1e67105
commit efe7855776

View File

@ -333,11 +333,14 @@ function thumbnail($filename, $source_path, $target_path, $thumb_width, $thumb_h
if($size[2] == 3) { if($size[2] == 3) {
imagealphablending($dst, false); imagealphablending($dst, false);
imagesavealpha($dst, true); imagesavealpha($dst, true);
} else if($size[2] == 1 && $src_transparency != -1) { } else if($size[2] == 1) {
$transparent_color = imagecolorsforindex($src, $src_transparency); $palletsize = imagecolorstotal($src);
$current_transparent = imagecolorallocate($dst, $transparent_color['red'], $transparent_color['green'], $transparent_color['blue']); if($src_transparency >= 0 && $src_transparency < $palletsize) {
imagefill($dst, 0, 0, $current_transparent); $transparent_color = imagecolorsforindex($src, $src_transparency);
imagecolortransparent($dst, $current_transparent); $current_transparent = imagecolorallocate($dst, $transparent_color['red'], $transparent_color['green'], $transparent_color['blue']);
imagefill($dst, 0, 0, $current_transparent);
imagecolortransparent($dst, $current_transparent);
}
} }
} else { } else {
$dst = imagecreatetruecolor($dst_w, $dst_h); $dst = imagecreatetruecolor($dst_w, $dst_h);
@ -367,7 +370,8 @@ function thumbnail($filename, $source_path, $target_path, $thumb_width, $thumb_h
imagealphablending($dst, false); imagealphablending($dst, false);
imagesavealpha($dst, true); imagesavealpha($dst, true);
} else if($size[2] == 1) { } else if($size[2] == 1) {
if($src_transparency != -1) { $palletsize = imagecolorstotal($src);
if($src_transparency >= 0 && $src_transparency < $palletsize) {
$transparent_color = imagecolorsforindex($src, $src_transparency); $transparent_color = imagecolorsforindex($src, $src_transparency);
$current_transparent = imagecolorallocate($dst, $transparent_color['red'], $transparent_color['green'], $transparent_color['blue']); $current_transparent = imagecolorallocate($dst, $transparent_color['red'], $transparent_color['green'], $transparent_color['blue']);
imagefill($dst, 0, 0, $current_transparent); imagefill($dst, 0, 0, $current_transparent);