9-slicer 中文文档教程
9-slicer
自动判断放大的区域并创建 9
Examples
input
切片
output
图像
个 "https://raw.githubusercontent.com/zprodev/9-slicer/master/docs/img/output.png" alt="output.png">
参数
{ width: 420,
height: 240,
left: 46,
right: 45,
top: 48,
bottom: 48 }
Demo
Distribution
npm
npm i -D 9-slicer
files
< a href="https://github.com/zprodev/9-slicer/tree/master/dist/browser">用于浏览器
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));
}
9-slicer
Automatically judge the enlarged area and create 9 slice images
Examples
input
output
Sliced PNG
Parameters
{ width: 420,
height: 240,
left: 46,
right: 45,
top: 48,
bottom: 48 }
Demo
Distribution
npm
npm i -D 9-slicer
files
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));
}