File size: 2,297 Bytes
9c5ffc0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from __future__ import annotations

from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from PIL import Image, PngImagePlugin

    from sd_webui.processing import StableDiffusionProcessing

    def save_image(
        image: Image.Image,
        path: str,
        basename: str,
        seed: int | None = None,
        prompt: str = "",
        extension: str = "png",
        info: str | PngImagePlugin.iTXt = "",
        short_filename: bool = False,
        no_prompt: bool = False,
        grid: bool = False,
        pnginfo_section_name: str = "parameters",
        p: StableDiffusionProcessing | None = None,
        existing_info: dict | None = None,
        forced_filename: str | None = None,
        suffix: str = "",
        save_to_dirs: bool = False,
    ) -> tuple[str, str | None]:
        """Save an image.

        Args:
            image (`PIL.Image`):
                The image to be saved.
            path (`str`):
                The directory to save the image. Note, the option `save_to_dirs` will make the image to be saved into a sub directory.
            basename (`str`):
                The base filename which will be applied to `filename pattern`.
            seed, prompt, short_filename,
            extension (`str`):
                Image file extension, default is `png`.
            pngsectionname (`str`):
                Specify the name of the section which `info` will be saved in.
            info (`str` or `PngImagePlugin.iTXt`):
                PNG info chunks.
            existing_info (`dict`):
                Additional PNG info. `existing_info == {pngsectionname: info, ...}`
            no_prompt:
                TODO I don't know its meaning.
            p (`StableDiffusionProcessing`)
            forced_filename (`str`):
                If specified, `basename` and filename pattern will be ignored.
            save_to_dirs (bool):
                If true, the image will be saved into a subdirectory of `path`.

        Returns: (fullfn, txt_fullfn)
            fullfn (`str`):
                The full path of the saved imaged.
            txt_fullfn (`str` or None):
                If a text file is saved for this image, this will be its full path. Otherwise None.
        """

else:
    from modules.images import save_image