From f2ac90299c8713de2c7bee12f6256b65c9d11cdc Mon Sep 17 00:00:00 2001 From: Oj Date: Thu, 1 Jul 2021 20:25:00 +0100 Subject: [PATCH] [ImageCDN] Copy if failed to use ImageMagick --- src/imageCdn.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/imageCdn.js b/src/imageCdn.js index 492746f..a66a9c2 100644 --- a/src/imageCdn.js +++ b/src/imageCdn.js @@ -31,7 +31,12 @@ export default (manifest) => { }); if (rawExt !== 'gif') { - await new Promise((res) => exec(`convert "${rawFile}" -resize x720 -quality 90 "${finalFile}"`, res)); + try { + await new Promise((res) => exec(`convert "${rawFile}" -resize x720 -quality 90 "${finalFile}"`, res)); + } catch (e) { + console.error('Failed to use ImageMagick to resize and compress, copying file as backup'); + copyFileSync(rawFile, finalFile); + } } else { copyFileSync(rawFile, finalFile); }