wordpress - 使用 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;
?>
解决方案
如果您启用了 ImageMagick 但您没有 Imagick PHP 扩展。没有这两个 WordPress 将不会自动使用 ImageMagick。该插件使您可以使用它并具有其他很棒的功能。
您可以使用以下插件: https ://wordpress.org/plugins/imagemagick-engine/
推荐阅读
- etl - ETL架构中的数据流流程
- python - 如何使用 SQLAlchemy 和 FastAPI 中的 json.dumps 删除 json 输出中的额外反斜杠?
- haskell - 返回给定索引处元素的函数
- java - 使用 Azure AD 帐户时出现强制密码更改问题
- c# - ASP net core MVC 1种形式下调用不同动作
- java - Joda Time 返回正确的日期,但 Java 时间没有
- oracle - 如何解决:通用连接池中的所有连接都在使用中?
- c# - 需要从 Windows Form C# 中非常复杂的 XML 文件中获取值
- javascript - 根据 ID 从 JSON 中删除元素
- javascript - Vue watch TypeScript错误TS2769:没有重载匹配这个调用