如何在IMagick中使用SVG CSS样式? [英] How to use SVG CSS styles with IMagick?

查看:173
本文介绍了如何在IMagick中使用SVG CSS样式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即使<style>位于SVG的<def>内部,(PHP)Imagick似乎也不接受CSS样式.那是对的吗?我找不到对此的参考.

It seems that the (PHP) Imagick does not accept styling with CSS even if the <style> is inside the SVG's <def>. Is that correct? I couldn't find a reference for this.

如果是这样,那将是什么仍能获得预期结果的方法呢?也许用它们的定义替换所有类?因此,例如,如果有

If so, what would be a way to still get the desired results? Maybe replace all the classes with their definitions? So, for example, if there is

.some-class {
  stroke-dasharray: 5 5;
}

然后将class="some-class"替换为stroke-dasharray="5 5",或者替换为style="stroke-dasharray: 5 5;",因为Imagick似乎了解样式属性.

then replace class="some-class" by stroke-dasharray="5 5", or, alternatively, by style="stroke-dasharray: 5 5;" since Imagick seems to understand style attributes.

推荐答案

我最近遇到了同样的问题,由于缺少软件包,我正在本地主机上工作,但在服务器上却没有工作. 我从Imagick安装了inkscape和SVG代(实际上,我使用的是Intervention Image,驱动程序设置为imagick)

I had the same issue recently, was working on my localhost but not on the server, due to a missing package. I installed inkscape and the SVG generation from Imagick (actually I'm using Intervention Image with the driver set to imagick)

apt-get install inkscape

起初SVG一代根本没有工作,我遵循了这个线程

at first the SVG generation was not working at all and I followed this thread Imagick SVG to JPG error no decode delegate

但是,此后,SVG一代开始工作了,不幸的是,SVG渲染的PNG是灰度的.我以为SVG中的样式丢失了,该线程帮助了我: 如何使用Imagick/ImageMagick调整SVG的大小

However,after that, the SVG generation was working, unfortunately the rendered PNG from a SVG was in greyscale. I thought the styles in the SVG were missing and this thread helped me: how to resize an SVG with Imagick/ImageMagick

这篇关于如何在IMagick中使用SVG CSS样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆