This package takes an images and will cut it into multiple images.
$ npm install image-to-pieces
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}, {...}]
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}, {...}]
- Improve performance
- Create option to return the tiles in arrays by row