메뉴 건너뛰기

프로그램언어

조회 수 774 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
<?php
/**
* @description 스마트폰, 카메라 등에서 사진 jpg 저장시에 
회전값이 들어갈 수 있다. 그럴 경우 변환해 주는 소스 이다.
*/
if(!function_exists('exif_read_data')){
    echo 'not defined exif_read_data. requires exif module';
    exit;
}
if(!function_exists('imagecreatefromjpeg')){
    echo 'not defined imagecreatefromjpeg.';
    exit;
}
if(!function_exists('imagerotate')){
    echo 'not defined imagerotate.';
    exit;
}


$source_path = "shot.jpg";
$temp_ext = strrchr($source_path, ".");
$temp_ext = strtolower($temp_ext);// 확장자
if(preg_match('/(jpg|jpeg)$/i',$temp_ext)
    && function_exists('exif_read_data')
    && function_exists('imagecreatefromjpeg')
    && function_exists('imagerotate')
    )
{
    $exif = exif_read_data($source_path);//<get exif data. jpeg 나 tiff 의 경우에만 갖고 있음
    $source = imagecreatefromjpeg($source_path);//<임시 리소스 생성

    //값에 따라 회전
    switch($exif['Orientation']){
        case 8 : $source = imagerotate($source,90,0); break;
        case 3 : $source = imagerotate($source,180,0); break;
        case 6 : $source = imagerotate($source,-90,0); break;
    }

    //결과 처리
    header('Content-Type: image/jpeg');
    imagejpeg($source);
    imagedestroy($source);
}
?>

List of Articles
번호 제목 날짜 조회 수
280 MYSQL DB 다중접속을 해결 하는 한 방법 2021.03.26 284
279 MySQL DB 중복여부 검사하여 없는 것만 추가 2015.04.14 20157
278 MYSQL DB의 모든 테이블에서 문자열 검색 하기 2021.03.26 915
277 MYSQL 업데이트 두 번 하기 2014.02.27 19729
276 mysql 에러 구문 표시 2014.02.27 20349
275 MySQL(MariaDB) 테이블 만들기 2018.03.28 8154
274 mysql_affected_rows — 최근 MySQL 작업으로 변경된 행 개수를 얻음 2016.12.23 18807
273 mysql_free_result(); 관련 오류 2021.03.25 327
272 mysql_insert_id 2016.12.23 18750
271 mysql_real_escape_string 이진 데이터를 입력할 경우 이 함수를 사용해야 함 2016.12.23 18640
270 mysql_result — 결과 데이터를 반환 2016.12.23 18967
269 MySQL테이블의 내용을 엑셀파일(xls)로 다운로드 하기 2018.07.24 4798
268 parse_ini_file — Parse a configuration file 2016.12.23 19774
267 PEAR DB 관련 함수들 2021.03.26 690
266 PHP $_SERVER 함수 2019.02.25 1558
265 PHP + 유튜브(youtube) 동영상 업로드 연동 소스 2021.01.21 1141
264 PHP - 공공 DATA XML 파싱(PHP 버전) 2023.01.12 270
263 PHP continue 문 file 2015.04.14 21097
262 php date 날짜 관련 함수 file 2021.03.27 411
261 PHP eregi가 빠를까, strpos가 빠를까? 2018.10.27 4091
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 17 Next
/ 17

하단 정보를 입력할 수 있습니다

© k2s0o1d4e0s2i1g5n. All Rights Reserved