创建缩略图时如何删除黑色背景颜色
当我在 codeigniter 中创建缩略图时,我得到一个具有黑色背景颜色的图像。
为什么会发生这样的事? 这是控制器中的代码:
$this->load->library('image_lib');
$config['image_library'] = 'gd2';
$config['source_image'] = $file ;
$config['maintain_ratio'] = FALSE;
$this->image_lib->initialize($config);
$this->md_image->resize_image('./images/logo_images/'.$filename,380,80,'./images/logo_images/thumbs/'.$filename);
When I am creating thumbnail in codeigniter I get an image with black background color.
Why did it happen?
This is the code in controller:
$this->load->library('image_lib');
$config['image_library'] = 'gd2';
$config['source_image'] = $file ;
$config['maintain_ratio'] = FALSE;
$this->image_lib->initialize($config);
$this->md_image->resize_image('./images/logo_images/'.$filename,380,80,'./images/logo_images/thumbs/'.$filename);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个 PHP 和 GD2 问题,并且在 CodeIgniter 的 Image Lib 中没有考虑到。
请参阅 PHP 手册,以便能够在调整大小时保持透明度:
http: //www.php.net/manual/en/function.imagecolortransparent.php
It is a PHP and GD2 problem, and not taken into account in the Image Lib in CodeIgniter.
Have a look here in the PHP manual to be able to keep transparency on resize :
http://www.php.net/manual/en/function.imagecolortransparent.php
Stéph