Show Menu
TOPICS×

s7vampy.open_image(filename)

Open an image file.
Parameters:
filename (str)
Name of the image file that is loaded into memory.
Returns:
The image instance.
The supported image file formats are: BMP, JPEG, PNG, and TIFF.
Support is limited to RGB and grayscale images. Only RGB images can have an alpha channel. The alpha channel can be extracted and used as a mask using the s7vampy.image.Image.extract_alpha() method. RGBA images can also be used to build static overlapping objects using the [s7vampy.obj.Group.add_static_overlap_object()](../../c-s7vampy-api-reference/c-classes/c-objects/r-class-s7vampy-obj-staticoverlapobject.md#reference-7b66780df1fc40cfa436fecdc16037c5) method.
Grayscale images are used to for masks and illumination maps. Note that all images added to a vignette need to match the size of the vignette view image.
Opening an image:
>>> from s7vampy import *
>>> img = open_image("TestData/view.png")
>>> img {name='TestData/view.png', has_alpha=False, size=(422, 640)}

Failure while opening an image:
>>> from s7vampy import *
>>> open_image("TestData/does-not-exist.png")
Traceback (most recent call last):
RuntimeError: Open Failed: 'TestData/does-not-exist.png'