【发布时间】:2019-02-14 18:15:51
【问题描述】:
我编写了以下代码来为 php 中的图像生成缩略图,它对某些图像工作正常,但在高分辨率/大尺寸图像的情况下它显示
此页面无法正常工作
问题。这里imagecreatefromjpeg() 不起作用。有什么解决办法请帮帮我..
function make_accused_thumb($src, $dest, $desired_width) {
/* read the source image */
//ini_set('gd.jpeg_ignore_warning', 1);
//echo $src;exit;
//echo $src;exit;
$source_image = @imagecreatefromjpeg($src);
echo $src;exit;
if (!$source_image)
{
$source_image= @imagecreatefromstring(file_get_contents($src));
}
$width = @imagesx($source_image);
$height = @imagesy($source_image);
/* find the "desired height" of this thumbnail, relative to the desired width */
$desired_height = @floor($height * ($desired_width / $width));
/* create a new, "virtual" image */
$virtual_image = @imagecreatetruecolor($desired_width, $desired_height);
/* copy source image at a resized size */
@imageCopyResized($virtual_image, $source_image, 0, 0, 0, 0, $desired_width, $desired_height, $width, $height);
/* create the physical thumbnail image to its destination */
@header('Content-Type: image/jpeg');
@imagejpeg($virtual_image, $dest);
}
【问题讨论】:
-
在您的服务器日志中,您可能会发现导致 500 错误的错误消息。
-
删除
exit;?还有,Laravel,Zend-Framework? -
它适用于其他图像,只要大尺寸图像(4mb,6mb)不起作用..服务器仅处于登录模式
-
控制不退出也显示此页面在更多尺寸图像的情况下无法正常工作
标签: php laravel zend-framework