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;
}
게시판 목록
토크
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 3030 | 9년 전 | 1657 | ||
| 3029 |
프로그래머7
|
9년 전 | 1344 | |
| 3028 | 9년 전 | 953 | ||
| 3027 |
ssir1159
|
9년 전 | 1604 | |
| 3026 | 9년 전 | 1562 | ||
| 3025 |
프로그래머7
|
9년 전 | 1255 | |
| 3024 | 9년 전 | 914 | ||
| 3023 |
|
9년 전 | 1131 | |
| 3022 | 9년 전 | 1114 | ||
| 3021 | 9년 전 | 769 | ||
| 3020 | 9년 전 | 1287 | ||
| 3019 | 9년 전 | 1457 | ||
| 3018 | 9년 전 | 1082 | ||
| 3017 | 9년 전 | 987 | ||
| 3016 | 9년 전 | 1383 | ||
| 3015 |
헤이하치대머리
|
9년 전 | 1055 | |
| 3014 | 10년 전 | 2342 | ||
| 3013 |
클리어픽스
|
10년 전 | 2308 | |
| 3012 | 10년 전 | 2117 | ||
| 3011 | 10년 전 | 2950 | ||
| 3010 |
|
10년 전 | 2951 | |
| 3009 |
|
10년 전 | 3164 | |
| 3008 |
|
10년 전 | 3385 | |
| 3007 |
|
10년 전 | 4107 | |
| 3006 |
하얼빈소년
|
10년 전 | 2609 | |
| 3005 |
작은것에충성
|
10년 전 | 5232 | |
| 3004 |
작은것에충성
|
10년 전 | 3894 | |
| 3003 |
작은것에충성
|
10년 전 | 3411 | |
| 3002 | 10년 전 | 3362 | ||
| 3001 |
|
10년 전 | 2099 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기