From e579eb2bf44f526cabfa9bd4adc6b4fa84727e3b Mon Sep 17 00:00:00 2001 From: mei23 Date: Thu, 4 Jul 2019 23:04:09 +0900 Subject: [PATCH] =?UTF-8?q?APNG=E3=81=A7=E3=82=82MIME=20type=E3=81=AFimage?= =?UTF-8?q?/png=E3=81=AB=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/common/views/deck/deck.user-column.home.vue | 2 -- .../app/desktop/views/home/user/user.photos.vue | 2 -- src/client/app/desktop/views/pages/welcome.vue | 2 -- .../app/mobile/views/pages/user/home.photos.vue | 2 -- src/client/app/mobile/views/pages/welcome.vue | 2 -- src/server/proxy/proxy-media.ts | 11 ++++++++--- src/services/drive/add-file.ts | 4 ++-- src/services/drive/image-processor.ts | 4 ++-- 8 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/client/app/common/views/deck/deck.user-column.home.vue b/src/client/app/common/views/deck/deck.user-column.home.vue index 49cc869eb9..923cb9224b 100644 --- a/src/client/app/common/views/deck/deck.user-column.home.vue +++ b/src/client/app/common/views/deck/deck.user-column.home.vue @@ -98,8 +98,6 @@ export default Vue.extend({ 'image/jpeg', 'image/png', 'image/gif', - 'image/apng', - 'image/vnd.mozilla.apng', ]; this.$root.api('users/notes', { diff --git a/src/client/app/desktop/views/home/user/user.photos.vue b/src/client/app/desktop/views/home/user/user.photos.vue index 03abcf865c..fca0a31c4a 100644 --- a/src/client/app/desktop/views/home/user/user.photos.vue +++ b/src/client/app/desktop/views/home/user/user.photos.vue @@ -39,8 +39,6 @@ export default Vue.extend({ 'image/jpeg', 'image/png', 'image/gif', - 'image/apng', - 'image/vnd.mozilla.apng', ]; this.$root.api('users/notes', { diff --git a/src/client/app/desktop/views/pages/welcome.vue b/src/client/app/desktop/views/pages/welcome.vue index 511e1548e5..48ab772cbf 100644 --- a/src/client/app/desktop/views/pages/welcome.vue +++ b/src/client/app/desktop/views/pages/welcome.vue @@ -187,8 +187,6 @@ export default Vue.extend({ 'image/jpeg', 'image/png', 'image/gif', - 'image/apng', - 'image/vnd.mozilla.apng', ]; this.$root.api('notes/local-timeline', { diff --git a/src/client/app/mobile/views/pages/user/home.photos.vue b/src/client/app/mobile/views/pages/user/home.photos.vue index b5547c916f..dfafb99768 100644 --- a/src/client/app/mobile/views/pages/user/home.photos.vue +++ b/src/client/app/mobile/views/pages/user/home.photos.vue @@ -31,8 +31,6 @@ export default Vue.extend({ 'image/jpeg', 'image/png', 'image/gif', - 'image/apng', - 'image/vnd.mozilla.apng', ]; this.$root.api('users/notes', { userId: this.user.id, diff --git a/src/client/app/mobile/views/pages/welcome.vue b/src/client/app/mobile/views/pages/welcome.vue index 6cf4a36f90..2c8d37df52 100644 --- a/src/client/app/mobile/views/pages/welcome.vue +++ b/src/client/app/mobile/views/pages/welcome.vue @@ -111,8 +111,6 @@ export default Vue.extend({ 'image/jpeg', 'image/png', 'image/gif', - 'image/apng', - 'image/vnd.mozilla.apng', ]; this.$root.api('notes/local-timeline', { diff --git a/src/server/proxy/proxy-media.ts b/src/server/proxy/proxy-media.ts index eadfab54a3..7f3b9bab2d 100644 --- a/src/server/proxy/proxy-media.ts +++ b/src/server/proxy/proxy-media.ts @@ -15,15 +15,20 @@ export async function proxyMedia(ctx: Koa.BaseContext) { try { await downloadUrl(url, path); - const [type, ext] = await detectMine(path); + let [type, ext] = await detectMine(path); + + if (type === 'image/apng') { + type = 'image/png'; + ext = 'png'; + } if (!type.startsWith('image/')) throw 403; let image: IImage; - if ('static' in ctx.query && ['image/png', 'image/gif', 'image/apng', 'image/vnd.mozilla.apng'].includes(type)) { + if ('static' in ctx.query && ['image/png', 'image/gif'].includes(type)) { image = await convertToPng(path, 498, 280); - } else if ('preview' in ctx.query && ['image/jpeg', 'image/png', 'image/gif', 'image/apng', 'image/vnd.mozilla.apng'].includes(type)) { + } else if ('preview' in ctx.query && ['image/jpeg', 'image/png', 'image/gif'].includes(type)) { image = await convertToJpeg(path, 200, 200); } else { image = { diff --git a/src/services/drive/add-file.ts b/src/services/drive/add-file.ts index e7b1e2a812..176603e1fa 100644 --- a/src/services/drive/add-file.ts +++ b/src/services/drive/add-file.ts @@ -36,6 +36,8 @@ async function save(file: DriveFile, path: string, name: string, type: string, h // thunbnail, webpublic を必要なら生成 const alts = await generateAlts(path, type, !file.uri); + if (type === 'image/apng') type = 'image/png'; + const meta = await fetchMeta(); if (meta.useObjectStorage) { @@ -46,8 +48,6 @@ async function save(file: DriveFile, path: string, name: string, type: string, h if (type === 'image/jpeg') ext = '.jpg'; if (type === 'image/png') ext = '.png'; if (type === 'image/webp') ext = '.webp'; - if (type === 'image/apng') ext = '.apng'; - if (type === 'image/vnd.mozilla.apng') ext = '.apng'; } const baseUrl = meta.objectStorageBaseUrl diff --git a/src/services/drive/image-processor.ts b/src/services/drive/image-processor.ts index 919d9ce138..94f62cc516 100644 --- a/src/services/drive/image-processor.ts +++ b/src/services/drive/image-processor.ts @@ -96,7 +96,7 @@ export async function convertToApng(path: string): Promise { return { data, - ext: 'apng', - type: 'image/vnd.mozilla.apng' + ext: 'png', + type: 'image/png' }; }