PHP | imagecreatefrombmp() Function
Last Updated :
29 Jan, 2020
The imagecreatefrombmp() function is an inbuilt function in PHP which is used to create a new image from file or URL.
Syntax:
resource imagecreatefrombmp( string $filename )
Parameters: This function accepts a single parameter $filename which holds the name or URL of a file.
Return Value: This function returns an image resource identifier on success, FALSE on errors.
Below given programs illustrate the imagecreatefrombmp() function in PHP:
Program 1: Viewing a bmp file in browser.
<?php
$im = imagecreatefrombmp(
header( 'Content-type: image/bmp' );
imagebmp( $im );
imagedestroy( $im );
?>
|
Output:
Program 2: This program converting the bitmap into png.
<?php
$im = imagecreatefrombmp(
header( 'Content-type: image/png' );
imagepng( $im );
imagedestroy( $im );
?>
|
Output:
Reference: https://www.php.net/manual/en/function.imagecreatefrombmp.php
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...