Open In App

PHP | png2wbmp() function

Improve
Improve
Like Article
Like
Save
Share
Report

The png2wbmp() function is an inbuilt function in PHP which is used to convert PNG image file to WBMP image file.

Syntax:

bool png2wbmp( string $pngname, 
int $wbmpname, int $dest_height, 
int $dest_width, int $threshold )

Parameters: This function accepts five parameters as mentioned above and described below:

  • $pngname: It specifies the path to PNG file.
  • $wbmpname: It specifies the path to destination WBMP file.
  • $dest_height: It specifies the destination image height.
  • $dest_width: It specifies the destination image width.
  • $threshold: It specifies the threshold value.

Return Value: This function returns TRUE on success or FALSE on failure.

Below given programs illustrate the png2wbmp() function in PHP:
Program 1:




<?php
// Path to the PNG image which
// is to be converted
$path = './geeksforgeeks.png';
  
// 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
png2wbmp($path, './converted.wbmp', $height, $width, 5);
echo 'PNG converted into WBMP successfully.';
?>


Output:

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

Program 2:




<?php
// Path to the PNG 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
png2wbmp($path, './converted.wbmp', $height, $width, 3);
  
$im = imagecreatefromwbmp('./converted.wbmp');
  
header('Content-type: image/png');
imagepng($im);
?>


Output:

Reference: https://www.php.net/manual/en/function.png2wbmp.php



Last Updated : 19 Feb, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads