Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zprodev/9-slicer
Convert PNG to 9slice
https://github.com/zprodev/9-slicer
esmodules nine-patch nineslice
Last synced: 8 days ago
JSON representation
Convert PNG to 9slice
- Host: GitHub
- URL: https://github.com/zprodev/9-slicer
- Owner: zprodev
- License: mit
- Created: 2018-08-14T12:50:43.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-08-03T20:35:32.000Z (over 3 years ago)
- Last Synced: 2024-12-15T06:10:06.381Z (19 days ago)
- Topics: esmodules, nine-patch, nineslice
- Language: TypeScript
- Homepage:
- Size: 647 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 9-slicer
[![Build Status](https://travis-ci.org/zprodev/9-slicer.svg?branch=master)](https://travis-ci.org/zprodev/9-slicer)
[![npm](https://img.shields.io/npm/v/9-slicer.svg)](https://www.npmjs.com/package/9-slicer)
[![license](https://img.shields.io/github/license/zprodev/9-slicer.svg)](LICENSE)Automatically judge the enlarged area and create 9 slice images
## Examples
### input
![input.png](https://raw.githubusercontent.com/zprodev/9-slicer/master/docs/img/input.png)
### output
Sliced PNG
![output.png](https://raw.githubusercontent.com/zprodev/9-slicer/master/docs/img/output.png)
Parameters
```
{ width: 420,
height: 240,
left: 46,
right: 45,
top: 48,
bottom: 48 }
```## Demo
[9 SLICER](https://zprodev.github.io/9-slicer/demo/)
## Distribution
### npm
```
npm i -D 9-slicer
```### files
[for CommonJS](https://github.com/zprodev/9-slicer/tree/master/dist/cjs)
[for Browser](https://github.com/zprodev/9-slicer/tree/master/dist/browser)
[for ESModules](https://github.com/zprodev/9-slicer/tree/master/dist/esm)
## Usage
### for CommonJS
```
const { readFileSync, writeFileSync } = require('fs');
const { slice } = require('9-slicer');const input = readFileSync('input.png');
const output = slice(input);// Example of outputting only things that can be reduced by 30% or more
if(30 <= output.reduction){
writeFileSync('output.png', output.buffer);
writeFileSync('output.json', JSON.stringify(output.params));
}
```