在Codeigniter中生成png透明缩略图

CI中的CI_Image_lib类不能生成背景透明的png或gif缩略图,以下是我的解决办法,重新创建一个MY_Image_lib类,并继承CI_Image_lib类,然后重写一下image_process_gd方法。

先在CI_Image_lib中找到image_process_gd方法,然后把这个方法的全部代码复制到MY_Image_lib类中,然后查找下面这行代码:

$dst_img = $create($this->width, $this->height);

接着在找到的这行代码下面添加如下代码:

$transparent = imagecolortransparent($src_img, imagecolorallocate($src_img, 0, 0, 0));
if ($transparent >= 0) {
	imagecolortransparent($dst_img, $transparent);
	imagealphablending($dst_img, false);
	imagesavealpha($dst_img, true);
}
You can leave a response, or trackback from your own site.

Leave a Reply

:wink: :-| :-x :twisted: :) 8-O :( :roll: :-P :oops: :-o :mrgreen: :lol: :idea: :-D :evil: :cry: 8) :arrow: :-? :?: :!:
*

Powered by WordPress | Shop Free Cellular Phones at Bestincellphones.com. | Thanks to Best CD Rates, iCellPhoneDeals.com Offers Best Cell Phone Deals. and Incinerador De Grasa