imagecreatefromgd2part 


gd apg

CREATE a new image from file or URL from a given part of 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 imagecreatefromgd2part string $filename,
                                                                       
int $x,
                                                                       
int $y,
                                                                       
int $width,
                                                                       
int $height )

where,

$filename The path to an existing GD2 image

$x 
x-coordinate of source point

$y 
y-coordinate of source point

$width 
The source width

$height 
The source height 

?>
 

  $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


  $x   


x-coordinate of source point.



  $y   


y-coordinate of source point.



  $width    


The source width.



  $height    


The source height.



  1 EXERCISE   

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

$src_file "gd2/GD2 004 03 (gif2gd2).gd2";

if (
file_exists($src_file))
{
echo 
'<br>Source Image:<br><br>';

echo 
$src_file '<br><br>';

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

$src_file_x 110;
$src_file_y 110;
$sec_file_w 167;
$sec_file_h 125;

$im01 
imagecreatefromgd2part($src_file$src_file_x
                                        
$src_file_y$sec_file_w$sec_file_h);

// var_dump($im01);

$dst_file "jpeg/JPEG 013 01 (gd2part2jpeg).jpg";

echo 
'<br><br>Target Image:';

echo 
'<br><br>' $dst_file '<br><br>';

imagejpeg($im01$dst_file90);

?>

<img src="<?php echo $dst_file?>
alt="<?php echo $dst_file?>
title="<?php echo $$lang?>"><br><br>

<?php
imagedestroy
($im01);
}
else
{
echo 
'The SOURCE image DOES NOT EXIST!';
echo 
$src_file;
}

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 
   Current browsers, do not support .gd2.
   Therefore, files in this format should be transformed
   at .gif, .jpg or .png - to be displayed.

   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

?> 

 RESULT   

GD2 004 03 (gif2gd2).gd2

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




JPEG 013 01 (gd2part2jpeg).jpg

JPEG 013 01 (gd2part2jpeg).jpg apr