【发布时间】:2017-01-19 17:01:16
【问题描述】:
我在简单的基本 PHP 图像调整大小时遇到了问题。
我使用 AJAX 调用在 POST 中传递我的图像..
这是我的 PHP 代码:
//resize original image
switch ($type) {
case "desktop":
$width = 1920;
$height = 1080;
break;
case "mobile":
$width = 640;
$height = 1080;
break;
}
print_r("start resize");
print_r('<br>');
$size = getimagesize($url);
$img_origX = imagesx($img_orig);
$img_origY = imagesy($img_orig);
//height (Auto calculate)
//$height = round($width*$size[1]/$size[0]);
$img = imagecreatetruecolor($width, $height);
imagecopyresampled($img, $img_orig, 0, 0, 0, 0, $width, $height, $img_origX, $img_origY);
// Output
header('Content-type: image/jpg');
imagejpeg($img , "thumbnail.jpg");
$imageData = fopen("thumbnail.jpg", "r");
print_r("resize ok");
print_r('<br>');
问题是在网络中我从来没有收到“resize ok”,出了点问题..
顺序是否正确?
【问题讨论】:
-
使用 error_log 将信息转储到错误日志中。这行不通
-
您的图片是否成功调整大小?
标签: javascript php image resize