首页 > 解决方案 > 使用 Imagick 在 Wordpress 中自定义缩略图

问题描述

我想将图像上传到 Wordpress 并使用 imagick 为其创建一个真正自定义的附加缩略图。

我有 imagick 的代码 - 可以。但我不知道,我应该如何在 wordpress 上传中实现它。你能帮我解决这个问题吗?有没有比挂钩到 Wordpress 上传事件更好的方法呢?

谢谢你。

我的imagick代码是:

    <?php
/* Create new object */
$im = new Imagick();

/* Create new checkerboard pattern */
$im->readImage('test.jpg'); 

/* Set the image format to png */
$im->setImageFormat('png');

/* Fill new visible areas with transparent */
$im->setImageVirtualPixelMethod(Imagick::VIRTUALPIXELMETHOD_TRANSPARENT);

/* Activate matte */
$im->setImageMatte(true);

/* Control points for the distortion */
$controlPoints = array(500, 30, 133,150,90,2800);
/*size, inner-circle, padding links, padding-top (jeweils Mittelpunkt), wie weit, */


/* Perform the distortion */                       
$im->distortImage(Imagick::DISTORTION_POLAR, $controlPoints, true);



/* Ouput the image */
header("Content-Type: image/png");
echo $im;
?>

标签: wordpressuploadcustomizationthumbnailsimagick

解决方案


如果您启用了 ImageMagick 但您没有 Imagick PHP 扩展。没有这两个 WordPress 将不会自动使用 ImageMagick。该插件使您可以使用它并具有其他很棒的功能。

您可以使用以下插件: https ://wordpress.org/plugins/imagemagick-engine/


推荐阅读