fly63前端网

www.fly63.com

首页文章资源工具教程 栏目
  • 关于我们
  • 网站投稿
  • 赞助一下
搜索

在线工具_工作生活好帮手

打造各种简单、易用、便捷的在线工具,网友无需注册和下载安装即可使用

点击查看

关闭

提交网站

svgexport
分享
复制链接
新浪微博
QQ 好友

扫一扫分享

GitHub:https://github.com/shakiba/svgexport
网站描述:快速实现 svg 转 png,jpg等格式
svg 是 用于描述二维矢量图形的图形格式,有着很多的优势,但是有时候并不是所有的场景都支持 svg,那么这时候,我们需要将svg 图片转换成 png 等格式。

svgexport 是一个 NodeJs 模块,也是一个命令行工具,可以实现 从 svg 转换成png,jpeg等格式。

安装很简单

npm install svgexport -g

使用方式

svgexport <input file> <output file> <options>
svgexport <datafile>

<options>        [<format>] [<quality>] [<input viewbox>] [<output size>] [<resize mode>] [<styles>]

<format>         png|jpeg|jpg
                 If not specified, it will be inferred from output file extension or defaults to "png".

<quality>        1%-100%

<input viewbox>  <left>:<top>:<width>:<height>|<width>:<height>
                 If input viewbox is not specified it will be inferred from input file.

<output size>    <scale>x|<width>:<height>|<width>:|:<height>
                 If output size is specified as width:height, <viewbox mode> is used.

<viewbox mode>   crop|pad
                 Crop (slice) or pad (extend) input to match output aspect ratio, default mode is "crop".

<datafile>       Path of a JSON file with following content:
                 [ {
                   "input" : ["<input file>", "<option>", "<option>", ...],
                   "output": [ ["<output file>", "<option>", "<option>", ...] ]
                 }, ...]
                 Input file options are merged with and overridden by output file options.
                 Instead of a JSON file, a Node module which exports same content can be provided.

转换示例

按比例扩大1.5x

svgexport input.svg output.png 1.5x

按比例缩放,指定宽度为32px

svgexport input.svg output.png 32:

设置宽高(32px:54px)进行缩放

svgexport input.svg output.png  32:54

设置JPEG 输出质量

svgexport input.svg output.jpg 80%

批量转换脚本

#!/usr/bin/env ruby
# encoding: utf-8
dir = ARGV[0]

Dir.entries(dir).select { |f|
    f.end_with? '.svg'
}.each { |f|
    newFile = f.gsub '.svg', '.png'
    puts newFile
    system "cd #{dir} && svgexport #{f} #{newFile} 120:120"
}


链接: https://fly63.com/nav/3661

more>>
相关栏目
remove.bg
消除图片背景:100% 自动 – 只需 5 秒
官网
阿里云DataV
地图数据
官网
Apifox
API 文档、API 调试、API Mock、API 自动化测试一体化协作平台
官网
易文档
需求文档、API文档、部署文档到使用手册
官网
mdx-deck
基于MDX的演示文稿
官网GitHub
YouCompress
在线免费文件压缩工具
官网
iHateRegex
快速搜索并匹配到合适的正则表达式
官网GitHub
Trilium Notes
层级结构的笔记程序,专注构建个人的大型知识库
点击进入GitHub
CodeZen
在线源代码转图片工具
官网
pngtosvg
在线PNG转SVG转换工具
官网
PDFgear
高效的 PDF 在线工具
官网
HackMD
一款超级好用的在线Markdown编辑器
官网GitHub
Hexnaw
在线网站配色评分工具
官网
糯词笔记
最佳读书笔记管理工具
官网
压缩图
在线图片压缩工具集合
官网
VectorCreator
简报插图创作工具
官网

手机预览