imagecopymerge 


gd apg

COPY and MERGE an entire or part image over another image.





This function copy a part of $src_im onto $dst_im starting at coordinates indicated by $src_x, $src_y with the width $src_width and height $src_height and will be copied at coordinates designated by $dest_x and $dest_y.

0 ≤ $pct ≤ 100.

If $pct = 0 no actions is taken.

If $pct = 100 this function behaves identically to imagecopy for pallete images, except for ignoring alpha components, while it implements alpha transparency for true colour images.

This function returns TRUE on success or FALSE on failure.



<?php

bool imagecopymerge 
GdImage $dst_image,
                                      
GdImage $src_image
                                               
int $dst_xint $dst_y
                                               
int $src_xint $src_y
                                               
int $src_widthint $src_height 
                                               
int $pct )


where,

$dst_im The destination image identifier

$src_im 
The source image identifier

$dst_x 
The x-coordinate of destination point 

$dst_y 
The y-coordinate of destination point 

$src_x 
The x-coordinate of source point 

$src_y 
The y-coordinate of source point 

$src_width
The source width 

$src_height 
The source height

$pct 
The percentage of the two merged images

?>
 

  $dst_im   


The destination image identifier.



  $src_im   


The source image identifier.



  $dst_x   


The x-coordinate of destination point.



  $dst_y   


The y-coordinate of destination point.



  $src_x   


The x-coordinate of source point.



  $src_y   


The y-coordinate of source point.



  $src_width   


The source width.



  $src_height   


The source height.



  $pct   


The percentage of the two merged images.



  1 EXERCISE   

<?php

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

$seal_img "png/Copyright-red&white.png";
// https://trip.ed48.com

$base_img "png/PNG 044 01.png";
// Puerta de Alcalá - Madrid (ESP)

$dest_img "png/PNG 044 01(copyrighted).png";

?>
 <?php echo $seal_img?><br><br>
<img src="<?php echo $seal_img?>"
 alt="<?php echo $seal_img?>
 title="<?php echo $seal_img?>" width="70"><br><br>

<?php echo $base_img?><br><br>
<img src="<?php echo $base_img?>"
 alt="<?php echo $base_img?>
 title="<?php echo $base_img?>" width="400"><br><br><br>
 
<?php
$id_base 
imagecreatefrompng($base_img);

$id_seal imagecreatefrompng($seal_img);

$seal_w imagesx($id_seal);
$seal_h imagesy($id_seal);

$base_w imagesx($id_base);
$base_h imagesy($id_base);

$base_x imagesx($id_base) - $seal_w 5;
$base_y imagesy($id_base) - $seal_h 55;

imagecopymerge($id_base$id_seal
                            
$base_x$base_y
                            
00
                            
$seal_w$seal_h
                            
100);

imagepng($id_base$dest_img);
?>
<?php 
echo $dest_img?><br><br>
<img src="<?php echo $dest_img?>"
 alt="<?php echo $dest_img?>
 title="<?php echo $dest_img?>" width="400">
 

 RESULT   

Copyright-red&white.png

Copyright-red&white.png apr

PNG 044 01.png

PNG 044 01.png apr


PNG 044 01(copyrighted).png

PNG 044 01(copyrighted).png apr