Gimp.Layer¶
- Subclasses:
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
- Inherited:
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent_instance |
r |
Class Details¶
- class Gimp.Layer(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
Operations on a single layer.
- classmethod from_mask(mask)¶
- Parameters:
mask (
Gimp.LayerMask
) – Mask for which to return the layer.- Returns:
The mask’s layer.
- Return type:
Get the specified mask’s layer.
This procedure returns the specified mask’s layer , or -1 if none exists.
New in version 2.2.
- classmethod get_by_id(layer_id)¶
- Parameters:
layer_id (
int
) – The layer id.- Returns:
a
Gimp.Layer
for layer_id orNone
if layer_id does not represent a valid layer. The object belongs to libgimp and you must not modify or unref it.- Return type:
Gimp.Layer
orNone
Returns a
Gimp.Layer
representing layer_id. This function callsGimp.Item.get_by_id
() and returns the item if it is layer orNone
otherwise.New in version 3.0.
- classmethod new(image, name, width, height, type, opacity, mode)¶
- Parameters:
image (
Gimp.Image
) – The image to which to add the layer.width (
int
) – The layer width.height (
int
) – The layer height.type (
Gimp.ImageType
) – The layer type.opacity (
float
) – The layer opacity.mode (
Gimp.LayerMode
) – The layer combination mode.
- Returns:
The newly created layer. The object belongs to libgimp and you should not free it.
- Return type:
Create a new layer.
This procedure creates a new layer with the specified width, height and type. If name is
None
, a default layer name will be used. opacity and mode are also supplied parameters.The new layer still needs to be added to the image as this is not automatic. Add the new layer with the [method`Image`.insert_layer] method.
Other attributes such as layer mask modes and offsets should be set with explicit procedure calls.
- classmethod new_from_drawable(drawable, dest_image)¶
- Parameters:
drawable (
Gimp.Drawable
) – The source drawable from where the new layer is copied.dest_image (
Gimp.Image
) – The destination image to which to add the layer.
- Returns:
The newly copied layer.
- Return type:
Create a new layer by copying an existing drawable.
This procedure creates a new layer as a copy of the specified drawable. The new layer still needs to be added to the image, as this is not automatic. Add the new layer with the
Gimp.Image.insert_layer
() command. Other attributes such as layer mask modes, and offsets should be set with explicit procedure calls.
- classmethod new_from_pixbuf(image, name, pixbuf, opacity, mode, progress_start, progress_end)¶
- Parameters:
image (
Gimp.Image
) – The RGB image to which to add the layer.name (
str
) – The layer name.pixbuf (
GdkPixbuf.Pixbuf
) – AGdkPixbuf.Pixbuf
.opacity (
float
) – The layer opacity.mode (
Gimp.LayerMode
) – The layer combination mode.progress_start (
float
) – start of progressprogress_end (
float
) – end of progress
- Returns:
The newly created layer. The object belongs to libgimp and you should not free it.
- Return type:
Create a new layer from a
GdkPixbuf.Pixbuf
.This procedure creates a new layer from the given
GdkPixbuf.Pixbuf
. The image has to be an RGB image and just like withGimp.Layer.new
() you will still need to add the layer to it.If you pass progress_end > progress_start to this function,
Gimp.progress_update
() will be called for. You have to callGimp.progress_init
() beforehand then.New in version 2.2.
- classmethod new_from_surface(image, name, surface, progress_start, progress_end)¶
- Parameters:
image (
Gimp.Image
) – The RGB image to which to add the layer.name (
str
) – The layer name.surface (
cairo.Surface
) – A Cairo image surface.progress_start (
float
) – start of progressprogress_end (
float
) – end of progress
- Returns:
The newly created layer. The object belongs to libgimp and you should not free it.
- Return type:
Create a new layer from a [type`cairo`.Surface].
This procedure creates a new layer from the given [type`cairo`.Surface]. The image has to be an RGB image and just like with
Gimp.Layer.new
() you will still need to add the layer to it.If you pass progress_end > progress_start to this function,
Gimp.progress_update
() will be called for. You have to callGimp.progress_init
() beforehand then.New in version 2.8.
- classmethod new_from_visible(image, dest_image, name)¶
- Parameters:
image (
Gimp.Image
) – The source image from where the content is copied.dest_image (
Gimp.Image
) – The destination image to which to add the layer.
- Returns:
The newly created layer.
- Return type:
Create a new layer from what is visible in an image.
This procedure creates a new layer from what is visible in the given image. The new layer still needs to be added to the destination image, as this is not automatic. Add the new layer with the
Gimp.Image.insert_layer
() command. Other attributes such as layer mask modes, and offsets should be set with explicit procedure calls.New in version 2.6.
- add_alpha()¶
-
Add an alpha channel to the layer if it doesn’t already have one.
This procedure adds an additional component to the specified layer if it does not already possess an alpha channel. An alpha channel makes it possible to clear and erase to transparency, instead of the background color. This transforms layers of type RGB to RGBA, GRAY to GRAYA, and INDEXED to INDEXEDA.
- add_mask(mask)¶
- Parameters:
mask (
Gimp.LayerMask
) – The mask to add to the layer.- Returns:
True
on success.- Return type:
Add a layer mask to the specified layer.
This procedure adds a layer mask to the specified layer. Layer masks serve as an additional alpha channel for a layer. This procedure will fail if a number of prerequisites aren’t met. The layer cannot already have a layer mask. The specified mask must exist and have the same dimensions as the layer. The layer must have been created for use with the specified image and the mask must have been created with the procedure ‘gimp-layer-create-mask’.
- copy()¶
- Returns:
The newly copied layer. The object belongs to libgimp and you should not free it.
- Return type:
Copy a layer.
This procedure copies the specified layer and returns the copy. The newly copied layer is for use within the original layer’s image. It should not be subsequently added to any other image.
- create_mask(mask_type)¶
- Parameters:
mask_type (
Gimp.AddMaskType
) – The type of mask.- Returns:
The newly created mask.
- Return type:
Create a layer mask for the specified layer.
This procedure creates a layer mask for the specified layer. Layer masks serve as an additional alpha channel for a layer. Different types of masks are allowed for initialisation:
white mask (leaves the layer fully visible);
black mask (gives the layer complete transparency);
the layer’s alpha channel (either a copy, or a transfer, which leaves the layer fully visible, but which may be more useful than a white mask);
the current selection;
a grayscale copy of the layer;
or a copy of the active channel.
The layer mask still needs to be added to the layer. This can be done with a call to
Gimp.Layer.add_mask
().Gimp.Layer.create_mask
() will fail if there are no active channels on the image, when called with ‘ADD-CHANNEL-MASK’. It will return a black mask when called with ‘ADD-ALPHA-MASK’ or ‘ADD-ALPHA-TRANSFER-MASK’ on a layer with no alpha channels, or with ‘ADD-SELECTION-MASK’ when there is no selection on the image.
- flatten()¶
-
Remove the alpha channel from the layer if it has one.
This procedure removes the alpha channel from a layer, blending all (partially) transparent pixels in the layer against the background color. This transforms layers of type RGBA to RGB, GRAYA to GRAY, and INDEXEDA to INDEXED.
New in version 2.4.
- get_apply_mask()¶
- Returns:
The layer’s apply mask setting.
- Return type:
Get the apply mask setting of the specified layer.
This procedure returns the specified layer’s apply mask setting. If the value is
True
, then the layer mask for this layer is currently being composited with the layer’s alpha channel.
- get_blend_space()¶
- Returns:
The layer blend space.
- Return type:
Get the blend space of the specified layer.
This procedure returns the specified layer’s blend space.
New in version 2.10.
- get_composite_mode()¶
- Returns:
The layer composite mode.
- Return type:
Get the composite mode of the specified layer.
This procedure returns the specified layer’s composite mode.
New in version 2.10.
- get_composite_space()¶
- Returns:
The layer composite space.
- Return type:
Get the composite space of the specified layer.
This procedure returns the specified layer’s composite space.
New in version 2.10.
- get_edit_mask()¶
- Returns:
The layer’s edit mask setting.
- Return type:
Get the edit mask setting of the specified layer.
This procedure returns the specified layer’s edit mask setting. If the value is
True
, then the layer mask for this layer is currently active, and not the layer.
- get_lock_alpha()¶
- Returns:
The layer’s lock alpha channel setting.
- Return type:
Get the lock alpha channel setting of the specified layer.
This procedure returns the specified layer’s lock alpha channel setting.
- get_mask()¶
- Returns:
The layer mask.
- Return type:
Get the specified layer’s mask if it exists.
This procedure returns the specified layer’s mask, or -1 if none exists.
- get_mode()¶
- Returns:
The layer combination mode.
- Return type:
Get the combination mode of the specified layer.
This procedure returns the specified layer’s combination mode.
- get_opacity()¶
- Returns:
The layer opacity.
- Return type:
Get the opacity of the specified layer.
This procedure returns the specified layer’s opacity.
- get_show_mask()¶
- Returns:
The layer’s show mask setting.
- Return type:
Get the show mask setting of the specified layer.
This procedure returns the specified layer’s show mask setting. This controls whether the layer or its mask is visible.
True
indicates that the mask should be visible. If the layer has no mask, then this function returns an error.
- is_floating_sel()¶
-
Is the specified layer a floating selection?
This procedure returns whether the layer is a floating selection. Floating selections are special cases of layers which are attached to a specific drawable.
- remove_mask(mode)¶
- Parameters:
mode (
Gimp.MaskApplyMode
) – Removal mode.- Returns:
True
on success.- Return type:
Remove the specified layer mask from the layer.
This procedure removes the specified layer mask from the layer. If the mask doesn’t exist, an error is returned.
- resize(new_width, new_height, offx, offy)¶
- Parameters:
- Returns:
True
on success.- Return type:
Resize the layer to the specified extents.
This procedure resizes the layer so that its new width and height are equal to the supplied parameters. Offsets are also provided which describe the position of the previous layer’s content. This operation only works if the layer has been added to an image.
- resize_to_image_size()¶
-
Resize a layer to the image size.
This procedure resizes the layer so that it’s new width and height are equal to the width and height of its image container.
- scale(new_width, new_height, local_origin)¶
- Parameters:
- Returns:
True
on success.- Return type:
Scale the layer using the default interpolation method.
This procedure scales the layer so that its new width and height are equal to the supplied parameters. The ‘local-origin’ parameter specifies whether to scale from the center of the layer, or from the image origin. This operation only works if the layer has been added to an image. The interpolation method used can be set with
Gimp.context_set_interpolation
().
- set_apply_mask(apply_mask)¶
- Parameters:
apply_mask (
bool
) – The new layer’s apply mask setting.- Returns:
True
on success.- Return type:
Set the apply mask setting of the specified layer.
This procedure sets the specified layer’s apply mask setting. This controls whether the layer’s mask is currently affecting the alpha channel. If there is no layer mask, this function will return an error.
- set_blend_space(blend_space)¶
- Parameters:
blend_space (
Gimp.LayerColorSpace
) – The new layer blend space.- Returns:
True
on success.- Return type:
Set the blend space of the specified layer.
This procedure sets the specified layer’s blend space.
New in version 2.10.
- set_composite_mode(composite_mode)¶
- Parameters:
composite_mode (
Gimp.LayerCompositeMode
) – The new layer composite mode.- Returns:
True
on success.- Return type:
Set the composite mode of the specified layer.
This procedure sets the specified layer’s composite mode.
New in version 2.10.
- set_composite_space(composite_space)¶
- Parameters:
composite_space (
Gimp.LayerColorSpace
) – The new layer composite space.- Returns:
True
on success.- Return type:
Set the composite space of the specified layer.
This procedure sets the specified layer’s composite space.
New in version 2.10.
- set_edit_mask(edit_mask)¶
- Parameters:
edit_mask (
bool
) – The new layer’s edit mask setting.- Returns:
True
on success.- Return type:
Set the edit mask setting of the specified layer.
This procedure sets the specified layer’s edit mask setting. This controls whether the layer or it’s mask is currently active for editing. If the specified layer has no layer mask, then this procedure will return an error.
- set_lock_alpha(lock_alpha)¶
- Parameters:
lock_alpha (
bool
) – The new layer’s lock alpha channel setting.- Returns:
True
on success.- Return type:
Set the lock alpha channel setting of the specified layer.
This procedure sets the specified layer’s lock alpha channel setting.
- set_mode(mode)¶
- Parameters:
mode (
Gimp.LayerMode
) – The new layer combination mode.- Returns:
True
on success.- Return type:
Set the combination mode of the specified layer.
This procedure sets the specified layer’s combination mode.
- set_offsets(offx, offy)¶
- Parameters:
- Returns:
True
on success.- Return type:
Set the layer offsets.
This procedure sets the offsets for the specified layer. The offsets are relative to the image origin and can be any values. This operation is valid only on layers which have been added to an image.
- set_opacity(opacity)¶
-
Set the opacity of the specified layer.
This procedure sets the specified layer’s opacity.
- set_show_mask(show_mask)¶
- Parameters:
show_mask (
bool
) – The new layer’s show mask setting.- Returns:
True
on success.- Return type:
Set the show mask setting of the specified layer.
This procedure sets the specified layer’s show mask setting. This controls whether the layer or its mask is visible.
True
indicates that the mask should be visible. If there is no layer mask, this function will return an error.