查詢

jpeg2wbmp()函式—用法及示例

「 將JPEG影象轉換為WBMP影象 」


函式名稱:jpeg2wbmp()

適用版本:PHP 4 >= 4.0.5, PHP 5, PHP 7

函式描述:將JPEG影象轉換為WBMP影象

用法:

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

引數:

  • $jpegname:JPEG影象檔案的路徑和檔名。
  • $wbmpname:轉換後的WBMP影象檔案的路徑和檔名。
  • $dest_height:轉換後的WBMP影象的高度。
  • $dest_width:轉換後的WBMP影象的寬度。
  • $threshold:可選引數,表示用於二值化影象的閾值。預設值為80。

返回值:

  • 如果成功轉換並儲存了WBMP影象,則返回true。
  • 如果發生錯誤,則返回false。

示例:

$jpegname = 'path/to/image.jpg';
$wbmpname = 'path/to/image.wbmp';
$dest_height = 200;
$dest_width = 200;
$threshold = 80;

if (jpeg2wbmp($jpegname, $wbmpname, $dest_height, $dest_width, $threshold)) {
    echo 'JPEG image converted to WBMP successfully.';
} else {
    echo 'Failed to convert JPEG image to WBMP.';
}

上述示例將指定的JPEG影象轉換為200x200畫素的WBMP影象,並將閾值設定為80。如果轉換成功,則輸出"JPEG image converted to WBMP successfully.",否則輸出"Failed to convert JPEG image to WBMP."

補充糾錯
下一個函式: join()函式
熱門PHP函式
分享連結