使用ImageMagick裁剪和缩放SVG到PNG,无像素化 [英] Crop and scale SVG to PNG using ImageMagick, without pixellation

查看:647
本文介绍了使用ImageMagick裁剪和缩放SVG到PNG,无像素化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含许多多边形的SVG:

I have an SVG with many polygons:

https://github.com/barrycarter/bcapps/blob/master/sample-data/current-temps.svg

看起来有点像这样:

裁剪并转换为PNG可以正常工作:

Cropping this and converting to PNG works fine:

convert -crop 100x100+200+150 current-temps.svg /tmp/exhb2.png

裁剪然而,缩放失败:

convert -crop 100x100+200+150 -scale 1000x750 current-temps.svg /tmp/exhb3.png

如何使ImageMagick缩放进入裁剪之前的SVG?

How do I make ImageMagick "zoom into" the SVG before cropping?

(我意识到ImageMagick只能读取,而不能写入SVG格式,但是
它应该仍然可以做什么我想要?)

(I realize ImageMagick can only read, not write, the SVG format, but it should still be able to do what I want?)

编辑/已解决:

谢谢,robermorales。

Thanks, robermorales.

inkscape -z -e out4.png -w 1000 -h 1000 -a 200:200:400:400 current-temps.svg 

(例如)像魅力一样工作。

(for example) worked like a charm.

我也意识到复制SVG,调整变换线:

I also realized that copying the SVG, tweaking the transform line:

<g transform="scale(3,3) rotate(-90) translate(-90,180)"> 

然后转换为PNG是另一种解决方案。

and then converting to PNG is another solution.

推荐答案

尝试在裁剪前进行缩放。

Try doing scale before crop.

然而,这样做使用inkscape cli更容易。

However, doing that using inkscape cli is easier.

很抱歉没有链接,afk

Sorry for no links, afk

这篇关于使用ImageMagick裁剪和缩放SVG到PNG,无像素化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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