I want to merge 2 images with imagick.
I already know how to merge them with imagick, but I need to pass 2 variables through wp_get_image_editor
to get this to work.
I named the 2 variables $background
and $logo
.
$background
contains the background image path.
$logo
contains the logo image path.
Does anyone know how I should do this?
Mike Schroder said:
“WP_Image_Editor is built to handle one file at a time, and there isnât anything built in to combine two images by default.
The main reason here is that the files in-memory arenât compatible with one-another if different editors (say, GD and Imagick) are used for each.
There are a few different ways to handle it, of course, but one way to solve the problem here would be to load one of the two images, then extend the Imagick editor (or both editors, if you prefer more compatibilty) to support combining images. Say, with a $image->combine( âfilenameâ ) method.
First, youâd load one of the images with wp_get_image_editor() (and specify that âcombineâ is a required method), then call your combine method while specifying the second image.”