|
@ -21,8 +21,9 @@ const imageMerge = (sources = [], options = {format: 'image/png'}) => new Promis |
|
|
Promise.all(images) |
|
|
Promise.all(images) |
|
|
.then(images => { |
|
|
.then(images => { |
|
|
// Set canvas dimensions
|
|
|
// Set canvas dimensions
|
|
|
canvas.width = options.width || Math.max(...images.map(image => image.img.width)); |
|
|
const getSize = dim => options[dim] || Math.max(...images.map(image => image.img[dim])); |
|
|
canvas.height = options.height || Math.max(...images.map(image => image.img.height)); |
|
|
canvas.width = getSize('width'); |
|
|
|
|
|
canvas.height = getSize('height'); |
|
|
|
|
|
|
|
|
// Draw images to canvas
|
|
|
// Draw images to canvas
|
|
|
images.forEach(image => ctx.drawImage(image.img, image.x || 0, image.y || 0)); |
|
|
images.forEach(image => ctx.drawImage(image.img, image.x || 0, image.y || 0)); |
|
|