Imagick 支持径向渐变吗?

发布于 2024-09-15 19:25:48 字数 1348 浏览 2 评论 0原文

问题
当使用 Imagick::newPseudoImage 创建径向渐变时,Apache HTTP 错误日志中出现此错误,并且未创建径向渐变:

PHP 致命错误:未捕获的异常 带有消息的“ImagickException” '无法创建新的伪图像: 径向渐变:#FF0000-#FFFFFF' in /var/www/html/energy/scripts/rg.php:6\n堆栈 跟踪:\n#0 /var/www/html/energy/scripts/rg.php(6): Imagick->新的伪图像(150,150, '径向渐变...')\n#1 {main}\n 扔进去 /var/www/html/energy/scripts/rg.php 上 第 6 行

研究
缺少 Imagick::newPseudoImage 的 PHP 文档,但根据 链接文本 (搜索“径向”):

RADIAL_GRADIENT...渐变径向 从一种色调过渡到 another...返回渲染的径向 使用指定的渐变图像 图像尺寸。指定所需的 底纹作为文件名的一部分(例如 径向渐变:红蓝或 径向渐变:#F00-#00F)。

我尝试过使用“RADIAL_GRADIENT”而不是“radial-gradient”以及我能想到的所有其他组合。最终,我想提供 Imagick::newPseudoImage RGB 值而不是十六进制并将创建的图像保存到磁盘。

我的 PHP 脚本

// 创建一个新的 imagick 对象。
$image = new Imagick();

// 一个新图像,具有从红色到白色的径向渐变渐变,150 x 150 像素。 $image->newPseudoImage(150,150,'径向渐变:#FF0000-#FFFFFF');

// 设置图像格式为PNG。
$image->setImageFormat('png');

// 输出图像。
header("内容类型:image/png");
回显$图像;

我的环境
imagick 3.0.1RC1
ImageMagick 6.2.8.0
PHP 5.2.14
RedHat Enterprise Linux 5.5

谢谢:-)

PROBLEM
When using Imagick::newPseudoImage to create a radial gradient, this error appears in the Apache HTTP error log and the radial gradient is not created:

PHP Fatal error: Uncaught exception
'ImagickException' with message
'Unable to create new pseudo image:
radial-gradient:#FF0000-#FFFFFF' in
/var/www/html/energy/scripts/rg.php:6\nStack
trace:\n#0
/var/www/html/energy/scripts/rg.php(6):
Imagick->newpseudoimage(150,150,
'radial-gradient...')\n#1 {main}\n
thrown in
/var/www/html/energy/scripts/rg.php on
line 6

RESEARCH
The PHP documentation for Imagick::newPseudoImage is lacking but according to link text (search for "radial"):

RADIAL_GRADIENT...Gradual radial
passing from one shade to
another...Returns a rendered radial
gradient image using the specified
image size. Specify the desired
shading as part of the filename (e.g.
radial-gradient:red-blue or
radial-gradient:#F00-#00F).

I've tried using "RADIAL_GRADIENT" instead of "radial-gradient" and every other combination I could think of. Utimately, I would like to feed Imagick::newPseudoImage RGB values instead of hex and save the created images to disk.

My PHP script

// Create a new imagick object.
$image = new Imagick();

// A new image with radial gradient fading from red to white, 150 by 150 pixels.
$image->newPseudoImage(150,150,'radial-gradient:#FF0000-#FFFFFF');

// Set the image format to PNG.
$image->setImageFormat('png');

// Output the image.
header("Content-Type: image/png");
echo $image;

My Environment
imagick 3.0.1RC1
ImageMagick 6.2.8.0
PHP 5.2.14
RedHat Enterprise Linux 5.5

Thank you :-)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

樱&纷飞 2024-09-22 19:25:48

您正在使用 ImageMagick 6.2.8;最新的是6.6.3。这两个版本之间有很多增强功能。您引用的文档页面描述了最新版本(据我所知)。

他们的下载页面提供了在 CentOS 5.4 上安装最新版本的 RPM(与 RedHat Enterprise Linux 5.4 基本相同)。这些可能也适用于 5.5 - 尝试一下:)

(我对 PHP 绑定不太了解,所以恐怕无法帮助您:)

You are using ImageMagick 6.2.8; the latest is 6.6.3. There have been a lot of enhancements between those two versions. The documentation page you reference describes the latest version (as far as I know).

Their download page has RPMs for installing the latest version on CentOS 5.4 (which is essentially identical to RedHat Enterprise Linux 5.4). These may well work on 5.5 as well - give them a try :)

(I don't know much about the PHP bindings, so can't help you with that I'm afraid :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文