imagecreatefromgd 


gd apg

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



<?php

GdImage
|false imagecreatefromgdstring $filename )


where,

$filename The path to an existing GD 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 "gd/GD 004 03 (png2gd).gd";

$img_name "jpeg/JPEG 012 01 (gd2jpeg).jpg";

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

<?php

$im01 
imagecreatefromgd($img_file);

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

var_dump($im01);

echo 
'<br><br>';

$bool01 imagejpeg($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   

GD 004 03 (png2gd).gd

Existing Image

However, it cannot be displayed by this browser.


The .jpeg format of the image has been created!


JPEG 012 01 (gd2jpeg).jpg

JPEG 012 01 (gd2jpeg).jpg apr