From ccbec210e7349d137073c2f8554e68ca08ba9857 Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Thu, 15 Oct 2020 16:32:04 +1100 Subject: [PATCH] Fix ml map grid for safari and non divisible by 2 images --- src/helpers/map.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/helpers/map.js b/src/helpers/map.js index 76c56b7..e3b0f9b 100644 --- a/src/helpers/map.js +++ b/src/helpers/map.js @@ -78,11 +78,16 @@ async function gridSizeML(image, candidates) { let canvas = document.createElement("canvas"); let context = canvas.getContext("2d"); canvas.width = 2048; - canvas.height = 2048 / ratio; + canvas.height = Math.floor(2048 / ratio); context.drawImage(image, 0, 0, canvas.width, canvas.height); - let imageData = context.getImageData(0, canvas.height / 2 - 16, 2048, 32); + let imageData = context.getImageData( + 0, + Math.floor(canvas.height / 2) - 16, + 2048, + 32 + ); for (let i = 0; i < imageData.data.length; i += 4) { const r = imageData.data[i]; const g = imageData.data[i + 1];