Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

draft: fix jpeg and exif data handling #6176

Closed

Conversation

vladmandic
Copy link
Collaborator

@vladmandic vladmandic commented Jan 1, 2023

using jpeg in automatic was somewhat broken when going back-and-forth from txt2img to extras as exif data was overwritten
and switching backt to png meant that pnginfo data was corrupt with previously encoded exif data

  • initialize pnginfo if exif data is already present
  • generate exif string from pnginfo` so they are always in-sync
  • fix infamous KeyError: '.jpg' (not fully fixed in Dirty fix for missing PIL supported file extensions #5838 and tons of bug reports to quote)
  • avoid double file write when saving jpeg file

@dathide
Copy link

dathide commented Jan 4, 2023

I've been using this for a few hours and haven't encountered any issues. Edit: Thanks for your work on this!

@AUTOMATIC1111
Copy link
Owner

exif_str += str(v) if k == 'parameters' else f"\n{k}: {v}"

Why is extra stuff added here? Will pnginfo tab be able to read this properly?

@vladmandic
Copy link
Collaborator Author

vladmandic commented Jan 4, 2023

exif_str += str(v) if k == 'parameters' else f"\n{k}: {v}"

Why is extra stuff added here? Will pnginfo tab be able to read this properly?

previously only latest info passed was used as exif string, so any previous info was simply lost.

for example txt2img worked fine as that is "new info", but then using upscaling from extras would append correct info (as a separate section) in pnginfo, but use only new info from extras to create exif string - previous info was lost.

this simply uses whatever is in pnginfo to create exif string and does not try to create exif string separately.
and yes, png info has no issues with it.

@AUTOMATIC1111
Copy link
Owner

firefox_8opJNppDQT

Here's what I get when I send params from png info to txt2img. The image was generated in txt2img and upscaled in extras tab.

Here's the image.
02135

Also I'm against making this more complicated for PNG info or putting some extended format into JPEG comment. I would prefer if JPEGs stayed as they are.

@vladmandic
Copy link
Collaborator Author

ok, this is an issue and i'll fix it.

i don't think jpeg can stay as-is as its broken - exif gets overwritten with every new operation - its totally unusable
(unlike metadata in png files which is perfect)

@vladmandic vladmandic changed the title fix jpeg and exif data handling draft: fix jpeg and exif data handling Jan 4, 2023
@vladmandic vladmandic closed this Jan 4, 2023
@vladmandic vladmandic deleted the fix-jpeg-and-exif-handling branch January 4, 2023 16:21
This pull request was closed.
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.

3 participants