PHP 버전이 낮아 imagerotate() 함수가 없을때 대신 사용하는 함수
--------------------------------------
그누보드4에서 모바일 파일첨부시 세로사진이 옆으로 누워버리길래..
찾다가 기존에 쓰는 방법인 imagerotate()함수가 php버전이 낮으면 작동이 안되고 찾을수 없다고 나온다..
그래서 열심히 구글링 후 다른 방법을 찾았기에.. 여기에 남김..
중복이면 죄송.
--------------------------------------
function rotateImage($img, $rotation) {
$width = imagesx($img);
$height = imagesy($img);
switch($rotation) {
case 90: $newimg= @imagecreatetruecolor($height , $width );break;
case 180: $newimg= @imagecreatetruecolor($width , $height );break;
case 270: $newimg= @imagecreatetruecolor($height , $width );break;
case 0: return $img;break;
case 360: return $img;break;
}
if($newimg) {
for($i = 0;$i < $width ; $i++) {
for($j = 0;$j < $height ; $j++) {
$reference = imagecolorat($img,$i,$j);
switch($rotation) {
case 90: if(!@imagesetpixel($newimg, $j, $width - $i, $reference )){return false;}break;
case 180: if(!@imagesetpixel($newimg, $width - $i, ($height - 1) - $j, $reference )){return false;}break;
case 270: if(!@imagesetpixel($newimg, ($height - 1) - $j, $i, $reference )){return false;}break;
}
}
} return $newimg;
}
return false;
}
게시판 목록
팁게시판
질문은 상단의 QA에서 해주시기 바랍니다.
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 6002 | 9년 전 | 197 | ||
| 6001 | 9년 전 | 174 | ||
| 6000 | 9년 전 | 219 | ||
| 5999 | 9년 전 | 153 | ||
| 5998 | 9년 전 | 197 | ||
| 5997 | 9년 전 | 225 | ||
| 5996 | 9년 전 | 185 | ||
| 5995 | 9년 전 | 237 | ||
| 5994 | 9년 전 | 186 | ||
| 5993 | 9년 전 | 256 | ||
| 5992 | 9년 전 | 338 | ||
| 5991 | 9년 전 | 349 | ||
| 5990 | 9년 전 | 287 | ||
| 5989 | 9년 전 | 278 | ||
| 5988 | 9년 전 | 279 | ||
| 5987 | 9년 전 | 232 | ||
| 5986 | 9년 전 | 263 | ||
| 5985 | 9년 전 | 227 | ||
| 5984 | 9년 전 | 194 | ||
| 5983 | 9년 전 | 189 | ||
| 5982 | 9년 전 | 243 | ||
| 5981 | 9년 전 | 293 | ||
| 5980 | 9년 전 | 244 | ||
| 5979 | 9년 전 | 254 | ||
| 5978 | 9년 전 | 234 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기