update : 2015.11.03
php.shukuma.com

검색:
 
 
파일이나 URL에서 새 이미지를 생성

imagecreatefromgif

(PHP 4, PHP 5, PHP 7)

imagecreatefromgif파일이나 URL에서 새 이미지를 생성

설명

resource imagecreatefromgif ( string $filename )

imagecreatefromgif() returns an image identifier representing the image obtained from the given filename.

Tip

fopen 래퍼를 활성화하면, 파일명으로 URL을 사용할 수 있습니다. 파일 이름을 지정하는 방법은 fopen()을 참고하십시오. 다양한 래퍼의 기능, 사용법, 제공하는 예약 정의 변수들에 대해서는 Supported Protocols and Wrappers를 참고하십시오.

인수

filename

Path to the GIF image.

반환값

성공 시에 이미지 자원 지시자를, 오류 시에 FALSE를 반환합니다.

예제

Example #1 Example to handle an error during loading of a GIF

<?php
function LoadGif($imgname)
{
    
/* Attempt to open */
    
$im = @imagecreatefromgif($imgname);

    
/* See if it failed */
    
if(!$im)
    {
        
/* Create a blank image */
        
$im imagecreatetruecolor (15030);
        
$bgc imagecolorallocate ($im255255255);
        
$tc imagecolorallocate ($im000);

        
imagefilledrectangle ($im0015030$bgc);

        
/* Output an error message */
        
imagestring ($im155'Error loading ' $imgname$tc);
    }

    return 
$im;
}

header('Content-Type: image/gif');

$img LoadGif('bogus.image');

imagegif($img);
imagedestroy($img);
?>

위 예제의 출력 예시:

Output of example : Example to handle an error during loading of a GIF

주의

Note:

GIF support was removed from the GD library in Version 1.6, and added back in Version 2.0.28. This function is not available between these versions.

Note:

When reading animated GIF files into memory, only the first frame is returned in the image resource pointer.