MCPcopy Index your code
hub / github.com/ColmapView/Colmapview.github.io / fetchUrlImageRaw

Function fetchUrlImageRaw

src/utils/urlImageFiles.ts:141–165  ·  view source on GitHub ↗
(
  imageUrlBase: string | null,
  imageName: string,
  explicitUrl?: string
)

Source from the content-addressed store, hash-verified

139 * Metric computations use this path because lossy cached images bias PSNR.
140 */
141export async function fetchUrlImageRaw(
142 imageUrlBase: string | null,
143 imageName: string,
144 explicitUrl?: string
145): Promise<File | null> {
146 const resolved = resolveImageRequestUrl(imageUrlBase, imageName, explicitUrl);
147 if (!resolved) {
148 return null;
149 }
150 const { url: imageUrl, filename } = resolved;
151
152 try {
153 const response = await fetch(imageUrl);
154 if (!response.ok) {
155 appLogger.warn(`[URL Image] Failed to fetch raw ${imageName}: ${response.status}`);
156 return null;
157 }
158
159 const blob = await response.blob();
160 return new File([blob], filename, { type: blob.type || 'application/octet-stream' });
161 } catch (err) {
162 appLogger.warn(`[URL Image] Error fetching raw ${imageName}:`, err);
163 return null;
164 }
165}
166
167/**
168 * Fetch a mask from URL.

Callers 2

getMetricImageFunction · 0.90

Calls 2

resolveImageRequestUrlFunction · 0.85
blobMethod · 0.80

Tested by

no test coverage detected