1
이미지 변환 기능을 만들고 있습니다. 예 : 파일 확장명이 변경되지 않았습니다. oldfile.png
out newfile.png
. 하지만 파일 변환 후 확장자를 변경해야합니다. newfile.jpg
맞습니까?Imagejpeg 기능이 파일 확장자를 변경하지 않습니다.
function convertimg($target, $new, $ext, $converto) {
if ($ext['mime'] == 'image/jpeg') {
$img = imagecreatefromjpeg($target);
} elseif ($ext['mime'] == 'image/png') {
$img = imagecreatefrompng($target);
} elseif ($ext['mime'] == 'image/gif') {
$img = imagecreatefromgif($target);
}
$ictc = imagecreatetruecolor($ext[0], $ext[1]);
imagecopyresampled($ictc, $img, 0, 0, 0, 0, $ext[0], $ext[1], $ext[0], $ext[1]);
ob_start();
header("Content-type: " . $converto);
if ($converto == 'image/jpeg') {
imagejpeg($ictc, $new, 84);
} elseif ($converto == 'image/png') {
imagepng($ictc, $new, 84);
} elseif ($converto == 'image/gif') {
imagegif($ictc, $new, 84);
}
ob_get_clean();
imagedestroy($ictc);
}
오, 그렇다면 이미지를 변환 할 때 확장을 지정해야합니다. 예 : '.jpg' 또는'.png'? – user3315433
@ user3315433 yes – baldrs
thnx, 나는 그 일을 잘했지만 문제는 내가'getimagesize()'로 다시 검사 할 때 여전히 jpg가 아닌 png 파일을 보여주는 것이다. 왜? – user3315433