API reference
BlendedImage
BlendedImage(background, images, positions=None, opacities=None, background_resize=None, image_scales=None, remove=None, cropped=None, images_crop=None, code=None)
The one and only object of this package!
Initiates the blended image, which is a superposition of images on a background. The images can be moved, resized and cropped, their opacity can be changed, their background color can be removed. The background can be cropped or expanded. The layers can be interchanged.
The blended image can be displayed in a Jupyter Notebook, saved as a PIL.Image.Image
or a numpy.ndarray
.
A code is generated to save the parameters of the blended image, and reproduce it later with different images.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
background |
Image or ndarray
|
Background image. |
required |
images |
Image or ndarray or list
|
Image to superpose. |
required |
positions |
list or None
|
Position of the image on the background. |
None
|
opacities |
list or None
|
Opacity of the image. |
None
|
background_resize |
list or None
|
Coefficient to resize the background. |
None
|
image_scales |
list or None
|
Height of the images in percentage of the background height. |
None
|
remove |
list or None
|
Remove specific color from the image. |
None
|
cropped |
list or None
|
Crop or expand the background. |
None
|
images_crop |
list or None
|
Crop the images. |
None
|
code |
str or None
|
Code to reproduce a previously created blended image. |
None
|
Examples:
>>> from istacky import BlendedImage
>>> from PIL import Image
>>> background = Image.open("background.jpg")
>>> top_layer = Image.open("image1.jpg")
>>> bottom_layer = Image.open("image2.jpg")
>>> blended_image = BlendedImage(background, [top_layer, bottom_layer])
editor
Displays the GUI, an interface made of widgets which can be displayed in a Jupyter Notebook.
Returns:
Type | Description |
---|---|
widgets
|
Widget to edit the blended image. |
get_code
Get the code to reproduce the blended image. A code is generated to save the parameters of the blended image, and reproduce it later with different images.
Returns:
Type | Description |
---|---|
str
|
Code to reproduce the blended image. |
to_array
Return the blended image as a numpy.ndarray
.
Returns:
Type | Description |
---|---|
ndarray
|
Blended image. |