이미지파일인지 체크와 이미지정보 > PHP

본문 바로가기
사이트 내 전체검색

PHP

이미지파일인지 체크와 이미지정보

페이지 정보

profile_image
작성자 관리자
댓글 0건 조회 6,431회 작성일 21-04-22 17:49

본문

//파일경로
$file = './img/2.jpg';

//이미지파일 정보
$get_imginfo = @getimagesize($file, $extinfo);

//이미지파일이면
if ($get_imginfo == true) {

  //리스트에 담는다.
  list($image_width, $image_height, $image_type) = $get_imginfo;

  //허용범위
  $accept_type = array("1", "2", "3", "6");

  //체크
  if (in_array($image_type, $accept_type)) {
    //jpg타입
    if ($image_type == 2) {
      //파일정보
      $exif = @exif_read_data($file, 0, true);

      echo $exif['FILE']['FileName'];
      echo "<br>";
      echo $exif['IFD0']['Make'];
      echo "<br>";
      echo $exif['IFD0']['Model'];
      echo "<br>";
      echo $exif['IFD0']['Orientation'];
      echo "<br>";
      echo $exif['IFD0']['Software'];

    }

  }

}
/*
image_type
1 => 'GIF',
2 => 'JPG',
3 => 'PNG',
4 => 'SWF',
5 => 'PSD',
6 => 'BMP',
7 => 'TIFF(intel byte order)',
8 => 'TIFF(motorola byte order)',
9 => 'JPC',
10 => 'JP2',
11 => 'JPX',
12 => 'JB2',
13 => 'SWC',
14 => 'IFF',
15 => 'WBMP',
16 => 'XBM'
*/
 

댓글목록

등록된 댓글이 없습니다.

회원로그인

회원가입

Copyright © neion.co.kr All rights reserved.