Skip to content

An NPM module, Intelli Image Crop, intelligently removes white spaces from raster images.

License

Notifications You must be signed in to change notification settings

wonmor/intelli-image-crop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

intelli-image-crop

Intelli Image Crop intelligently removes white spaces from raster images. For Javascript and Typescript users.

npm version


Screenshot-1

Usage

  1. Import the module...
const removeImageBlanks = require('intelli-image-crop'); // Legacy Javascript
import removeImageBlanks from 'intelli-image-crop'; // Modern Javascript (React)
  1. Usage example...
const imageObject = ...; // Your image object
const padding = 10; // Padding value
const cornerRadius = 20; // Corner radius value

const result = removeImageBlanks(imageObject, padding, cornerRadius);
  1. Make sure the imageObject is rasterized (in pixels, not vectors) before you begin...
// Rasterize the canvas
const rasterizedCanvas = document.createElement("canvas");

// Make SURE you mutiply the width and height with the DPR (Device Pixel Ratio)
// for support on high-resolution displays!
rasterizedCanvas.width = viewerCanvas.offsetWidth * window.devicePixelRatio;
rasterizedCanvas.height = viewerCanvas.offsetHeight * window.devicePixelRatio;

const rasterizedContext = rasterizedCanvas.getContext("2d");

rasterizedContext.drawImage(viewerCanvas, 0, 0);

Releases

No releases published

Packages

No packages published