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

imagecreatefromgd

PHP function Edit on GitHub ✎

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

Create a new image from GD file or URL

Description

imagecreatefromgd(string $filename): GdImage|false

Create a new image from GD file or URL.

Fopen-wrapper

Parameters

filename

Path to the GD file.

Return Values

Identifier

Changelog

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

Examples

imagecreatefromgd() example

php
<?php
// Load the gd image
$im = @imagecreatefromgd('./test.gd');

// Test if the image was loaded
if(!$im)
{
     die('Unable to load gd image!');
}

// Do image operations here

// Save the image
imagegd($im, './test_updated.gd');
?>

Notes Gd-formats

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