Skip to content

Commit

Permalink
correct bug when trying to enhance JPG images (#1928)
Browse files Browse the repository at this point in the history
This fix was authored by @mebelz and is reissued here to base it on
`main`.
  • Loading branch information
lstein authored Dec 11, 2022
1 parent 7efe0f3 commit f745f78
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ldm/invoke/pngwriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,13 @@ def retrieve_metadata(img_path):
metadata stored there, as a dict
'''
im = Image.open(img_path)
md = im.text.get('sd-metadata', '{}')
dream_prompt = im.text.get('Dream', '')
if hasattr(im, 'text'):
md = im.text.get('sd-metadata', '{}')
dream_prompt = im.text.get('Dream', '')
else:
# When trying to retrieve metadata from images without a 'text' payload, such as JPG images.
md = '{}'
dream_prompt = ''
return {'sd-metadata': json.loads(md), 'Dream': dream_prompt}

def write_metadata(img_path:str, meta:dict):
Expand Down

0 comments on commit f745f78

Please sign in to comment.