디스크에서 이미지를 업로드하려면 크기를 조정하고을 다운로드 한 다음 Amazon S3에 업로드하십시오.imagejpeg()가 PHP에서 출력을 올바르게 제공하지 않습니다.
그러나 imagejpeg()에서 적절한 이미지 출력을 얻을 수 없습니다.
을 heres 내 코드 :
$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 % 확실하지 않니? 다른 곳에서 내용을 반향하고 있습니까? –