1
0
forked from mirror/misskey

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/png',
'image/gif',
'image/apng',
'image/vnd.mozilla.apng',
];
this.$root.api('users/notes', {

View File

@ -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', {

View File

@ -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', {

View File

@ -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,

View File

@ -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', {

View File

@ -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 = {

View File

@ -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

View File

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