Package Exports
- trim-canvas-blank
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (trim-canvas-blank) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
trim-canvas-blank
A lightweight library for trimming canvas blank, no dependencies.
Installation
npm
npm i -S trim-canvas-blank
yarn
yarn add trim-canvas-blank
Usage
import trimCanvas from "trim-canvas-blank";
const canvas = document.querySelector("canvas");
const image = document.querySelector(".render-img");
let outputCanvas;
// simple usage
outputCanvas = trimCanvas(canvas);
// or you can custom padding
outputCanvas = trimCanvas(canvas, {
padding: 12, // default 0
// padding: [24, 12, 24, 12], // [top, right, bottom, left]
});
// output
const src = outputCanvas.toDataURL("image/png");
image.src = src;
Demo
You can see a demo of trim-canvas-blank
here.