( imageUrlBase: string | null, imageName: string, explicitUrl?: string )
| 139 | * Metric computations use this path because lossy cached images bias PSNR. |
| 140 | */ |
| 141 | export 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. |
no test coverage detected