From 8a0b9d2e8d23496f0ff48dddfc8fb48310fba29d Mon Sep 17 00:00:00 2001 From: Victor Seiji Hariki Date: Sat, 17 Dec 2022 02:07:10 -0300 Subject: [PATCH] fix saving canvas negative images Signed-off-by: Victor Seiji Hariki --- js/lib/util.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/js/lib/util.js b/js/lib/util.js index 23a88e6..b79fb05 100644 --- a/js/lib/util.js +++ b/js/lib/util.js @@ -364,8 +364,8 @@ function downloadCanvas(options = {}) { defaultOpt(options, { cropToContent: true, canvas: uil.getVisible({ - x: 0, - y: 0, + x: -imageCollection.origin.x, + y: -imageCollection.origin.y, w: imageCollection.size.w, h: imageCollection.size.h, }), @@ -384,6 +384,7 @@ function downloadCanvas(options = {}) { var croppedCanvas = options.cropToContent ? cropCanvas(options.canvas).canvas : options.canvas; + if (croppedCanvas != null) { croppedCanvas.toBlob((blob) => { link.href = URL.createObjectURL(blob);