admin管理员组

文章数量:1130349

Over and over again our blog has the same featured image and all thats changing is two logos. At present we have a blank template we manually load into Photoshop and attach the two images. I have successfully managed to create and save a new image using imagemagick but now I would like to take this one step further and use the inputs from two custom image fields as the basis for the featured image.

On the page itself I could easily overlay with CSS but the feature image would then not display correctly on social media and other areas of the website.

Here is my PHPGD code I have working standlone, I'm at a complete loss of where to go from now.

{ 

$dir = dirname(__FILE__);     
$logo = new Imagick(); 
if (FALSE === $logo->readImage($dir . '/logo.png')) 
{ 
    throw new Exception(); 
} 



$background = new Imagick(); 
if (FALSE === $background->readImage($dir . '/bg.jpg')) 
{ 
    throw new Exception(); 
} 


$background->compositeImage($logo, Imagick::COMPOSITE_DEFAULT, 130, 130);
$background->mergeImageLayers(imagick::LAYERMETHOD_FLATTEN);
$background->setImageFileName($dir . '/featured.jpg'); 


} 

Over and over again our blog has the same featured image and all thats changing is two logos. At present we have a blank template we manually load into Photoshop and attach the two images. I have successfully managed to create and save a new image using imagemagick but now I would like to take this one step further and use the inputs from two custom image fields as the basis for the featured image.

On the page itself I could easily overlay with CSS but the feature image would then not display correctly on social media and other areas of the website.

Here is my PHPGD code I have working standlone, I'm at a complete loss of where to go from now.

{ 

$dir = dirname(__FILE__);     
$logo = new Imagick(); 
if (FALSE === $logo->readImage($dir . '/logo.png')) 
{ 
    throw new Exception(); 
} 



$background = new Imagick(); 
if (FALSE === $background->readImage($dir . '/bg.jpg')) 
{ 
    throw new Exception(); 
} 


$background->compositeImage($logo, Imagick::COMPOSITE_DEFAULT, 130, 130);
$background->mergeImageLayers(imagick::LAYERMETHOD_FLATTEN);
$background->setImageFileName($dir . '/featured.jpg'); 


} 

本文标签: uploadsCan you generate a featured image from two images from custom fields