Skip to content

Preserve newlines when importing prompts from PNG metadata - #2574

Open
amiiari wants to merge 1 commit into
Acly:mainfrom
amiiari:fix-png-import-newlines
Open

Preserve newlines when importing prompts from PNG metadata #2574
amiiari wants to merge 1 commit into
Acly:mainfrom
amiiari:fix-png-import-newlines

Conversation

@amiiari

@amiiari amiiari commented Jul 21, 2026

Copy link
Copy Markdown

Fixes #2565, changes were coded by Claude Opus 4.8!

Problem: QImageReader.text() collapsed newlines inside PNG text chunks then flattened them to a single line.

What this code does now is:

  • Add Image.read_png_text(), which parses tEXt/zTXt/iTXt chunks directly (mirroring the existing manual-write path save_png_w_itxt), and keeps the text byte-for-byte.
  • import_prompt_from_file() now reads PNG metadata through it; non-PNG formats still fall back to Qt.

QImageReader.text() collapses newlines inside PNG text chunks, so multi-line
prompts imported via import_prompt_from_file() were flattened to a single line
(issue Acly#2565).

Add Image.read_png_text(), which parses tEXt/zTXt/iTXt chunks directly
(mirroring the existing manual-write path save_png_w_itxt) and keeps the text
byte-for-byte. import_prompt_from_file() now reads PNG metadata through it;
non-PNG formats still fall back to Qt.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prompt line formatting breaks on import from stable diffusion image

1 participant