Issue
I have a jpg file that i want to merge another image png file on it. I am not sure how to implement this using php?
Solution
you can use gd's imagecopy function.
This function is used to copy a portion of image from source to the destination
imagecopy (
$dst_im , // destination image (resource), imagecreatefrom(gif|jpg|png)
$src_im , // destination image (resource), imagecreatefrom(gif|jpg|png)
$dst_x , // x cordinate in destination where u want the new obj placed
$dst_y , // y cordinate in destination where u want the new obj placed
$src_x , // x cordinate in source from wher u want the new obj placed
$src_y , // y cordinate in source from where u want the new obj placed
$src_w , // the width of the object to copy
$src_h // the height of the object to copy
);
As pointed in the comment in the above code, you will have to create an image resource for both destination and source.
Typically done using
$src = imagecreatefromjpg('image.jpg');
$dst = imagecreatefromjpg('watermark');
The remaining portions are just simple co-ordinates.
Also don't forget to visit imagecopy yourself.
Answered By - Kishor Kundan Answer Checked By - Mary Flores (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.