有哪些优化SVG的选项? [英] What are some options for optimizing SVG?

查看:122
本文介绍了有哪些优化SVG的选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有多个SVG,其中一些很大(11MB),它们是使用 pdf2svg 通过PDF创建的.

I have multiple SVGs, some of them rather large (11MB) and they're created from a PDF using pdf2svg.

问题是SVG太大,打开时间很长,而且不必要地复杂.它主要包含文本和一些图像(例如报纸),并且文本被分成小块字符,甚至没有单词.

The problem is, that the SVG is too big, takes long time to open, and is unnecessarily complex. It contains mostly text and some images (think newspaper), and the text is split into little chunks of characters, not even words.

我需要对其进行优化,首先是要减小尺寸,还要减少元素数量以使其加载更快.到目前为止,我唯一想到的就是查看同一行中的字符,并将它们合并为一个<tspan>.

I need to optimize it, first to reduce size, and also to reduce the amount of elements to make it load faster. The only thing I thought of so far is looking at characters which are at one line, and join them in a single <tspan>.

这应该大大减少文本元素的数量,因为它看起来主要是由1-5个字母组成的组.

This should reduce the amount of text elements by quite a significant margin, because it looks like it's mostly groups of 1-5 letters.

但是我正在寻找我可以对SVG做更多的事情来减小尺寸.还有一个主要字体,用于大约95%的文本,但是就目前而言,所有文本都定义为字形(渲染形状).

But I am looking for some more things I can do to the SVG to reduce the size. There's also a main font, which is used for about 95% of the text, but as it is right now, all of the text is defined as glyphs (rendered shapes).

是否可以仅嵌入字体,以使文本呈现为文本,而不是形状?

此外,如果您知道将PDF转换为SVG的任何更好的库,我将不胜感激.唯一的要求是,SVG输出应与PDF完全相同.

Also if you know of any better library for converting PDFs to SVG, I'd appreciate any input. The only requirement is that it the SVG output should look exactly the same as the PDF.

我还要指出,速度并不是很重要.只要转换能够产生所需的结果,转换的时间就无关紧要.

I'd also like to note that speed isn't really important. It doesn't matter how long the conversion takes, as long as it produces the required result.

推荐答案

SVG-Cleaner似乎运行完美:比其他人快得多,压缩效果更好,在我的测试中更可靠,批处理文件夹处理,嘿!一个适合我们懒人的Windows安装程序!

SVG-Cleaner seems to work perfectly: much faster thanb others, better compression, robust in my tests, batch folder proccessing, and hey! a windows installer for us lazy people!

我的尝试:原始文件大小:241 KB,在删除InkScape引用后:149K,使用工具清理:38 KB,清理并压缩:5 KB(.sgvz文件扩展名).

My try: Original file size: 241 KB, after InkScape delete refs: 149K, cleaned with the tool: 38 KB, cleaned and compressed: 5 KB (.sgvz file extension).

我试图打开最后一张,希望得到一张空白的图纸...但是我的图形仍然完好无损!

I tried to open the last one, expecting a blank drawing... But my graphics were still there intact!

此处(Windows,Ubuntu或源代码)

Download it here (Windows, Ubuntu, or Source)

这篇关于有哪些优化SVG的选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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