HomeLanguagesPHP | jpeg2wbmp() function

PHP | jpeg2wbmp() function

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

Syntax:

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

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

  • $jpegname: It specifies the path to JPEG 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 jpeg2wbmp() function in PHP:
Program 1:




<?php
// Path to the JPEG image which
// is to be converted
$path = './neveropen.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.';
?>


Output:

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

Program 2:




<?php
// Path to the JPEG image which
// is to be converted
$path = './neveropen.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);
?>


Output:

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

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

2 COMMENTS

Most Popular

Dominic
32662 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
7035 POSTS0 COMMENTS
Nicole Veronica
12172 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12260 POSTS0 COMMENTS
Shaida Kate Naidoo
7161 POSTS0 COMMENTS
Ted Musemwa
7426 POSTS0 COMMENTS
Thapelo Manthata
7124 POSTS0 COMMENTS
Umr Jansen
7127 POSTS0 COMMENTS