在 CodeIgniter 中调整 PNG 的大小,同时保留透明度

Posted

技术标签:

【中文标题】在 CodeIgniter 中调整 PNG 的大小,同时保留透明度【英文标题】:Resizing PNG in CodeIgniter while preserving the transparency 【发布时间】:2011-06-18 20:20:47 【问题描述】:

我正在使用此代码在 CodeIgniter 中调整图像大小

$config['image_library'] = 'gd2';
$config['source_image'] = $tempFile;
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['width'] = 70 / $ratio;
$config['height'] = 70;
$config['thumb_marker'] = '';
$this->load->library('image_lib', $config);
$this->image_lib->resize();

但是当我上传 png 文件时,透明区域变黑了。 我需要使调整大小的图像透明。请帮帮我。

【问题讨论】:

【参考方案1】:

谷歌的三个第一结果: http://www.akemapa.com/2008/07/10/php-gd-resize-transparent-image-png-gif/ http://www.phpfreaks.com/forums/index.php?topic=232090.0 How to preserve transparency when resizing PNG using Perl and GD

特定于 CI: http://codeigniter.com/forums/viewthread/62955/

【讨论】:

这样画质变差了,有什么解决办法吗?【参考方案2】:

自 CI 移动后,上述链接已失效。新链接在这里: http://forum.codeigniter.com/thread-7857.html

【讨论】:

以上是关于在 CodeIgniter 中调整 PNG 的大小,同时保留透明度的主要内容,如果未能解决你的问题,请参考以下文章