如何在PHP中使用imagecreatefromwbmp()函式從WBMP檔案或URL建立一個新影像?
在PHP中,**imagecreatefromwbmp()** 是一個內建函式,用於從WBMP檔案或URL建立一個新影像。**imagecreatefromwbmp()** 返回一個影像識別符號,表示從給定檔名獲得的影像。 當我們想要在從WBMP檔案載入影像後編輯它們時,可以使用**imagecreatefromwbmp()**。使用imagewbmp()函式,可以將影像轉換為WBMP格式。
語法
resource imagecreatefromwbmp(string $filename)
引數
**imagecreatefromwbmp()** 只接受一個引數,**$filename**。它包含影像的檔名。
返回值
**imagecreatefromwbmp()** 成功時返回一個影像資源識別符號,失敗時返回錯誤。
示例1
<?php // Loading the WBMP image from the local drive folder $img = imagecreatefromwbmp'C:\xampp\htdocs\pic.wbmp'); // View the loaded image in the browser imagewbmp($img); imagedestroy($img); ?>
輸出
Note − The above PHP code will load the content into the browser in the unsupported form text as browsers don't support WBMP.
示例2
<?php // Load a WBMP image from the local drive folder //We can convert the image to WBMP using the online converter //or using the imagewbmp() function $img = imagecreatefromwbmp('C:\xampp\htdocs\Images\img30.wbmp'); // Save the GIF image into the given local drive folder path. imagejpeg($img,'C:\xampp\htdocs\pic.gif'); imagedestroy($img); ?>
使用imagecreatefromwbmp()函式之前的原始輸入影像
使用imagecreatefromwbmp()函式後的輸出影像
注意 − WBMP是無線點陣圖檔案格式。它是一種針對移動計算裝置最佳化的WAP圖形格式。WBMP格式的圖片以點陣圖格式儲存。也就是說,影像的每個畫素都儲存為1位。要開啟WBMP檔案,需要無線點陣圖檔案格式軟體。
廣告