使用 GD 和 php 制作缩略图会返回内部服务器错误
我正在使用 GD 根据我的 php 网站上的要求制作缩略图,但每当我运行该函数时:
include('resize-class.php');
function getThumbnail($album,$name){
if ($name != ""){
$file = dirname(__FILE__).'/pics/'.$album.'/'.$name.'.jpg';
$thumb = substr($file,0,-4).'-thumb.jpg';
if (!file_exists($thumb)){
$newThumb = new resize($file);
$newThumb -> resizeImage(100,100,"crop");
$newThumb -> saveImage($thumb);
}
$thumbi = pathinfo($thumb);
$thumb = '<img src="pics/'.$album.'/'.$thumbi['basename'].'" />';
}else{
$thumb = "";
}
return $thumb;
}
其中 resize-class.php
是本教程中使用的代码片段: http://net.tutsplus.com/tutorials/ php/image-resizing-made-easy-with-php/
Cherokee 错误日志出现以下错误:
[25/12/2010 00:16:30.759] (error) handler_fcgi.c:83 - Parsing error: unknown version
并且创建了一个空的 jpeg,并且脚本的其余部分完成了(因此用户看到的是损坏的图像图标,而不是所需的缩略图)。该脚本在我使用 Abyss Web 服务器的 Windows 机器上运行良好,但当我使用 cherokee 和 php-cgi 在 Debian 上运行它时,它不起作用。我确保在 /etc/php5/cgi/ 和 /etc/php5/cli/ 的 php.ini 中设置了 extension=gd.so
。
phpinfo()
显示 GD 模块已加载,但除此之外我不知道为什么它不起作用。您可以在此处查看phpinfo()
I am using GD to make thumbnails as required on my php site, but whenever I run the function:
include('resize-class.php');
function getThumbnail($album,$name){
if ($name != ""){
$file = dirname(__FILE__).'/pics/'.$album.'/'.$name.'.jpg';
$thumb = substr($file,0,-4).'-thumb.jpg';
if (!file_exists($thumb)){
$newThumb = new resize($file);
$newThumb -> resizeImage(100,100,"crop");
$newThumb -> saveImage($thumb);
}
$thumbi = pathinfo($thumb);
$thumb = '<img src="pics/'.$album.'/'.$thumbi['basename'].'" />';
}else{
$thumb = "";
}
return $thumb;
}
Where resize-class.php
is the snippet used in this tutorial:
http://net.tutsplus.com/tutorials/php/image-resizing-made-easy-with-php/
Cherokee error log gets the following error:
[25/12/2010 00:16:30.759] (error) handler_fcgi.c:83 - Parsing error: unknown version
And an empty jpeg is created and the rest of the script completes (so the user sees a broken image icon instead of the desired thumbnail). The script worked fine on my windows machine using Abyss web server but when I ran it on Debian using cherokee and php-cgi it didn't work. And I made sure that extension=gd.so
is set in php.ini
in /etc/php5/cgi/ and /etc/php5/cli/.
phpinfo()
shows that the GD module is loaded, but otherwise I don't know why it isn't working. You can view the phpinfo() here
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对错误消息进行快速 Google 搜索表明,类似的错误是由 Cherokee 更新引起的,重新启动即可修复该错误。也许重新启动整个机器会起作用?否则,代码中没有任何无效内容,并且您有一个非常新版本的 PHP - 并且由于 hte 脚本的其余部分已完成,因此肯定是某个地方存在配置问题。
A quick Google search on the error message suggested that a similar error was caused by a Cherokee update and a restart fixed it. Perhaps restarting the whole machine would work? Otherwise there isn't anything invalid with the code and you have a very new version of PHP - and since the rest of hte script completes, definitely a configuration issue somewhere.