{"record":{"id":"9d14340ee5debf85","repo":"sveltejs/kit","slug":"could-not-determine-intrinsic-dimensions-for-res","errorCode":null,"errorMessage":"Could not determine intrinsic dimensions for ${resolved_id}","messagePattern":"Could not determine intrinsic dimensions for (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/enhanced-img/src/vite-plugin.js","lineNumber":157,"sourceCode":"\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`Could not locate ${file_path}. Please move it to be located relative to the page in the routes directory or reference it beginning with /static/. See https://vitejs.dev/guide/assets for more details on referencing assets.`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Could not locate ${file_path}. See https://vitejs.dev/guide/assets for more details on referencing assets.`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (OPTIMIZABLE.test(url)) {\n\t\t\t\t\t\tconst image = await process_id(resolved_id, plugin_context, imagetools_plugin);\n\t\t\t\t\t\ts.update(node.start, node.end, img_to_picture(content, node, image));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst metadata = await sharp(resolved_id).metadata();\n\t\t\t\t\t\t// this must come after the await so that we don't hand off processing between getting\n\t\t\t\t\t\t// the imports.size and incrementing the imports.size\n\t\t\t\t\t\tconst name = imports.get(original_url) || '__IMPORTED_ASSET_' + imports.size + '__';\n\t\t\t\t\t\tif (!metadata.width || !metadata.height) {\n\t\t\t\t\t\t\tconsole.warn(`Could not determine intrinsic dimensions for ${resolved_id}`);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst new_markup = `<img ${serialize_img_attributes(content, node.attributes, {\n\t\t\t\t\t\t\tsrc: `{${name}}`,\n\t\t\t\t\t\t\twidth: metadata.width,\n\t\t\t\t\t\t\theight: metadata.height\n\t\t\t\t\t\t})} />`;\n\t\t\t\t\t\ts.update(node.start, node.end, new_markup);\n\t\t\t\t\t\timports.set(original_url, name);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t/**\n\t\t\t\t * @type {Array<ReturnType<typeof update_element>>}\n\t\t\t\t */\n\t\t\t\tconst pending_ast_updates = [];\n\n\t\t\t\twalk(/** @type {import('svelte/compiler').AST.TemplateNode} */ (ast), null, {\n\t\t\t\t\tRegularElement(node, { next }) {","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/enhanced-img/src/vite-plugin.js#L139-L175","documentation":"In enhanced-img's Vite plugin, update_element rewrites <img> tags in markup, calling sharp(resolved_id).metadata() to obtain intrinsic width/height for the generated attributes. If metadata lacks width or height, it warns that intrinsic dimensions could not be determined and still emits the markup, but width/height attributes may be undefined.","triggerScenarios":"Processing an <img src=\"...\"> in a Svelte component during transform (RegularElement handling) where sharp cannot extract dimensions from the resolved image file (corrupt file, unsupported format, or SVG without dimensions).","commonSituations":"Broken/corrupt images committed to the repo; SVG icons without width/height attributes; images referenced via aliases that resolve to wrong paths; sharp failing on certain CMYK or progressive JPEGs.","solutions":["Add explicit width and height attributes on the <img> tag so dimensions don't need to be inferred.","Validate/replace the image file with a known-good asset.","Give SVG files explicit width/height/viewBox attributes in their root element.","Ensure the resolved path is a real raster image (check import alias and extension)."],"exampleFix":"<!-- before -->\n<img src=\"$lib/assets/icon.svg\" alt=\"icon\" />\n<!-- after -->\n<img src=\"$lib/assets/icon.svg\" alt=\"icon\" width=\"32\" height=\"32\" />","handlingStrategy":"validation","validationCode":"import sharp from 'sharp';\nconst meta = await sharp(resolvedId).metadata();\nif (!meta.width || !meta.height) {\n  console.warn(`${resolvedId}: set explicit width/height on the <img> tag`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always set width/height attributes on imgs referencing unmeasurable assets","Ensure SVGs have explicit dimensions","Check resolved import paths point to valid raster files"],"tags":["enhanced-img","vite-plugin","image-processing","sharp","build-warning"],"backgroundTag":"image-dimensions-unknown","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}