뿌

PHP 버전이 낮아 imagerotate() 함수가 없을때 대신 사용하는 함수

· 2016-03-17 (목) 10:29:25 · 3050

--------------------------------------

그누보드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;
 }

|
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

8,188건
+
제목 글쓴이 날짜 조회
16-07-13 조회 2,157
16-07-12 조회 2,320
16-07-12 조회 2,347
16-07-11 조회 2,180
16-06-05 조회 2,885
16-06-03 조회 2,997
16-05-26 조회 2,916
15-09-22 조회 4,963
15-06-10 조회 4,805
14-10-25 조회 6,339
14-10-22 조회 8,964
14-09-21 조회 5,768
14-09-16 조회 5,050
14-08-22 조회 1.1만
14-08-13 조회 5,881
14-08-12 조회 5,419
14-08-12 조회 6,273
14-08-11 조회 6,906
14-06-12 조회 6,182
14-06-11 조회 5,086
14-05-09 조회 5,402
14-05-09 조회 6,361
14-05-09 조회 6,389
14-05-08 조회 5,722
14-04-17 조회 4,724
14-04-16 조회 4,554
14-04-15 조회 4,560
14-04-15 조회 4,514
14-04-15 조회 4,283
14-04-14 조회 4,260
14-04-14 조회 4,224
14-04-14 조회 4,610
14-04-14 조회 4,758
14-04-14 조회 4,744
14-04-13 조회 4,637
14-04-12 조회 4,203
14-04-12 조회 4,352
14-04-12 조회 4,459
14-04-11 조회 4,991
14-04-10 조회 4,718
14-04-10 조회 4,756
14-04-09 조회 4,909
14-04-09 조회 5,274
14-04-08 조회 6,940
13-10-30 조회 7,640
13-07-11 조회 5,103
13-03-28 조회 1.1만
13-02-27 조회 6,761
13-02-14 조회 5,575
13-01-10 조회 4,495
12-12-31 조회 5,069
12-12-20 조회 6,093
12-12-12 조회 5,252
12-12-07 조회 4,472
12-11-28 조회 4,825
12-11-22 조회 5,257
12-11-12 조회 5,625
12-09-22 조회 4,493
12-09-18 조회 4,681