# svgexport
svgexport is a Node.js module and command-line tool for exporting SVG files to PNG and JPEG, it uses Puppeteer for rendering SVG files.
### Command Line
#### Installation
```
npm install svgexport -g
```
#### Usage
```usage
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.
```
#### Examples
Scale 1.5x proportionally:
```
svgexport input.svg output.png 1.5x
```
Scale proportionally to set output width to 32px:
```
svgexport input.svg output.png 32:
```
Scale proportionally and pad output to set output width:height to 32px:54px:
```
svgexport input.svg output.png pad 32:54
```
Export `-1:-1:24:24` (`left:top:width:height`) of input.svg to output.png:
```
svgexport input.svg output.png -1:-1:24:24 1x
```
Set output JPEG quality:
```
svgexport input.svg output.jpg 80%
```
Use a CSS to style input SVG:
```
svgexport input.svg output.jpg "svg{background:silver;}"
```
By default, Puppeteer has a page load timeout of 30 seconds. This might not be
enough for large SVG files. If you want to change the page timeout, set the
`SVGEXPORT_TIMEOUT` environment variable to the desired number of seconds.
```bash
// One minute timeout
SVGEXPORT_TIMEOUT=60 svgexport input.svg output.png
```
### Node.js Module
#### Installation
```
npm install svgexport --save
```
#### Usage
```javascript
var svgexport = require('svgexport');
svgexport.render(datafile, callback);
```
`datafile` can be an object, an array of objects or a JSON file path, see command line usage for its format.
### Contributors
svgexport was migrated from PhantomJS to Puppeteer by [Michael Heerklotz](https://github.com/MichaelHeerklotz).
### License
Copyright (c) 2016 Ali Shakiba
Available under the MIT license
*Keywords: svg, export, rasterize, converter, png, jpeg, jpg, cli, command-line, inkscape, illustrator, coreldraw*
没有合适的资源?快使用搜索试试~ 我知道了~
一个通过智能算法将设计稿转换为前端页面的产品(design to code),是`低代码`平台的一个分支方向
共89个文件
js:35个
png:24个
json:6个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 77 浏览量
2023-07-05
17:36:28
上传
评论
收藏 2.73MB ZIP 举报
温馨提示
一个通过智能算法将设计稿转换为前端页面的产品(design to code),是`低代码`平台的一个分支方向, 他的输入是设计稿产出是前端页面,中间无需值守即可自动完成。此项目可以一键将 Sketch、Photoshop 的设计稿转换为可维护的前端代码。100 个 page 的工作量 10 分钟内即可轻松搞定,极大释放前端生产力。生产级代码:通过智能算法推算出和手写代码一样的结构和css逻辑,产出的代码约等于一个中级前端的水平。全flex布局。根据元素所处的环境, 自动修正像素误差,符合设计表达。代码可阅读、可维护.
资源推荐
资源详情
资源评论
收起资源包目录
lens-master.zip (89个子文件)
lens-master
db.sqlite3 15.07MB
.eslintrc.js 4KB
doc
demo
h5.gif 570KB
check.gif 326KB
qr.jpg 63KB
src
tools
styleflux
components
sassParser.js 6KB
index.js 1KB
sql.js 2KB
px2other.js 505B
svgexport
resize.js 1KB
package.json 908B
bin
index.js 62B
package-lock.json 84KB
test
svg
trans.svg 728B
simple.svg 1004B
viewbox-with-width-height.svg 1KB
viewbox.svg 1003B
expected
jpeg-low.jpg 2KB
36h-vb-wh.png 459B
18-18.png 1KB
36h-vb.png 5KB
16-16.png 1KB
32-32.png 4KB
36w-vb-wh.png 459B
32h.png 4KB
36h.png 5KB
2.5x18.png 8KB
2.5x18-vb.png 8KB
36w-vb.png 5KB
36w.png 5KB
test.png 1KB
offset.png 4KB
jpeg-high.jpg 8KB
32-64.png 8KB
40-40-vb-wh.png 782B
32-64-pad.png 8KB
2.5x40-vb-wh.png 2KB
64-32.png 8KB
64-32-pad.png 8KB
2.5x16.png 6KB
18-18-vb.png 1KB
32w.png 4KB
test.json 1KB
test-resize.js 858B
exported
.empty 0B
test.js 6KB
index.js 3KB
render.js 9KB
README.md 3KB
px2otherAst.js 1KB
parserSketch
svgToImg.js 30KB
path.js 2KB
style.js 7KB
layer.js 4KB
sketchToPng.js 25KB
font.js 4KB
render
mobile
index.js 3KB
template.art 2KB
uniapp
index.js 2KB
template.art 209B
base
bitmap.js 4KB
css.js 3KB
type.js 1KB
path.js 2KB
layer.js 8KB
text.js 6KB
index.js 3KB
tools.js 12KB
index.js 2KB
parseLayer
feature.js 2KB
styleNew.js 3KB
index.js 1KB
LICENSE 11KB
.ncurc.json 34B
demo
readme.md 718B
source
test.sketch 25KB
.yunjinrc.js 662B
h5
screenshot
list_match.png 199KB
list
list.css 2KB
list.html 4KB
design.md 161B
package.json 1KB
package-lock.json 336KB
.yunjinrc.js 665B
changeLog.md 5KB
.npmignore 111B
index.js 2KB
.gitignore 68B
.npmrc 372B
共 89 条
- 1
资源评论
Java程序员-张凯
- 粉丝: 1w+
- 资源: 6656
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Screenshot_20240430_144340_com.ss.android.ugc.live.jpg
- 回到山沟沟.mp3
- 基于matlab实现自适应波束形成RLS及LMS算法仿真源程序1.rar
- 基于matlab实现自己编写的基于卡尔曼滤波的利用加速度传感器的计步器,测试数据是传感器放在腰部和手臂 .rar
- 基于matlab实现阵列信号处理,波束形成.rar
- 111111111111111111
- 基于matlab实现计步器编程;对当前的计步器装置的数值算法模拟 .rar
- Mdb学习查看PW;access;mdb;pw;password;patch
- 基于matlab实现关于语音信号声源定位DOA估计所用的一些传统算法.rar
- 基于ultralytics-yolov8, 将其检测/分类/分割/姿态等任务移植到rk3588上
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功