PHP 7.2.0 Release Candidate 4 Released


(PHP 4 >= 4.0.7, PHP 5, PHP 7)

imagecreatefromgd2Create a new image from GD2 file or URL


resource imagecreatefromgd2 ( string $filename )

Create a new image from GD2 file or URL.


A URL can be used as a filename with this function if the fopen wrappers have been enabled. See fopen() for more details on how to specify the filename. See the Supported Protocols and Wrappers for links to information about what abilities the various wrappers have, notes on their usage, and information on any predefined variables they may provide.



Path to the GD2 image.

Return Values

Returns an image resource identifier on success, FALSE on errors.


Example #1 imagecreatefromgd2() example

// Load the gd2 image
$im imagecreatefromgd2('./test.gd2');

// Apply an effect on the image, in this 
// case negate the image if PHP 5+

// Save the image

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
e">Th p://fr2.p e">Th 0.7, e">Th 0.7tion.imageco "funn"imagecolormagecolortransparent e">Th p e">Th 0.7 Th 0.7 e">Th > p e">Th 0., e">Th 0.tion.imageco "funn"imagecolormagecolortransparent e">Th if> p e">Th 0if, e">Th 0iftion.imageco "funn"imagecolormagecolortransparent e">Th jpetialias.php" title= e">Th jpet, e">Th jpettion.imageco "funn"imagecolormagecolortransparent e">Th pntialias.php" title= e">Th pnt, e">Th p
  • Th ction.image-type-toagear e">Th ction., e">Th _​to_​extension">image_​type_​to_​extension
  • e">Th le="imageaffine">image e">Th le=", e">Th
  • Th eb"imageaffine">image e">Th leb", e">Th eb"
  • Th xbmimageaffine">image e">Th xbm, e">Th xbm
  • Th xpmimageaffine">image e">Th xpm, e">Th xpm
  • Thtexttransimageaffine">image e">Thtexttrans, e">Thtexttrans
  • image eo", eo"
  • image eo"auto, eo"auto
  • imageptioecessi
  • imagepv> <
  • imageellipsi
  • imagebmp #00mditbmcolor: #00mditbmagecolortransparent
  • image#00mdiellipsicolor: #00mdiellipsi <
  • image#00mdi Conanglicolor: #00mdi Conangli <
  • imagefilrtobagecscolor: #00mtobagecs <
  • imagefiltcscolor: #00tcs <
  • imagefli", fli" <
  • imagefont>