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

Function fetchZipImage

src/utils/zipImageFiles.ts:47–78  ·  view source on GitHub ↗
(imageName: string)

Source from the content-addressed store, hash-verified

45 * Returns the cached File if already extracted, otherwise extracts and caches.
46 */
47export async function fetchZipImage(imageName: string): Promise<File | null> {
48 const cached = zipImageState.getCached(imageName);
49 if (cached) return cached;
50
51 if (!hasActiveZipArchive()) return null;
52
53 if (zipImageState.isRequestPending(imageName)) {
54 return zipImageState.waitForRequest(imageName);
55 }
56
57 zipImageState.startRequest(imageName);
58 let result: File | null = null;
59
60 try {
61 const extractedFile = await extractZipImage(imageName);
62 if (!extractedFile) {
63 return null;
64 }
65
66 const filename = imageName.split('/').pop() || imageName;
67 const file = await compressAndResizeToJpeg(new Blob([await extractedFile.arrayBuffer()]), filename);
68 zipImageState.setCached(imageName, file);
69 result = file;
70
71 return file;
72 } catch (err) {
73 appLogger.warn(`[ZIP Image] Error extracting ${imageName}:`, err);
74 return null;
75 } finally {
76 zipImageState.completeRequest(imageName, result);
77 }
78}
79
80/**
81 * Extract an image from ZIP without display-cache resizing or JPEG recompression.

Callers 4

getImageFunction · 0.90
prefetchImagesFunction · 0.90

Calls 9

compressAndResizeToJpegFunction · 0.90
hasActiveZipArchiveFunction · 0.85
extractZipImageFunction · 0.85
getCachedMethod · 0.80
isRequestPendingMethod · 0.80
waitForRequestMethod · 0.80
startRequestMethod · 0.80
setCachedMethod · 0.80
completeRequestMethod · 0.80

Tested by

no test coverage detected