{"record":{"id":"5c973f158623d05f","repo":"santifer/career-ops","slug":"unsupported-image-type-extname-inputpath","errorCode":null,"errorMessage":"Unsupported image type: ${extname(inputPath) || '(no extension)'}. Supported: ${Object.keys(MIME_TYPES).join(', ')}","messagePattern":"Unsupported image type: (.+?)\\. Supported: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"img-to-pdf.mjs","lineNumber":107,"sourceCode":"  console.log('');\n  console.log('  --force   overwrite <output-path> if it already exists');\n  console.log('');\n  console.log('MVP scope: one image in, one PDF page out. Multi-image/multi-page is not supported.');\n}\n\n/**\n * Render a single image file to a single-page PDF matching the image's own\n * pixel dimensions (at 96 CSS px/inch), so the output is neither cropped\n * nor padded with blank margins.\n *\n * @param {string} inputPath - Absolute path to the source image.\n * @param {string} outputPath - Absolute path to write the PDF to.\n * @returns {Promise<{outputPath: string, size: number, width: number, height: number}>}\n */\nexport async function convertImageToPdf(inputPath, outputPath) {\n  const mimeType = detectMimeType(inputPath);\n  if (!mimeType) {\n    throw new Error(`Unsupported image type: ${extname(inputPath) || '(no extension)'}. Supported: ${Object.keys(MIME_TYPES).join(', ')}`);\n  }\n\n  const buffer = await readFile(inputPath);\n  const base64 = buffer.toString('base64');\n  const html = `<!doctype html>\n<html>\n<head>\n<meta charset=\"utf-8\">\n<style>\n  * { margin: 0; padding: 0; }\n  html, body { margin: 0; padding: 0; }\n  img { display: block; }\n</style>\n</head>\n<body>\n<img id=\"career-ops-img\" src=\"data:${mimeType};base64,${base64}\">\n</body>\n</html>`;","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/santifer/career-ops/blob/9b17a8ac97b398a496b38e423ae24e433b43254f/img-to-pdf.mjs#L89-L125","documentation":"Thrown by convertImageToPdf() in img-to-pdf.mjs when detectMimeType() returns null because the file extension is not in the MIME_TYPES allowlist (.png, .jpg/.jpeg, .gif, .webp, .bmp, .svg). The message echoes the offending extension (or '(no extension)') and lists supported types so the caller knows exactly what to convert to.","triggerScenarios":"Passing an image with an unsupported or missing extension: .tiff, .heic, .avif, .pdf, .ico, or a file with no extension at all. detectMimeType keys off extname lowercased against MIME_TYPES, so case is handled but format is not.","commonSituations":"User drops a HEIC from an iPhone or a .tiff from a scanner into the pipeline; a screenshot saved as .avif by a newer browser; a recruiter's photo attached as a PDF renamed .jpg.","solutions":["Convert the image to a supported format first: .png or .jpg — use `magick input.tiff output.png` or `sips -s format png input.heic --out output.png`.","Rename to the correct extension if the file is actually a supported format but mislabeled (verify with `file input`).","If SVG fails despite being listed, ensure it is well-formed XML (detectMimeType accepts .svg but rendering still requires valid markup).","For .heic/.avif/.tiff, add an upstream conversion step to your pipeline rather than extending MIME_TYPES — Chromium rasterization of those is unreliable."],"exampleFix":"// before\nawait convertImageToPdf('photo.heic', 'photo.pdf');\n// throws: Unsupported image type: .heic\n\n// after — convert first\n// shell: magick photo.heic photo.png\nawait convertImageToPdf('photo.png', 'photo.pdf');","handlingStrategy":"validation","validationCode":"const SUPPORTED = new Set(['.png', '.jpg', '.jpeg', '.gif', '.webp', '.bmp', '.svg']);\nconst ext = extname(inputPath).toLowerCase();\nif (!SUPPORTED.has(ext)) {\n  throw new Error(`Pre-check: convert '${ext || 'no-ext'}' to PNG/JPEG before calling convertImageToPdf.`);\n}","typeGuard":"/** True if the path's extension is in img-to-pdf's MIME_TYPES allowlist. */\nfunction isSupportedImage(path) {\n  const SUPPORTED = new Set(['.png', '.jpg', '.jpeg', '.gif', '.webp', '.bmp', '.svg']);\n  return SUPPORTED.has(extname(path).toLowerCase());\n}","tryCatchPattern":null,"preventionTips":["Convert HEIC/AVIF/TIFF to PNG upstream — do not extend MIME_TYPES for formats Chromium rasterizes poorly.","Validate extension before invoking the pipeline; surface a clear pre-check error.","Confirm the file's real type with `file` when extension looks wrong.","Reject files with no extension early in the intake UI."],"tags":["image","pdf","validation","file-format"],"backgroundTag":null,"analyzedSha":"9b17a8ac97b398a496b38e423ae24e433b43254f","analyzedAt":"2026-08-13T00:48:39.135Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}