linshenkx/prompt-optimizer · error · Error
This PNG file does not contain Prompt Optimizer favorite sha
Error message
This PNG file does not contain Prompt Optimizer favorite share data. Use the original exported PNG file; screenshots or compressed images cannot be imported.
What it means
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.
Source
Thrown at packages/ui/src/utils/favorite-share-export.ts:1461
}
export const readFavoriteSharePackage = (
input: ArrayBuffer | Uint8Array | string,
): Uint8Array => {
if (typeof input === 'string') {
const parser = new DOMParser()
const document = parser.parseFromString(input, 'text/html')
const script = document.getElementById(FAVORITE_SHARE_HTML_SCRIPT_ID)
if (!script?.textContent) {
throw new Error('This HTML file does not contain Prompt Optimizer favorite share data')
}
return base64ToBytes(parseSharePayload(script.textContent).packageBase64)
}
const bytes = input instanceof Uint8Array ? input : new Uint8Array(input)
const chunk = readPngTextChunk(bytes, FAVORITE_SHARE_PNG_TEXT_KEYWORD)
if (!chunk) {
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.')
}
return base64ToBytes(parseSharePayload(chunk).packageBase64)
}
export const looksLikeFavoriteShareHtml = (
fileName: string | undefined,
text: string,
): boolean => {
const normalizedName = String(fileName || '').toLowerCase()
return (
normalizedName.endsWith('.html') ||
normalizedName.endsWith('.htm') ||
text.includes(FAVORITE_SHARE_HTML_SCRIPT_ID)
) && text.includes(FAVORITE_SHARE_SCHEMA_VERSION)
}
export const looksLikeFavoriteSharePng = (
fileName: string | undefined,View on GitHub (pinned to 3e677b1d9f)
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
Example fix
// before
const pkg = readFavoriteSharePackage(pngBytes)
// after
const chunk = readPngTextChunk(pngBytes, FAVORITE_SHARE_PNG_TEXT_KEYWORD)
if (!chunk) {
throw new UserError('No share data in this PNG. Please use the original exported file.')
}
const pkg = readFavoriteSharePackage(pngBytes) Defensive patterns
Strategy: validation
Validate before calling
const bytes = new Uint8Array(await file.arrayBuffer())
const hasPayload = readPngTextChunk(bytes, FAVORITE_SHARE_PNG_TEXT_KEYWORD) != null
if (!hasPayload) throw new UserError('Use the original exported PNG; screenshots cannot be imported') Type guard
const hasFavoriteShareChunk = (b: Uint8Array): boolean => isPng(b) && readPngTextChunk(b, FAVORITE_SHARE_PNG_TEXT_KEYWORD) != null
Try / catch
try { readFavoriteSharePackage(pngBytes) } catch (e) { if (e.message.includes('screenshots or compressed images')) askForOriginalFile(); else throw e } Prevention
- Send exported PNGs as file attachments to avoid re-encoding
- Never screenshot the export; download it
- Prefer the HTML share format over lossy channels
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Prompt asset is not available for this favorite
- Invalid import data format
- Import data contains favorite with empty content
- Invalid function mode in import data: functionMode=${functio
- Failed to import favorites: ${errorMessage}
AI-assisted analysis of linshenkx/prompt-optimizer@3e677b1d9f (2026-08-27).
Data as JSON: /api/errors/01d9d9a193df9e5f.
Report an issue: GitHub.