{"record":{"id":"01d9d9a193df9e5f","repo":"linshenkx/prompt-optimizer","slug":"this-png-file-does-not-contain-prompt-optimizer-fa","errorCode":null,"errorMessage":"This PNG file does not contain Prompt Optimizer favorite share data. Use the original exported PNG file; screenshots or compressed images cannot be imported.","messagePattern":"This PNG file does not contain Prompt Optimizer favorite share data\\. Use the original exported PNG file; screenshots or compressed images cannot be imported\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/ui/src/utils/favorite-share-export.ts","lineNumber":1461,"sourceCode":"}\n\nexport const readFavoriteSharePackage = (\n  input: ArrayBuffer | Uint8Array | string,\n): Uint8Array => {\n  if (typeof input === 'string') {\n    const parser = new DOMParser()\n    const document = parser.parseFromString(input, 'text/html')\n    const script = document.getElementById(FAVORITE_SHARE_HTML_SCRIPT_ID)\n    if (!script?.textContent) {\n      throw new Error('This HTML file does not contain Prompt Optimizer favorite share data')\n    }\n    return base64ToBytes(parseSharePayload(script.textContent).packageBase64)\n  }\n\n  const bytes = input instanceof Uint8Array ? input : new Uint8Array(input)\n  const chunk = readPngTextChunk(bytes, FAVORITE_SHARE_PNG_TEXT_KEYWORD)\n  if (!chunk) {\n    throw new Error('This PNG file does not contain Prompt Optimizer favorite share data. Use the original exported PNG file; screenshots or compressed images cannot be imported.')\n  }\n  return base64ToBytes(parseSharePayload(chunk).packageBase64)\n}\n\nexport const looksLikeFavoriteShareHtml = (\n  fileName: string | undefined,\n  text: string,\n): boolean => {\n  const normalizedName = String(fileName || '').toLowerCase()\n  return (\n    normalizedName.endsWith('.html') ||\n    normalizedName.endsWith('.htm') ||\n    text.includes(FAVORITE_SHARE_HTML_SCRIPT_ID)\n  ) && text.includes(FAVORITE_SHARE_SCHEMA_VERSION)\n}\n\nexport const looksLikeFavoriteSharePng = (\n  fileName: string | undefined,","sourceCodeStart":1443,"sourceCodeEnd":1479,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/ui/src/utils/favorite-share-export.ts#L1443-L1479","documentation":"When given binary input (Uint8Array/ArrayBuffer), readFavoriteSharePackage looks for a tEXt chunk with the favorite-share keyword and throws if none exists. Screenshots, re-encodes, or any process that rewrites PNG data destroy metadata chunks, so only the original exported PNG can be re-imported.","triggerScenarios":"Importing a PNG that was screenshotted, re-saved by an image editor, compressed by a chat app, or re-encoded after upload — all of which drop the tEXt chunk; or importing a PNG that never contained share data.","commonSituations":"Users send the exported PNG through WhatsApp/Slack/imgur which strips metadata or re-encodes; users take a screenshot of the PNG instead of saving it; image CDN or build pipeline (sharp, squoosh) optimizing away tEXt chunks.","solutions":["Import the original exported PNG file, not a screenshot or re-shared copy","Transfer the file as a file attachment preserving bytes (avoid messenger image compression)","Before importing, sniff for the chunk yourself with readPngTextChunk(bytes, FAVORITE_SHARE_PNG_TEXT_KEYWORD) and show a clear message","Prefer exporting the HTML share format when the transfer channel re-compresses images"],"exampleFix":"// before\nconst pkg = readFavoriteSharePackage(pngBytes)\n\n// after\nconst chunk = readPngTextChunk(pngBytes, FAVORITE_SHARE_PNG_TEXT_KEYWORD)\nif (!chunk) {\n  throw new UserError('No share data in this PNG. Please use the original exported file.')\n}\nconst pkg = readFavoriteSharePackage(pngBytes)","handlingStrategy":"validation","validationCode":"const bytes = new Uint8Array(await file.arrayBuffer())\nconst hasPayload = readPngTextChunk(bytes, FAVORITE_SHARE_PNG_TEXT_KEYWORD) != null\nif (!hasPayload) throw new UserError('Use the original exported PNG; screenshots cannot be imported')","typeGuard":"const hasFavoriteShareChunk = (b: Uint8Array): boolean =>\n  isPng(b) && readPngTextChunk(b, FAVORITE_SHARE_PNG_TEXT_KEYWORD) != null","tryCatchPattern":"try { readFavoriteSharePackage(pngBytes) } catch (e) { if (e.message.includes('screenshots or compressed images')) askForOriginalFile(); else throw e }","preventionTips":["Send exported PNGs as file attachments to avoid re-encoding","Never screenshot the export; download it","Prefer the HTML share format over lossy channels"],"tags":["png","metadata","import","lossy-transfer"],"backgroundTag":"missing-payload-in-file","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}