JSFiddle - React, Tailwind, and code Playground

HTML

<canvas id="canvas1"></canvas>

JavaScript

// функция перемешивающая массив
function shuffle(array) {
  let i = array.length;
  while (i--) {
    let j = Math.floor(Math.random() * (i + 1));
    [array[i], array[j]] = [array[j], array[i]];
  }
  return array;
}

// функция добавляющая картинку на страницу
function toImage(canvas, type) {
  document.body.append(Object.assign(new Image(), {
    src: canvas.toDataURL(type)
  }));
}

const x = 150; // ширина одного
const y = 150; // высота одного
const w = 2; // сколько в ряду

// картинки, должны быть на том же домене или иметь Access-Control-Allow-Origin
const images = [
  "https://picsum.photos/seed/aaa/150",
  "https://picsum.photos/seed/bbb/150",
  "https://picsum.photos/seed/ccc/150",
  "https://picsum.photos/seed/ddd/150"
]; 

const h = Math.ceil(images.length / w); // сколько в столбце

var canvas = Object.assign(document.getElementById('canvas1'), {
  width: w * x,
  height: h * y
});
var ctx = canvas.getContext('2d');

Promise.all(
  shuffle(images).map((src, i) => new Promise(
    (onload, onerror) => Object.assign(new Image(), {
      crossOrigin: 'anonymous',
      src, 
      onerror,
      onload
    })
  ).then(({target}) => {
    const hPos = Math.floor(i / w);
    const wPos = i - (hPos * w);
    
    ctx.drawImage(
      target, 
      wPos * x, 
      hPos * y,  
      x, 
      y
    )
  }))
).then(() => {
  toImage(canvas, 'image/jpeg');
  toImage(canvas, 'image/png');
});