webpでなくする ただしサムネやプレビューはwebpのまま (テスト)
This commit is contained in:
		
							parent
							
								
									e87e97fce4
								
							
						
					
					
						commit
						e7d9221a71
					
				
					 4 changed files with 10 additions and 9 deletions
				
			
		|  | @ -63,7 +63,7 @@ export async function populateEmoji(emojiName: string, noteUserHost: string | nu | |||
| 
 | ||||
| 	const isLocal = emoji.host == null; | ||||
| 	const emojiUrl = emoji.publicUrl || emoji.originalUrl; // || emoji.originalUrl してるのは後方互換性のため
 | ||||
| 	const url = isLocal ? emojiUrl : `${config.url}/proxy/${encodeURIComponent(emojiUrl)}?${query({ url: emojiUrl })}`; | ||||
| 	const url = isLocal ? emojiUrl : `${config.url}/proxy/${encodeURIComponent((new URL(emojiUrl)).pathname)}?${query({ url: emojiUrl })}`; | ||||
| 
 | ||||
| 	return { | ||||
| 		name: emojiName, | ||||
|  |  | |||
|  | @ -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 { convertToWebp } from '@/services/drive/image-processor'; | ||||
| import { convertToWebp, convertToJpeg, 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'; | ||||
|  | @ -74,7 +74,7 @@ export default async function(ctx: Koa.Context) { | |||
| 
 | ||||
| 					if (isWebpublic) { | ||||
| 						if (['image/svg+xml'].includes(mime)) { | ||||
| 							return await convertToWebp(path, 2048, 2048, 100); | ||||
| 							return await convertToPng(path, 2048, 2048); | ||||
| 						} | ||||
| 					} | ||||
| 
 | ||||
|  |  | |||
|  | @ -194,7 +194,7 @@ export async function generateAlts(path: string, type: string, generateWeb: bool | |||
| 		} | ||||
| 
 | ||||
| 		satisfyWebpublic = !!( | ||||
| 			type !== 'image/svg+xml' && | ||||
| 			type !== 'image/svg+xml' && type !== 'image/webp' && | ||||
| 			!(metadata.exif || metadata.iptc || metadata.xmp || metadata.tifftagPhotoshop) && | ||||
| 			metadata.width && metadata.width <= 2048 && | ||||
| 			metadata.height && metadata.height <= 2048 | ||||
|  | @ -214,10 +214,12 @@ export async function generateAlts(path: string, type: string, generateWeb: bool | |||
| 		logger.info(`creating web image`); | ||||
| 
 | ||||
| 		try { | ||||
| 			if (['image/webp', 'image/jpeg'].includes(type)) { | ||||
| 				webpublic = await convertSharpToWebp(img, 2048, 2048); | ||||
| 			} else if (['image/png', 'image/svg+xml'].includes(type)) { | ||||
| 				webpublic = await convertSharpToWebp(img, 2048, 2048, 100); | ||||
| 			if (['image/jpeg', 'image/webp'].includes(type)) { | ||||
| 				webpublic = await convertSharpToJpeg(img, 2048, 2048); | ||||
| 			} else if (['image/png'].includes(type)) { | ||||
| 				webpublic = await convertSharpToPng(img, 2048, 2048); | ||||
| 			} else if (['image/svg+xml'].includes(type)) { | ||||
| 				webpublic = await convertSharpToPng(img, 2048, 2048); | ||||
| 			} else { | ||||
| 				logger.debug(`web image not created (not an required image)`); | ||||
| 			} | ||||
|  |  | |||
|  | @ -16,7 +16,6 @@ export const uploads = ref<Uploading[]>([]); | |||
| const compressTypeMap = { | ||||
| 	'image/jpeg': { quality: 0.85 }, | ||||
| 	'image/webp': { quality: 0.85, mimeType: 'image/jpeg'}, | ||||
| 	'image/png': { quality: 1 }, | ||||
| 	'image/svg+xml': { quality: 1, mimeType: 'image/png'}, | ||||
| } as const; | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue