This commit is contained in:
tamaina 2022-01-29 21:02:58 +09:00
parent 8fcf86cb52
commit 3236ebac6b
3 changed files with 8 additions and 9 deletions

View file

@ -11,7 +11,7 @@ import { DriveFiles } from '@/models/index';
import { InternalStorage } from '@/services/drive/internal-storage';
import { downloadUrl } from '@/misc/download-url';
import { detectType } from '@/misc/get-file-info';
import { convertToJpeg, convertToPng } from '@/services/drive/image-processor';
import { convertToWebp, convertToPng } from '@/services/drive/image-processor';
import { GenerateVideoThumbnail } from '@/services/drive/generate-video-thumbnail';
import { StatusError } from '@/misc/fetch';
import { FILE_TYPE_BROWSERSAFE } from '@/const';
@ -65,10 +65,8 @@ export default async function(ctx: Koa.Context) {
const convertFile = async () => {
if (isThumbnail) {
if (['image/jpeg', 'image/webp'].includes(mime)) {
return await convertToJpeg(path, 498, 280);
} else if (['image/png', 'image/svg+xml'].includes(mime)) {
return await convertToPng(path, 498, 280);
if (['image/jpeg', 'image/webp', 'image/png', 'image/svg+xml'].includes(mime)) {
return await convertToWebp(path, 498, 280);
} else if (mime.startsWith('video/')) {
return await GenerateVideoThumbnail(path);
}

View file

@ -194,6 +194,7 @@ export async function generateAlts(path: string, type: string, generateWeb: bool
}
satisfyWebpublic = !!(
type !== 'image/svg+xml' &&
!(metadata.exif || metadata.iptc || metadata.xmp || metadata.tifftagPhotoshop) &&
metadata.width && metadata.width <= 2048 &&
metadata.height && metadata.height <= 2048

View file

@ -16,10 +16,10 @@ export const uploads = ref<Uploading[]>([]);
const compressTypeMap = new Map([
// [圧縮前の形式, 圧縮後の形式],
['image/jpeg', 'image/jpeg'],
['image/webp', 'image/jpeg'],
['image/png', 'image/png'],
['image/svg', 'image/png'],
['image/jpeg', 'image/webp'],
['image/webp', 'image/webp'],
['image/png', 'image/webp'],
['image/svg', 'image/webp'],
]);
export function uploadFile(file: File, folder?: any, name?: string, keepOriginal: boolean = defaultStore.state.keepOriginalUploading): Promise<Misskey.entities.DriveFile> {