APNGでもMIME typeはimage/pngにするように

This commit is contained in:
mei23 2019-07-04 23:04:09 +09:00
parent dfd991a6c6
commit e579eb2bf4
No known key found for this signature in database
GPG key ID: DD8628500D3E4B23
8 changed files with 12 additions and 17 deletions

View file

@ -98,8 +98,6 @@ export default Vue.extend({
'image/jpeg', 'image/jpeg',
'image/png', 'image/png',
'image/gif', 'image/gif',
'image/apng',
'image/vnd.mozilla.apng',
]; ];
this.$root.api('users/notes', { this.$root.api('users/notes', {

View file

@ -39,8 +39,6 @@ export default Vue.extend({
'image/jpeg', 'image/jpeg',
'image/png', 'image/png',
'image/gif', 'image/gif',
'image/apng',
'image/vnd.mozilla.apng',
]; ];
this.$root.api('users/notes', { this.$root.api('users/notes', {

View file

@ -187,8 +187,6 @@ export default Vue.extend({
'image/jpeg', 'image/jpeg',
'image/png', 'image/png',
'image/gif', 'image/gif',
'image/apng',
'image/vnd.mozilla.apng',
]; ];
this.$root.api('notes/local-timeline', { this.$root.api('notes/local-timeline', {

View file

@ -31,8 +31,6 @@ export default Vue.extend({
'image/jpeg', 'image/jpeg',
'image/png', 'image/png',
'image/gif', 'image/gif',
'image/apng',
'image/vnd.mozilla.apng',
]; ];
this.$root.api('users/notes', { this.$root.api('users/notes', {
userId: this.user.id, userId: this.user.id,

View file

@ -111,8 +111,6 @@ export default Vue.extend({
'image/jpeg', 'image/jpeg',
'image/png', 'image/png',
'image/gif', 'image/gif',
'image/apng',
'image/vnd.mozilla.apng',
]; ];
this.$root.api('notes/local-timeline', { this.$root.api('notes/local-timeline', {

View file

@ -15,15 +15,20 @@ export async function proxyMedia(ctx: Koa.BaseContext) {
try { try {
await downloadUrl(url, path); 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; if (!type.startsWith('image/')) throw 403;
let image: IImage; 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); 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); image = await convertToJpeg(path, 200, 200);
} else { } else {
image = { image = {

View file

@ -36,6 +36,8 @@ async function save(file: DriveFile, path: string, name: string, type: string, h
// thunbnail, webpublic を必要なら生成 // thunbnail, webpublic を必要なら生成
const alts = await generateAlts(path, type, !file.uri); const alts = await generateAlts(path, type, !file.uri);
if (type === 'image/apng') type = 'image/png';
const meta = await fetchMeta(); const meta = await fetchMeta();
if (meta.useObjectStorage) { 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/jpeg') ext = '.jpg';
if (type === 'image/png') ext = '.png'; if (type === 'image/png') ext = '.png';
if (type === 'image/webp') ext = '.webp'; if (type === 'image/webp') ext = '.webp';
if (type === 'image/apng') ext = '.apng';
if (type === 'image/vnd.mozilla.apng') ext = '.apng';
} }
const baseUrl = meta.objectStorageBaseUrl const baseUrl = meta.objectStorageBaseUrl

View file

@ -96,7 +96,7 @@ export async function convertToApng(path: string): Promise<IImage> {
return { return {
data, data,
ext: 'apng', ext: 'png',
type: 'image/vnd.mozilla.apng' type: 'image/png'
}; };
} }