Changeset 23444
- Timestamp:
- 2014/05/26 18:38:07 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_13-dev/data/module/gdthumb.php
r20628 r23444 231 231 232 232 $src_im = imageCreateFromPNG($path); 233 234 $colortransparent = imagecolortransparent($src_im); 235 if ($colortransparent > -1) { 236 $dst_im = $imagecreate($re_size[0], $re_size[1]); 237 imagepalettecopy($dst_im, $src_im); 238 imagefill($dst_im, 0, 0, $colortransparent); 239 imagecolortransparent($dst_im, $colortransparent); 240 imagecopyresized($dst_im,$src_im, 0, 0, 0, 0, $re_size[0], $re_size[1], $size[0], $size[1]); 241 } else { 242 $dst_im = $imagecreate($re_size[0], $re_size[1]); 243 imagecopyresized($dst_im,$src_im, 0, 0, 0, 0, $re_size[0], $re_size[1], $size[0], $size[1]); 244 245 (imagecolorstotal($src_im) == 0) ? $colortotal = 65536 : $colortotal = imagecolorstotal($src_im); 246 247 imagetruecolortopalette($dst_im, true, $colortotal); 248 } 233 $colortransparent = imagecolortransparent($src_im); 234 $has_alpha = ord(file_get_contents($path, false, null, 25, 1)) & 0x04; 235 if ($colortransparent > -1 || $has_alpha) { 236 $dst_im = $imagecreate($re_size[0], $re_size[1]); 237 // アルファチャンネルが存在する場合はそちらを使用する 238 if ($has_alpha) { 239 imagealphablending($dst_im, false); 240 imagesavealpha($dst_im, true); 241 } 242 imagepalettecopy($dst_im, $src_im); 243 imagefill($dst_im, 0, 0, $colortransparent); 244 imagecolortransparent($dst_im, $colortransparent); 245 imagecopyresized($dst_im,$src_im, 0, 0, 0, 0, $re_size[0], $re_size[1], $size[0], $size[1]); 246 } else { 247 $dst_im = $imagecreate($re_size[0], $re_size[1]); 248 imagecopyresized($dst_im,$src_im, 0, 0, 0, 0, $re_size[0], $re_size[1], $size[0], $size[1]); 249 250 (imagecolorstotal($src_im) == 0) ? $colortotal = 65536 : $colortotal = imagecolorstotal($src_im); 251 252 imagetruecolortopalette($dst_im, true, $colortotal); 253 } 249 254 250 255 // 画像出力
Note: See TracChangeset
for help on using the changeset viewer.