图片eps格式转emf/png/svg格式的方法 作者: admin 时间: 2019-08-16 分类: 默认分类 #图片eps格式转emf/png/svg格式的方法 好久没写博客了,目前供职于某家商业图库,长期与图片打交道,这一年下来积累不少,却没有多少时间总结。目前接手了一个icon的项目,需要做到矢量图片之间的转换。趁这个机会,总结一下格式转换的方法。 ### eps to png 最简单的转换方法, 在这里我们使用大名鼎鼎的[imagemagick](https://imagemagick.org/index.php]), 在macOS中可以直接使用brew安装: ``` brew install -vd --use-wmf --use-exr --with-quantum-depth-8 --enable-hdri --use-lqr --use-rsvg --with-magick-plus-plus imagemagick ``` 安装完成之后,可以通过 ``` mogrify -path ./png/ -format png *.eps ``` 对某个目录下的eps文件直接进行转换,也可以使用 ``` convert -transparent white 3.eps 3.png ``` 将带有白色背景的eps格式图片转换为透明的png格式图片。 如果上述方法不管用的话,使用 ``` # 定高256像素 inkscape -h 256 -f xxxx绝对路径.eps -e 绝对路径.png ``` 即可解决 ### eps to emf 因为emf是微软的文件格式,macOS对其支持并不友好。使用convert直接转换后得到的emf虽然可以在office全家桶这种打开,但是在windows平台中并不能显示。在经历过种种选型之后,采取了[inkscape](https://inkscape.org/release/0.92.2/mac-os-x/)进行转换,效果超群。 在官网下载inkscape并安装完成后,在.zshrc中添加一行: ``` alias inkscape="/Applications/Inkscape.app/Contents/Resources/bin/inkscape" ``` 设置inkscape别名,就可以使用inkscape命令了。 转换语句为 ``` # 定高256像素 inkscape -h 256 -f xxxx绝对路径.eps -m 绝对路径.emf ``` ### eps to svg svg格式转换也是经过了种种选型,目前的做法是将eps转换为pdf,再将pdf转换为svg。 #### eps to pdf ~~转pdf没有其他好的方法,先安装ghostscript~~ ``` brew install ghostscript ``` ~~然后使用~~ ``` ps2pdf -dEPSCrop 1.eps 1.pdf ``` 转换为pdf。 #### ~~pdf to svg~~ ~~简单粗暴~~ ``` brew install pdf2svg ``` ``` pdf2svg 1.pdf 1.svg ``` ~~这样转换出来的图片在实用性上是最高的。~~ 最近读了一遍inkscape的文档,发现可以这样操作 ``` inkscape -f xxxx绝对路径.eps -l 绝对路径.svg ``` 这样就可以直接转出svg格式的图片,inkscape真乃神器也。 之前还欠了一篇对anyproxy进行容器化的文章 之后会对elasticsearch在项目中的使用,以及图片比对系统进行分析。 希望自己能好好写博客:) 标签: eps, png, 格式, 转换, 图片, emf, svg
大佬 不错