imagepng

本函式用來建立一張 PNG 格式圖形。參數 im 為使用 ImageCreate() 所建立的圖片代碼。參數 filename 可省略,若無本參數 filename,則會將圖片指接送到瀏覽器端,記得在送出圖片之前要先送出使用 Content-type: image/png 的標頭字元串 (header) 到瀏覽器端,以順利傳輸圖片。本函式在 PHP 3.0.13 版之後才支持。

基本介紹

  • 外文名:imagepng
  • 語法: int imagepng
  • 返回值:: 整數
  • 函式種類:圖形處理
簡介,例子,

簡介

ImagePNG
建立 PNG 圖型。
語法: int imagepng(int im, string [filename]);
返回值: 整數
函式種類: 圖形處理
使用本功能需要在編譯 PHP 前先安裝 GD library。在 1.6.2 版以前的 GD library 有支持 GIF 格式的功能,但因為 GIF 格式使用的 LZW 演算法牽涉到 Unisys 的專利權,因此在 GD library 1.6.2 版之後不支持 GIF 的格式。然而到了PHP5,GD庫又支持創建GIF了。

例子

<?php
Header("Content-type: image/gif");
$im = imagecreate(400,30);
$black = ImageColorAllocate($im, 0,0,0);
$white = ImageColorAllocate($im, 255,255,255);
imageline($im, 1, 1, 350, 25, $black);
imagearc($im, 200, 15, 20, 20, 35, 190, $white);
imagestring($im, 5, 4, 10, "Graph TEST!!", $white);
ImageGif($im);
ImageDestroy($im);
?>

相關詞條

熱門詞條

聯絡我們