imagexbm()函數是PHP中的內置函數,用於顯示圖像以瀏覽文件。此函數的主要用途是在瀏覽器中查看圖像並將任何其他圖像類型轉換為XBM。
用法:
bool imagexbm( resource $image, int $to, int $foreground)
參數:此函數接受上述和以下所述的三個參數:
- $image:它指定要處理的圖像資源。
 - $to (Optional):它指定將文件保存到的路徑。
 - $foreground (Optional):它指定圖像的前景。
 
返回值:如果成功,此函數將返回TRUE,否則將返回FALSE。
以下示例說明了PHP中的imagexbm()函數:
範例1:在此示例中,我們將在瀏覽器中下載圖像。
<?php 
  
// Load an xbm image from local folder 
// Image can be converted into xbm using 
// online convertors or imagexbm() 
$im = imagecreatefromxbm('geeksforgeeks.xbm'); 
  
// Download the image 
header('Content-Type:image/xbm'); 
imagexbm($im); 
imagedestroy($im); 
?>輸出:
This will download your image as download, further you can rename this file to anything like geeksforgeeks.xbm and use it.
範例2:在此示例中,我們將PNG轉換為XBM。
<?php 
  
// Load an image from PNG URL 
$im = imagecreatefrompng( 
'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png'); 
  
// Convert the image into XBM using imagexbm() function 
imagexbm($im, 'converted.xbm'); 
imagedestroy($im); 
?>輸出:
This will save the XBM version of image in the same folder where your PHP script is.
參考: https://www.php.net/manual/en/function.imagexbm.php
相關用法
- p5.js min()用法及代碼示例
 - PHP Ds\Set get()用法及代碼示例
 - p5.js hue()用法及代碼示例
 - PHP pow( )用法及代碼示例
 - PHP next()用法及代碼示例
 - p5.js value()用法及代碼示例
 - d3.js d3.map.set()用法及代碼示例
 - d3.js d3.max()用法及代碼示例
 - d3.js d3.min()用法及代碼示例
 - d3.js d3.mean()用法及代碼示例
 - p5.js tan()用法及代碼示例
 - p5.js sin()用法及代碼示例
 
注:本文由純淨天空篩選整理自gurrrung大神的英文原創作品 PHP | imagexbm() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
