imagecreatefromwebp 


gd apg

CREATE a new image from file or URL from a WEBP image.





This function returns an image identifier representing the image obtained from the given filename.





This function returns FALSE on errors.

The GdImage, resource or object returned by this function allows the creation of other image formats from WEBP format.



<?php

GdImage
|false imagecreatefromwebpstring $filename )


where,

$filename The path to an existing WEBP image 

?>
 

  $filename   


The path or stream resource.

$filename can reference a local file or, (configuration permitting), a remote file using one of the supported stream wrappers:

STREAM WRAPPERS MEANING
file:// LOCAL File System
http:// URL HTTP
ftp:// URL FTP
php:// I/O streams
zlib:// Data Compression stream
data:// DATA (RFC-2397)
glob:// Find Filenames
phar:// PHP Archive
ssh2:// Secure Shell 2
rar:// RAR
ogg:// Audio
expect:// Interaction of stream processes
ed48


  1 EXERCISE   

<?php

echo 'PHP VERSION: ' PHP_VERSION '<br><br>';

$img_file "webp/WEBP 001 01.webp"

echo 
$img_file?><br><br>Existing Image 
<br><br><img src="<?php echo $img_file?>" alt="<?php echo $img_file?>" title="W E B P"> 

<?php

$im01 
imagecreatefromwebp($img_file); 

// var_dump($im01);

echo '<br><br>'

$img_name "bmp/BMP 006 01 (webp2bmp).bmp"

$bool01 imagebmp($im01$img_name);

if (
$bool01 == true)   
{   
echo 
'The new format has been created!<br><br>' 
$img_name '<br><br>';  

echo 
'<img src="' $img_name 
 
'" alt="' $img_name '" title="' $img_name '">';  
}   
else   
{   
echo 
'$bool01 = ' $bool01 
'<br><br>The image was NOT created!';   
}   

?> 

 RESULT   

WEBP 001 01.webp

Existing Image

WEBP 001 01.webp apr


The .bmp format of the image has been created!

BMP 006 01 (webp2bmp).bmp

BMP 006 01 (webp2bmp).bmp apr

  2 EXERCISE   

<?php

echo 'PHP VERSION: ' PHP_VERSION '<br><br>';

$img_file "webp/WEBP 0029 09.webp"

echo 
$img_file?><br><br>Existing Image 
<br><br><img src="<?php echo $img_file?>" alt="<?php echo $img_file?>" title="W E B P"> 

<?php

$im02 
imagecreatefromwebp($img_file); 

// var_dump($im02);

echo '<br><br>'

$img_name "wbmp/WBMP 005 02 (webp2wbmp).wbmp"

$bool01 imagewbmp($im02$img_name);   

if (
$bool01 == true)   
{   
echo 
'The new format has been created!<br><br>' 
$img_name '<br><br>';  

echo 
'The image was Created...<br>
      BUT CAN NOT BE DISPLAYED by this browser!'

}   
else   
{   
echo 
'$bool01 = ' $bool01 
'<br><br>The image was NOT created!';   
}   

?> 

 RESULT   

WEBP 0029 09.webp

Existing Image

WEBP 0029 09.webp apr

The new format has been created!

WBMP 005 02 (webp2wbmp).wbmp

The image was Created...
BUT CAN NOT BE DISPLAYED by this browser!


  3 EXERCISE   

<?php

echo 'PHP VERSION: ' PHP_VERSION '<br><br>'

$img_file "webp/WEBP 005 02 P de Galinhas (bmp2webp).webp"

echo 
$img_file?><br><br>Existing Image 
<br><br><img src="<?php echo $img_file?>" alt="<?php echo $img_file?>" title="W E B P" width="400"> 

<?php

$im03 
imagecreatefromwebp($img_file); 

// var_dump($im03);

echo '<br><br>'

$img_name "wbmp/WBMP 006 03 P de Galinhas (webp2wbmp).wbmp"

$bool01 imagewbmp($im03$img_name);   

if (
$bool01 == true)   
{   
echo 
'The new format has been created!<br><br>' 
$img_name '<br><br>';  

echo 
'The image was Created...<br>
      BUT CAN NOT BE DISPLAYED by this browser!'

}   
else   
{   
echo 
'$bool01 = ' $bool01 
'<br><br>The image was NOT created!';   
}   

?> 

 RESULT   

WEBP 005 02 P de Galinhas (bmp2webp).webp

Existing Image

WEBP 005 02 P de Galinhas (bmp2webp).webp apr

The new format has been created!

WBMP 006 03 P de Galinhas (webp2wbmp).wbmp

The image was Created...
BUT CAN NOT BE DISPLAYED by this browser!