imagecreatefromgd2 


gd apg

CREATE a new image from file or URL from a GD2 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 GD2 format.



<?php

GdImage
|false imagecreatefromgd2string $filename )


where,

$filename The path to an existing GD2 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 "gd2/GD2 005 02 (jpeg2gd2).gd2";

echo 
$img_file?><br><br>Existing Image...<br><br> 
However, it cannot be displayed by this browser.

<?php

$im01 
imagecreatefromgd2($img_file);

echo 
'<br><br>The resource to be used:<br><br>';

var_dump($im01);

echo 
'<br><br>';

$img_name "png/PNG 020 01 (gd22png).png";

$bool01 imagepng($im01$img_name);

if (
$bool01 == true)  
{  
echo 
'<br><br>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   

GD2 005 02 (jpeg2gd2).gd2

Existing image...

However, it cannot be displayed by this browser.

The .png format of the image has been created!


PNG 020 01 (gd22png).png

PNG 020 01 (gd22png).png apr