我想从磁盘上传图片,调整大小,,然后将其上传到Amazon S3。imagejpeg()不能正确输出php
但是,我不能从imagejpeg()得到正确的图像输出。
继承人我的代码:
$sourceUrl = $_FILES['path']['tmp_name'];
$thumbWidth = '100';
$thumbid = uniqid();
$img = imagecreatefromjpeg($sourceUrl);
$width = imagesx($img);
$height = imagesy($img);
// calculate thumbnail size
$new_width = $thumbWidth;
$new_height = floor($height * ($thumbWidth/$width));
// create a new temporary image
$tmp_img = imagecreatetruecolor($new_width, $new_height);
// copy and resize old image into new image
imagecopyresampled($tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
// output the image
imagejpeg($tmp_img);
// upload thumbnail to s3
$s3->putObjectFile($tmp_img, "mybucket", $thumbid, S3::ACL_PUBLIC_READ);
萤火虫给我这个错误:
illegal character
[Break on this error] (�����JFIF���������>CREATOR: g...(using IJG JPEG v62), default quality\n
如果我修改imagejpeg这样,
imagejpeg($tmp_img, 'abc.jpg');
然后我得到了同样的错误。 :(
我能得到一些帮助,在这里请
您描述的第二种方法应该工作,JPG代码不应该输出。你100%确定它不?你在其他地方回应内容吗? – 2010-06-23 10:20:20