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;
}
게시판 목록
토크
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 3091 | 9년 전 | 716 | ||
| 3090 |
|
9년 전 | 1348 | |
| 3089 | 9년 전 | 712 | ||
| 3088 | 9년 전 | 646 | ||
| 3087 | 9년 전 | 562 | ||
| 3086 | 9년 전 | 547 | ||
| 3085 | 9년 전 | 565 | ||
| 3084 | 9년 전 | 650 | ||
| 3083 | 9년 전 | 1040 | ||
| 3082 | 9년 전 | 686 | ||
| 3081 | 9년 전 | 956 | ||
| 3080 | 9년 전 | 1240 | ||
| 3079 | 9년 전 | 994 | ||
| 3078 | 9년 전 | 1950 | ||
| 3077 | 9년 전 | 1210 | ||
| 3076 | 9년 전 | 1092 | ||
| 3075 | 9년 전 | 1046 | ||
| 3074 | 9년 전 | 966 | ||
| 3073 | 9년 전 | 987 | ||
| 3072 |
|
9년 전 | 1218 | |
| 3071 |
|
9년 전 | 1404 | |
| 3070 |
|
9년 전 | 1380 | |
| 3069 |
|
9년 전 | 1630 | |
| 3068 |
|
9년 전 | 2015 | |
| 3067 | 9년 전 | 1315 | ||
| 3066 |
|
9년 전 | 1123 | |
| 3065 | 9년 전 | 1397 | ||
| 3064 |
brucelee1973
|
9년 전 | 2892 | |
| 3063 |
|
9년 전 | 1850 | |
| 3062 |
|
9년 전 | 728 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기