imagecreatefromxpm

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

imagecreatefromxpm由文件或 URL 創(chuàng)建一個(gè)新圖象。

說明

imagecreatefromxpm(string $filename): resource

imagecreatefromxpm() 返回一圖像標(biāo)識(shí)符,代表了從給定的文件名取得的圖像。

小技巧

如已啟用fopen 包裝器,在此函數(shù)中, URL 可作為文件名。關(guān)于如何指定文件名詳見 fopen()。各種 wapper 的不同功能請(qǐng)參見 支持的協(xié)議和封裝協(xié)議,注意其用法及其可提供的預(yù)定義變量。

注意: 此函數(shù)未在 Windows 平臺(tái)下實(shí)現(xiàn)。

參數(shù)

filename

Path to the XPM image.

返回值

成功后返回圖象對(duì)象,失敗后返回 false。

范例

示例 #1 Creating an image instance using imagecreatefromxpm()

<?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);
imagedestroy($xpm);
?>

返回值

注意: 此函數(shù)未在 Windows 平臺(tái)下實(shí)現(xiàn)。