當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


PHP jpeg2wbmp()用法及代碼示例

jpeg2wbmp()函數是PHP中的內置函數,用於將JPEG圖像文件轉換為WBMP圖像文件。

用法:

bool jpeg2wbmp( string $jpegname, 
int $wbmpname, int $dest_height, 
int $dest_width, int $threshold )

參數:該函數接受上述和以下所述的五個參數:


  • $jpegname:它指定JPEG文件的路徑。
  • $wbmpname:它指定目標WBMP文件的路徑。
  • $dest_height:它指定目標圖像的高度。
  • $dest_width:它指定目標圖像的寬度。
  • $threshold:它指定閾值。

返回值:如果成功,則此函數返回TRUE;如果失敗,則返回FALSE。

下麵給出的程序說明了PHP中的jpeg2wbmp()函數:程序1:

<?php 
// Path to the JPEG image which 
// is to be converted 
$path = './geeksforgeeks.jpg'; 
  
// Get the image sizes which includes 
// the height and width 
$image = getimagesize($path); 
$height = $image[1]; 
$width = $image[0]; 
  
// Convert image the image and save as test.wbmp 
jpeg2wbmp($path, './converted.wbmp', $height, $width, 5); 
echo 'JPEG converted into WBMP successfully.'; 
?>

輸出:

This will save the WBMP version of JPEG in the same folder.

程序2:

<?php 
// Path to the JPEG image which 
// is to be converted 
$path = './geeksforgeeks.jpg'; 
  
// Get the image sizes which includes 
// the height and width 
$image = getimagesize($path); 
$height = $image[1]; 
$width = $image[0]; 
  
// Convert image the image and save as test.wbmp 
jpeg2wbmp($path, './converted.wbmp', $height, $width, 1); 
  
$im = imagecreatefromwbmp('./converted.wbmp'); 
  
header('Content-type:image/png'); 
imagepng($im); 
?>

輸出:

參考: https://www.php.net/manual/en/function.jpeg2wbmp.php



相關用法


注:本文由純淨天空篩選整理自gurrrung大神的英文原創作品 PHP | jpeg2wbmp() function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。