https://github.com/rwson/png-merger
auto merge pngs to an sprite image and auto replace csses's background refrence
https://github.com/rwson/png-merger
command-line-tool merge nodejs
Last synced: 3 months ago
JSON representation
auto merge pngs to an sprite image and auto replace csses's background refrence
- Host: GitHub
- URL: https://github.com/rwson/png-merger
- Owner: rwson
- Created: 2017-12-25T03:21:16.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-10T02:41:24.000Z (over 8 years ago)
- Last Synced: 2025-12-25T17:10:16.136Z (7 months ago)
- Topics: command-line-tool, merge, nodejs
- Language: JavaScript
- Size: 18.8 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# png-merger
自动将项目中的零散png合并成雪碧图并修改css中的引用
### 测试
```bash
git clone https://github.com/rwson/png-merger.git
cd path/to/png-merger
npm install
npm test
```
### 使用
```bash
npm install png-merger -g
# 用法①
#Teiminal切到项目根目录下
#初始化雪碧图配置文件
png-merger init
#合并符合条件的png
png-merger
# 用法②
#Teiminal切到项目根目录下
#把配置项当成命令行参数传递
png-merger i=test/images i=test/imgs c=test l=0.7 s=200x200
```
### 参数说明
| 参数 | 简写 | 意义 |
|:------------- |:-------------|:-----|
| images |i|图片目录, 支持多个|
| csses |c|样式文件目录, 支持多个|
| level |l|优化级别, 0 ~ 1|
| size |s|图片尺寸小于等于width * height时, 才会被合并|
### 可能存在的问题
由于没有用`node-canvas`之类的模块,所以`png-merger`依赖了[puppeteer](https://github.com/GoogleChrome/puppeteer), 安装`puppeteer`时, 可能会下载`Chromium`, 所以需要提前设置下`PUPPETEER_DOWNLOAD_HOST`
```bash
export PUPPETEER_DOWNLOAD_HOST=https://storage.googleapis.com.cnpmjs.org
npm install png-merger -g
```