From e9dc54c4d9e61e0aefa1c106a51ddf27febc65a7 Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 13 Jun 2019 22:59:15 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=B5=E3=83=A0=E3=83=8D=E3=82=A4=E3=83=AB?= =?UTF-8?q?=E7=94=9F=E6=88=90=E3=81=A7=E3=82=A8=E3=83=A9=E3=83=BC=E3=81=AB?= =?UTF-8?q?=E3=81=AA=E3=81=A3=E3=81=A6=E3=82=82=E3=83=95=E3=82=A1=E3=82=A4?= =?UTF-8?q?=E3=83=AB=E3=81=AE=E3=82=A2=E3=83=83=E3=83=97=E3=83=AD=E3=83=BC?= =?UTF-8?q?=E3=83=89=E3=82=92=E5=A4=B1=E6=95=97=E3=81=97=E3=81=AA=E3=81=84?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #5050 --- src/services/drive/add-file.ts | 54 +++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/src/services/drive/add-file.ts b/src/services/drive/add-file.ts index d21c67d18..a2143ca60 100644 --- a/src/services/drive/add-file.ts +++ b/src/services/drive/add-file.ts @@ -149,18 +149,22 @@ export async function generateAlts(path: string, type: string, generateWeb: bool if (generateWeb) { logger.info(`creating web image`); - if (['image/jpeg'].includes(type)) { - webpublic = await convertToJpeg(path, 2048, 2048); - } else if (['image/webp'].includes(type)) { - webpublic = await convertToWebp(path, 2048, 2048); - } else if (['image/png'].includes(type)) { - webpublic = await convertToPng(path, 2048, 2048); - } else if (['image/apng', 'image/vnd.mozilla.apng'].includes(type)) { - webpublic = await convertToApng(path); - } else if (['image/gif'].includes(type)) { - webpublic = await convertToGif(path); - } else { - logger.info(`web image not created (not an image)`); + try { + if (['image/jpeg'].includes(type)) { + webpublic = await convertToJpeg(path, 2048, 2048); + } else if (['image/webp'].includes(type)) { + webpublic = await convertToWebp(path, 2048, 2048); + } else if (['image/png'].includes(type)) { + webpublic = await convertToPng(path, 2048, 2048); + } else if (['image/apng', 'image/vnd.mozilla.apng'].includes(type)) { + webpublic = await convertToApng(path); + } else if (['image/gif'].includes(type)) { + webpublic = await convertToGif(path); + } else { + logger.info(`web image not created (not an image)`); + } + } catch (e) { + logger.warn(`web image not created (an error occured)`, e); } } else { logger.info(`web image not created (from remote)`); @@ -170,18 +174,22 @@ export async function generateAlts(path: string, type: string, generateWeb: bool // #region thumbnail let thumbnail: IImage | null = null; - if (['image/jpeg', 'image/webp'].includes(type)) { - thumbnail = await convertToJpeg(path, 498, 280); - } else if (['image/png'].includes(type)) { - thumbnail = await convertToPng(path, 498, 280); - } else if (['image/gif'].includes(type)) { - thumbnail = await convertToGif(path); - } else if (type.startsWith('video/')) { - try { - thumbnail = await GenerateVideoThumbnail(path); - } catch (e) { - logger.error(`GenerateVideoThumbnail failed: ${e}`); + try { + if (['image/jpeg', 'image/webp'].includes(type)) { + thumbnail = await convertToJpeg(path, 498, 280); + } else if (['image/png'].includes(type)) { + thumbnail = await convertToPng(path, 498, 280); + } else if (['image/gif'].includes(type)) { + thumbnail = await convertToGif(path); + } else if (type.startsWith('video/')) { + try { + thumbnail = await GenerateVideoThumbnail(path); + } catch (e) { + logger.error(`GenerateVideoThumbnail failed: ${e}`); + } } + } catch (e) { + logger.warn(`thumbnail not created (an error occured)`, e); } // #endregion thumbnail