fix save metadata

This commit is contained in:
Vladimir Mandic
2023-08-27 07:48:33 +00:00
parent f45adac44a
commit 05a2e12ce4
3 changed files with 5 additions and 4 deletions
+2 -1
View File
@@ -351,7 +351,8 @@ class FilenameGenerator:
buffered = BytesIO()
self.image.save(buffered, format="JPEG")
img_str = base64.b64encode(buffered.getvalue())
return hashlib.sha256(img_str).hexdigest()[0:8]
shorthash = hashlib.sha256(img_str).hexdigest()[0:8]
return shorthash
def prompt_no_style(self):
if self.p is None or self.prompt is None:
+1 -1
View File
@@ -1083,7 +1083,7 @@ class StableDiffusionProcessingImg2Img(StableDiffusionProcessing):
for img in self.init_images:
# Save init image
if shared.opts.save_init_img:
self.init_img_hash = hashlib.md5(img.tobytes()).hexdigest() # pylint: disable=attribute-defined-outside-init
self.init_img_hash = hashlib.sha256(img.tobytes()).hexdigest()[0:8] # pylint: disable=attribute-defined-outside-init
images.save_image(img, path=shared.opts.outdir_init_images, basename=None, forced_filename=self.init_img_hash, save_to_dirs=False)
image = images.flatten(img, shared.opts.img2img_background_color)
if crop_region is None and self.resize_mode != 4:
+2 -2
View File
@@ -119,8 +119,8 @@ def save_files(js_data, images, html_info, index):
shared.log.info(f"Copying image: {fullfn} -> {destination}")
else:
image = image_from_url_text(filedata)
# infotext is offset by 1 because the first image is the grid
fullfn, txt_fullfn = modules.images.save_image(image, shared.opts.outdir_save, "", seed=p.all_seeds[i], prompt=p.all_prompts[i], info=p.infotexts[i + 1], extension=shared.opts.samples_format, grid=is_grid, p=p, save_to_dirs=shared.opts.use_save_to_dirs_for_ui)
info = p.infotexts[i + 1] if len(p.infotexts) > len(p.all_seeds) else p.infotexts[i] # infotexts may be offset by 1 because the first image is the grid
fullfn, txt_fullfn = modules.images.save_image(image, shared.opts.outdir_save, "", seed=p.all_seeds[i], prompt=p.all_prompts[i], info=info, extension=shared.opts.samples_format, grid=is_grid, p=p, save_to_dirs=shared.opts.use_save_to_dirs_for_ui)
if fullfn is None:
continue
filename = os.path.relpath(fullfn, shared.opts.outdir_save)