(file: File, quality: number)
| 18 | } |
| 19 | |
| 20 | export async function convertToJpeg(file: File, quality: number): Promise<Blob> { |
| 21 | const effectiveQuality = isJpegFile(file) ? Math.min(quality, 0.85) : quality; |
| 22 | const bitmap = await createImageBitmap(file); |
| 23 | const canvas = new OffscreenCanvas(bitmap.width, bitmap.height); |
| 24 | const ctx = canvas.getContext('2d')!; |
| 25 | ctx.drawImage(bitmap, 0, 0); |
| 26 | bitmap.close(); |
| 27 | return canvas.convertToBlob({ type: 'image/jpeg', quality: effectiveQuality }); |
| 28 | } |
| 29 | |
| 30 | export function normalizeImageZipPath(path: string): string { |
| 31 | let normalized = path.replace(/\\/g, '/'); |
no test coverage detected