php8.5
Home/ Manual/ image / functions/ imagecreatefromgd2

imagecreatefromgd2

PHP function Edit on GitHub ✎

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

Create a new image from GD2 file or URL

Description

imagecreatefromgd2(string $filename): GdImage|false

Create a new image from GD2 file or URL.

Fopen-wrapper

Parameters

filename

Path to the GD2 image.

Return Values

Identifier

Changelog

VersionDescription
8.0.0On success, this function returns a GDImage instance now; previously, a resource was returned.

Examples

imagecreatefromgd2() example

php
<?php
// Load the gd2 image
$im = imagecreatefromgd2('./test.gd2');

// Apply an effect on the image, in this 
// case negate the image
if(function_exists('imagefilter'))
{
    imagefilter($im, IMG_FILTER_NEGATE);
}

// Save the image
imagegd2($im, './test_updated.gd2');
?>

Notes Gd-formats

Source: reference/image/functions/imagecreatefromgd2.xml · from the official PHP manual (php/doc-en)