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
版权声明:本文标题:uploads - Can you generate a featured image from two images from custom fields? 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749078631a2312699.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论