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

imagecreatefromxpm

PHP function Edit on GitHub ✎

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

New

Description

imagecreatefromxpm(string $filename): GdImage|false

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

Fopen-wrapper

Parameters

filename

Path to the XPM image.

Return Values

Identifier

Changelog

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

Examples

Creating an image instance using imagecreatefromxpm()

php
<?php
// Check for XPM support
if(!(imagetypes() & IMG_XPM))
{
    die('Support for xpm was not found!');
}

// Create the image instance
$xpm = imagecreatefromxpm('./example.xpm');

// Do image operations here

// PHP has no support for writing xpm images
// so in this case we save the image as a 
// jpeg file with 100% quality
imagejpeg($xpm, './example.jpg', 100);
?>

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