MCPcopy Create free account
hub / github.com/ColmapView/Colmapview.github.io / convertToJpeg

Function convertToJpeg

src/parsers/imageZipExport.ts:20–28  ·  view source on GitHub ↗
(file: File, quality: number)

Source from the content-addressed store, hash-verified

18}
19
20export 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
30export function normalizeImageZipPath(path: string): string {
31 let normalized = path.replace(/\\/g, '/');

Callers 1

exportImagesZipFunction · 0.85

Calls 5

isJpegFileFunction · 0.85
drawImageMethod · 0.80
convertToBlobMethod · 0.80
closeMethod · 0.65
getContextMethod · 0.45

Tested by

no test coverage detected