개발자 Q&A

개발하다 막혔다면? 여기서 질문하세요! 초보부터 고수까지, 함께 고민하고 해결하는 공간입니다. 누구나 자유롭게 질문하고 답변을 남겨보세요!

2025.08.04 19:40

GD_info 관련 질문

목록
  • MariaDB장인 10시간 전 2025.08.04 19:40 새글
  • 2
    1
안녕하세요 선생님,
GD_info를 사용하여 이미지 정보를 추출하려고 하는데요.
이미지의 파일 크기를 가져올 수 있는 방법은 어떤 것들이 있을까요?

    댓글목록

    profile_image
    나우호스팅  10시간 전



    GD_info를 사용하여 이미지 파일 크기를 가져올 수 있는 방법은 다음과 같습니다.

    1. GD_info의 imageinfo() 함수를 사용하여 이미지 정보를 추출할 수 있습니다. 이 함수는 이미지의 크기, MIME 타입, 파일 이름, 파일 크기, 이미지 유형, 이미지 크기 등 다양한 정보를 반환합니다.

    예시:

    #hostingforum.kr
    php
    
    $image = imagecreatefromstring(file_get_contents('image.jpg'));
    
    $info = getimagesizefromstring(file_get_contents('image.jpg'));
    
    $width = $info[0];
    
    $height = $info[1];
    
    $file_size = $info[3];
    
    echo "이미지 크기: $width x $heightn";
    
    echo "파일 크기: $file_size bytesn";
    
    


    2. GD_info의 imagecreatefromstring() 함수를 사용하여 이미지 파일을 로드한 후, getimagesize() 함수를 사용하여 이미지 크기를 가져올 수 있습니다.

    예시:
    #hostingforum.kr
    php
    
    $image = imagecreatefromstring(file_get_contents('image.jpg'));
    
    $width = imagesx($image);
    
    $height = imagesy($image);
    
    $file_size = filesize('image.jpg');
    
    echo "이미지 크기: $width x $heightn";
    
    echo "파일 크기: $file_size bytesn";
    
    


    3. GD_info의 imagecreatefromjpeg(), imagecreatefrompng(), imagecreatefromgif() 함수를 사용하여 이미지 파일을 로드한 후, getimagesize() 함수를 사용하여 이미지 크기를 가져올 수 있습니다.

    예시:
    #hostingforum.kr
    php
    
    $image = imagecreatefromjpeg('image.jpg');
    
    $width = imagesx($image);
    
    $height = imagesy($image);
    
    $file_size = filesize('image.jpg');
    
    echo "이미지 크기: $width x $heightn";
    
    echo "파일 크기: $file_size bytesn";
    
    


    이러한 방법 중 하나를 사용하여 이미지 파일 크기를 가져올 수 있습니다.

    2025-08-04 19:41

  • 개발자 Q&A 포인트 정책
      글쓰기
      50P
      댓글
      10P
  • 전체 41,528건 / 6 페이지

검색

게시물 검색