From 93f80504544687609a47797808d880a433c3cf69 Mon Sep 17 00:00:00 2001 From: perissology Date: Wed, 9 Jan 2019 06:29:49 -0800 Subject: [PATCH] use resizedImage if image optimization fails --- src/services/image.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/services/image.js b/src/services/image.js index 2f4b15c16..bfbe2d796 100644 --- a/src/services/image.js +++ b/src/services/image.js @@ -1,6 +1,7 @@ "use strict"; const repository = require('./repository'); +const log = require('./log'); const protectedSessionService = require('./protected_session'); const noteService = require('./notes'); const imagemin = require('imagemin'); @@ -13,7 +14,13 @@ const sanitizeFilename = require('sanitize-filename'); async function saveImage(buffer, originalName, parentNoteId) { const resizedImage = await resize(buffer); - const optimizedImage = await optimize(resizedImage); + let optimizedImage; + try { + optimizedImage = await optimize(resizedImage); + } catch (e) { + log.error(e); + optimizedImage = resizedImage; + } const imageFormat = imageType(optimizedImage);