emcconville / wand

The ctypes-based simple ImageMagick binding for Python
http://docs.wand-py.org/
Other
1.42k stars 199 forks source link

How to globally call images #635

Closed monkeycc closed 1 year ago

monkeycc commented 1 year ago

External call image required

from wand.image import Image

aaimg = None

def aa():
    global aaimg
    with Image(filename=r"E:\1.tiff") as img:
        print("width =", img.width)
        print("height =", img.height)

        img.resize(1280, 1280)

        aaimg = img

aa()

print("aaimg", aaimg)
aaimg <wand.image.Image: (closed)>
Show closed
emcconville commented 1 year ago

You would not, as accessing the instance outside of the context manager would result in a closed image.