From 92934502e817f1c5b278b54f0b2c70f5a83c8cf7 Mon Sep 17 00:00:00 2001 From: juliandescottes Date: Tue, 9 May 2017 00:06:22 +0200 Subject: [PATCH] fix merge of smaller piskel into bigger piskel --- src/js/utils/MergeUtils.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/js/utils/MergeUtils.js b/src/js/utils/MergeUtils.js index 4e270eb..8f69e49 100644 --- a/src/js/utils/MergeUtils.js +++ b/src/js/utils/MergeUtils.js @@ -17,11 +17,15 @@ * @return {Piskel} The new Piskel instance created */ merge : function (piskel, importedPiskel, options) { + var isImportedPiskelBigger = + importedPiskel.getWidth() > piskel.getWidth() || + importedPiskel.getHeight() > piskel.getHeight(); + // First make sure both the piskel and the imported piskel use the target dimensions. - if (options.resize === 'expand') { + if (isImportedPiskelBigger && options.resize === 'expand') { piskel = pskl.utils.ResizeUtils.resizePiskel(piskel, { - width : importedPiskel.getWidth(), - height : importedPiskel.getHeight(), + width : Math.max(piskel.getWidth(), importedPiskel.getWidth()), + height : Math.max(piskel.getHeight(), importedPiskel.getHeight()), origin : options.origin, resizeContent: false });