Skip to content

Latest commit

 

History

History
45 lines (32 loc) · 885 Bytes

readme.md

File metadata and controls

45 lines (32 loc) · 885 Bytes

image-to-pieces

This package takes an images and will cut it into multiple images.

Install

$ npm install image-to-pieces

Usage

With image

import ImageToPieces from 'image-to-pieces';
const img = new Image();

const rows = 5;
const columns = 5;

const Image = new ImageToPieces(img, columns, rows);

const tiles = Image.getTiles();

console.log(tiles)
-> [{data: "data:image/png;base64,..", index: 2,x: 120,y: 0}, {...}]

With image url

import ImageToPieces from 'image-to-pieces';

const rows = 5;
const columns = 5;

const Image = new ImageToPieces(null, columns, rows);
await Image.loadImageByUrl('https://picsum.photos/200');
const tiles = Image.getTiles();


console.log(tiles)
-> [{data: "data:image/png;base64,..", index: 2,x: 120,y: 0}, {...}]

Todo's

  • Improve performance
  • Create option to return the tiles in arrays by row