From 05a2e12ce4353ea6da5bff487864dc674ffb2871 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Sun, 27 Aug 2023 07:48:33 +0000 Subject: [PATCH] fix save metadata --- modules/images.py | 3 ++- modules/processing.py | 2 +- modules/ui_common.py | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/images.py b/modules/images.py index fe032ab27..b7332a808 100644 --- a/modules/images.py +++ b/modules/images.py @@ -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: diff --git a/modules/processing.py b/modules/processing.py index d561a6c1d..a12168031 100644 --- a/modules/processing.py +++ b/modules/processing.py @@ -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: diff --git a/modules/ui_common.py b/modules/ui_common.py index 32e89e5f2..0f1ea52e3 100644 --- a/modules/ui_common.py +++ b/modules/ui_common.py @@ -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)