Issue
I'm working with imagick and face some problem. I want to composite two images: image01 and image02,image01 is background image,a part of image02 composite on image01. the function just like GD's imagecopy function.
bool imagecopy( resource dst_im, resource src_im, int dst_x, int dst_y,
int src_x, int src_y,int src_w, int src_h )
Copy a part of src_im onto dst_im starting at the x,y coordinates src_x, src_y with a width of src_w and a height of src_h. The portion defined will be copied onto the x,y coordinates, dst_x and dst_y.
the question is: how to implement imagecopy function by Imagick?
thanks for your help.
Solution
This should do it:
//load files from source
$background = new Imagick(image01_src);
$overlay = new Imagick(image02_src);
//Crop the overlay to the required size
$overlay->cropImage ($new_width,$new_height,$x_offset,$y_offset);
//composite overlay on background
$background->compositeImage($overlay, Imagick::COMPOSITE_OVER, $margin_x, $margin_y);
//save result
$background->setImageFormat("png");
$background->writeImage(new_src);
//clean up
$background->clear();
$background->destroy();
$overlay->clear();
$overlay->destroy();
Answered By - Lukas Nagel Answer Checked By - Marilyn (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.