PHP GD 创建左上角带有一个黑色像素的缩略图
警告:我对 CodeIgniter 没有太多经验,并且我正在更新最初由其他开发人员创建的网站。
由于某种原因,CodeIgniter 图像类正在创建左上角带有黑色像素的缩略图。下面是一个示例:
替代文本 http://jnjnjn.com/images/codeigniter_bad_thumb.jpg
这似乎只发生在生产中(该网站托管在超级蹩脚的共享主机上)。缩略图在我的 OS X 开发机器和 Slicehost 上的 Ubuntu 机器上创建得很好。
代码是相当样板的,据我所知,图像库没有太多可以搞砸的选项。
选项如下所示:
$this->Image_Resize['image_library'] = 'gd2';
$this->Image_Resize['thumb_marker'] = 'thumb_';
$this->Image_Resize['create_thumb'] = TRUE;
$this->Image_Resize['maintain_ratio'] = TRUE;
$this->Image_Resize['width'] = 200;
$this->Image_Resize['height'] = 200;
然后图像处理如下:
$this->Image_Resize['source_image'] = 'images/news/'.$image['file_name'];
$this->image_lib->initialize($this->Image_Resize);
$this->image_lib->resize();
以前有人遇到过这个问题吗?谷歌和所以搜索并没有让我到任何地方。这些像素让我发疯。
更新:正如我担心的那样,这与 CodeIgniter 没有任何关系。主机的 GD 库出了点问题,他们不支持其他任何东西。奇怪的是我在世界上找不到其他人遇到过这个问题。
无论如何,我的建议是永远、永远、永远不要使用 Doteasy。他们是一场噩梦。
Warning: I don't have much experience with CodeIgniter and I am updating a site originally created by another developer.
For some reason the CodeIgniter image class is creating thumbnails with a black pixel in the top left corner. Here is an example:
alt text http://jnjnjn.com/images/codeigniter_bad_thumb.jpg
This only seems to happen in production (this site is being hosted on a super lame shared host). Thumbnails are created just fine on my OS X dev machine and my Ubuntu machine on Slicehost.
The code is pretty boilerplate, and from what I can tell the image library doesn't have a whole lot of options to screw up.
The options look like this:
$this->Image_Resize['image_library'] = 'gd2';
$this->Image_Resize['thumb_marker'] = 'thumb_';
$this->Image_Resize['create_thumb'] = TRUE;
$this->Image_Resize['maintain_ratio'] = TRUE;
$this->Image_Resize['width'] = 200;
$this->Image_Resize['height'] = 200;
And then the image is processed like this:
$this->Image_Resize['source_image'] = 'images/news/'.$image['file_name'];
$this->image_lib->initialize($this->Image_Resize);
$this->image_lib->resize();
Has anyone run into this issue before? Google & SO searches aren't getting me anywhere. These pixels are driving me nuts.
Update: As I was afraid, this didn't have anything to do with CodeIgniter. Something is screwy with the host's GD library and they don't support anything else. It's just weird that I can't find anyone else in the world who's had this problem.
Anyway my advice is to never, ever, ever use Doteasy. They are a nightmare.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果是主机造成的,则可能是他们的图像库有问题。 codeigniter Image Manipulation 类实际上只是在该级别之上进行抽象,因此您实际上可以选择要使用的图像库。了解您的主机提供了哪些可用的选项,也许可以尝试不同的选项,看看结果是否相同。 ['image_library'] 的可能选项有:
图像操作类 - Codeigniter 文档< /a>
If it's the host that's causing it, maybe it's their image library that's having problems. The codeigniter Image Manipulation class is really just abstracted above that level, so you can actually choose what image library to use. Find out what ones are available from your host and maybe try a different one and see if the results are the same. Possible options for the ['image_library'] are:
Image Manipulation Class - Codeigniter Documentation
我遇到了同样的问题,经过一番挖掘,这就是我针对我的情况提出的建议。我想如果有什么有用的东西我会与其他人分享。请记住,这是直接的 PHP,而不是代码点火器,但这是您进行 google 搜索时的第一个响应之一。
这似乎只发生在我使用 24 位透明 png 时,调整大小并使用图像卷积函数锐化时。一旦我注释掉应用卷积的代码部分,黑色像素就会消失。
I'm running into the same issue, and after some digging here's what I've come up with for my situation. I figured I would share it with everyone else incase there's something useful. Keep in mind, this is straight PHP not code ignitor, but this is one of the first responses when you do a google search.
This appears to only happen for me with a 24bit transparent png, when resized and then sharpened using imageconvolution function. As soon as I comment out the portion of code which is applying the convolution, the black pixel disappears.
我有同样的事情,似乎只发生在 PNG32 格式 - 尝试以 PNG24 或 PNG8 导出图像,看看这是否有帮助,对我有用。
I had the same thing, seems to happen only with PNG32 format - try exporting your image in PNG24 or PNG8 and see if that helps, worked for me.