이미지 업로드 하고 나서 사이즈 변경하는 코드인데 문제가 있습니다

이미지 업로드 하고 나서 사이즈 변경하는 코드인데 문제가 있습니다

QA

이미지 업로드 하고 나서 사이즈 변경하는 코드인데 문제가 있습니다

답변 1

본문

아래 코드로 업로드 한 이미지 사이즈를 변경하면 사진이 90도 돌아가지는데 어떻게 하면될까요??

//파라미터(원본이미지, 바뀔이미지, 화질 (0 ~100) , 사이즈 width, height)
//파일 업로드 완료됐다라는 가정하에 진행 (move_uploaded_file)

$source_img		= $file_path."/".$file_nm1; //업로드 된 이미지
$destination_img = $file_path."/"."64_".$file_nm1; //앞에 64_ 를 붙히고 저장
            
compress($source_img, $destination_img , 90, 64,64);
// 파일 사이즈 및 용량 변경
function compress($file, $destination, $quality, $w, $h) {

    $info = getimagesize($file);

    $width = $info[0];
    $height = $info[1];

    if ($info['mime'] == 'image/jpeg') 
        $image = imagecreatefromjpeg($file);

    elseif ($info['mime'] == 'image/gif') 
        $image = imagecreatefromgif($file);

    elseif ($info['mime'] == 'image/png') 
        $image = imagecreatefrompng($file);

    $dst = imagecreatetruecolor($w, $h);
    imagecopyresampled($dst, $image, 0, 0, 0, 0, $w, $h, $width, $height);
    $result = imagejpeg($dst, $destination, $quality);

	return $result;
}

 

 

이 질문에 댓글 쓰기 :

답변 1

답변을 작성하시기 전에 로그인 해주세요.
QA 내용 검색
질문등록
전체 794
© SIRSOFT
현재 페이지 제일 처음으로