Gimp.Item¶
- Subclasses:
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/co |
The item id for internal use |
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent_instance |
r |
Class Details¶
- class Gimp.Item(**kwargs)¶
- Bases:
- Abstract:
Yes
- Structure:
Functions to manipulate items.
- classmethod get_by_id(item_id)¶
- Parameters:
item_id (
int
) – The item id.- Returns:
a
Gimp.Item
for item_id orNone
if item_id does not represent a valid item. The object belongs to libgimp and you must not modify or unref it.- Return type:
Returns a
Gimp.Item
representing item_id. SinceGimp.Item
is an abstract class, the real object type will actually be the proper subclass.Note: in most use cases, you should not need to retrieve a
Gimp.Item
by its ID, which is mostly internal data and not reusable across sessions. Use the appropriate functions for your use case instead.New in version 3.0.
- classmethod id_is_channel(item_id)¶
- Parameters:
item_id (
int
) – The item ID.- Returns:
- Return type:
Returns whether the item ID is a channel.
This procedure returns
True
if the specified item ID is a channel.*Note*: in most use cases, you should not use this function. See [func`Gimp`.Item.id_is_layer] for a discussion on alternatives.
New in version 3.0.
- classmethod id_is_drawable(item_id)¶
- Parameters:
item_id (
int
) – The item ID.- Returns:
- Return type:
Returns whether the item ID is a drawable.
This procedure returns
True
if the specified item ID is a drawable.*Note*: in most use cases, you should not use this function. See [func`Gimp`.Item.id_is_layer] for a discussion on alternatives.
New in version 3.0.
- classmethod id_is_group_layer(item_id)¶
- Parameters:
item_id (
int
) – The item ID.- Returns:
- Return type:
Returns whether the item ID is a group layer.
This procedure returns
True
if the specified item ID is a group layer.*Note*: in most use cases, you should not use this function. See [func`Gimp`.Item.id_is_layer] for a discussion on alternatives.
New in version 3.0.
- classmethod id_is_layer(item_id)¶
- Parameters:
item_id (
int
) – The item ID.- Returns:
- Return type:
Returns whether the item ID is a layer.
This procedure returns
True
if the specified item ID is a layer.*Note*: in most use cases, you should not use this function. If the goal is to verify the accurate type for a [class`Gimp`.Item], you should either use [method`Gimp`.Item.is_layer] or the specific type-checking methods for the used language.
For instance, in C:
``C if (GIMP_IS_LAYER (item))
do_something ();
Or in the Python binding, you could run:
``py3 if isinstance(item, Gimp.Layer):
do_something()
New in version 3.0.
- classmethod id_is_layer_mask(item_id)¶
- Parameters:
item_id (
int
) – The item.- Returns:
- Return type:
Returns whether the item ID is a layer mask.
This procedure returns
True
if the specified item ID is a layer mask.*Note*: in most use cases, you should not use this function. See [func`Gimp`.Item.id_is_layer] for a discussion on alternatives.
New in version 3.0.
- classmethod id_is_path(item_id)¶
- Parameters:
item_id (
int
) – The item ID.- Returns:
- Return type:
Returns whether the item ID is a path.
This procedure returns
True
if the specified item ID is a path.*Note*: in most use cases, you should not use this function. See [func`Gimp`.Item.id_is_layer] for a discussion on alternatives.
New in version 3.0.
- classmethod id_is_selection(item_id)¶
- Parameters:
item_id (
int
) – The item ID.- Returns:
- Return type:
Returns whether the item ID is a selection.
This procedure returns
True
if the specified item ID is a selection.*Note*: in most use cases, you should not use this function. See [func`Gimp`.Item.id_is_layer] for a discussion on alternatives.
New in version 3.0.
- classmethod id_is_text_layer(item_id)¶
- Parameters:
item_id (
int
) – The item ID.- Returns:
- Return type:
Returns whether the item ID is a text layer.
This procedure returns
True
if the specified item ID is a text layer.*Note*: in most use cases, you should not use this function. See [func`Gimp`.Item.id_is_layer] for a discussion on alternatives.
New in version 3.0.
- classmethod id_is_valid(item_id)¶
- Parameters:
item_id (
int
) – The item ID to check.- Returns:
Whether the item ID is valid.
- Return type:
Returns
True
if the item ID is valid.This procedure checks if the given item ID is valid and refers to an existing item.
*Note*: in most use cases, you should not use this function. If you got a [class`Gimp`.Item] from the API, you should trust it is valid. This function is mostly for internal usage.
New in version 3.0.
- attach_parasite(parasite)¶
- Parameters:
parasite (
Gimp.Parasite
) – The parasite to attach to the item.- Returns:
True
on success.- Return type:
Add a parasite to an item.
This procedure attaches a parasite to an item. It has no return values.
New in version 2.8.
- delete()¶
-
Delete a item.
This procedure deletes the specified item. This must not be done if the image containing this item was already deleted or if the item was already removed from the image. The only case in which this procedure is useful is if you want to get rid of a item which has not yet been added to an image.
New in version 2.8.
- detach_parasite(name)¶
- Parameters:
name (
str
) – The name of the parasite to detach from the item.- Returns:
True
on success.- Return type:
Removes a parasite from an item.
This procedure detaches a parasite from an item. It has no return values.
New in version 2.8.
- get_children()¶
- Returns:
The item’s list of children. The returned value must be freed with
GLib.free
().- Return type:
Returns the item’s list of children.
This procedure returns the list of items which are children of the specified item. The order is topmost to bottommost.
New in version 2.8.
- get_color_tag()¶
- Returns:
The item’s color tag.
- Return type:
Get the color tag of the specified item.
This procedure returns the specified item’s color tag.
New in version 2.10.
- get_expanded()¶
-
Returns whether the item is expanded.
This procedure returns
True
if the specified item is expanded.New in version 2.10.
- get_id()¶
- Returns:
the item ID.
- Return type:
Note: in most use cases, you should not need an item’s ID which is mostly internal data and not reusable across sessions.
New in version 3.0.
- get_image()¶
- Returns:
The item’s image.
- Return type:
Returns the item’s image.
This procedure returns the item’s image.
New in version 2.8.
- get_lock_content()¶
- Returns:
Whether the item’s contents are locked.
- Return type:
Get the ‘lock content’ state of the specified item.
This procedure returns the specified item’s lock content state.
New in version 2.8.
- get_lock_position()¶
- Returns:
Whether the item’s position is locked.
- Return type:
Get the ‘lock position’ state of the specified item.
This procedure returns the specified item’s lock position state.
New in version 2.10.
- get_lock_visibility()¶
- Returns:
Whether the item’s visibility is locked.
- Return type:
Get the ‘lock visibility’ state of the specified item.
This procedure returns the specified item’s lock visibility state.
New in version 3.0.
- get_name()¶
-
Get the name of the specified item.
This procedure returns the specified item’s name.
New in version 2.8.
- get_parasite(name)¶
- Parameters:
name (
str
) – The name of the parasite to find.- Returns:
The found parasite.
- Return type:
Look up a parasite in an item
Finds and returns the parasite that is attached to an item.
New in version 2.8.
- get_parasite_list()¶
- Returns:
The names of currently attached parasites. The returned value must be freed with
GLib.strfreev
().- Return type:
[
str
]
List all parasites.
Returns a list of all parasites currently attached the an item.
New in version 2.8.
- get_parent()¶
- Returns:
The item’s parent item.
- Return type:
Returns the item’s parent item.
This procedure returns the item’s parent item, if any.
New in version 2.8.
- get_tattoo()¶
- Returns:
The item tattoo.
- Return type:
Get the tattoo of the specified item.
This procedure returns the specified item’s tattoo. A tattoo is a unique and permanent identifier attached to a item that can be used to uniquely identify a item within an image even between sessions.
New in version 2.8.
- get_visible()¶
- Returns:
The item visibility.
- Return type:
Get the visibility of the specified item.
This procedure returns the specified item’s visibility.
New in version 2.8.
- is_channel()¶
-
Returns whether the item is a channel.
This procedure returns
True
if the specified item is a channel.New in version 2.8.
- is_drawable()¶
-
Returns whether the item is a drawable.
This procedure returns
True
if the specified item is a drawable.New in version 2.8.
- is_group()¶
-
Returns whether the item is a group item.
This procedure returns
True
if the specified item is a group item which can have children.New in version 2.8.
- is_group_layer()¶
-
Returns whether the item is a group layer.
This procedure returns
True
if the specified item is a group layer.New in version 3.0.
- is_layer()¶
-
Returns whether the item is a layer.
This procedure returns
True
if the specified item is a layer.New in version 2.8.
- is_layer_mask()¶
-
Returns whether the item is a layer mask.
This procedure returns
True
if the specified item is a layer mask.New in version 2.8.
- is_path()¶
-
Returns whether the item is a path.
This procedure returns
True
if the specified item is a path.New in version 2.8.
- is_selection()¶
-
Returns whether the item is a selection.
This procedure returns
True
if the specified item is a selection.New in version 2.8.
- is_text_layer()¶
-
Returns whether the item is a text layer.
This procedure returns
True
if the specified item is a text layer.New in version 2.8.
- is_valid()¶
- Returns:
Whether the item is valid.
- Return type:
Returns
True
if the item is valid.This procedure checks if the given item is valid and refers to an existing item.
New in version 2.8.
- set_color_tag(color_tag)¶
- Parameters:
color_tag (
Gimp.ColorTag
) – The new item color tag.- Returns:
True
on success.- Return type:
Set the color tag of the specified item.
This procedure sets the specified item’s color tag.
New in version 2.10.
- set_expanded(expanded)¶
- Parameters:
expanded (
bool
) –True
to expand the item,False
to collapse the item.- Returns:
True
on success.- Return type:
Sets the expanded state of the item.
This procedure expands or collapses the item.
New in version 2.10.
- set_lock_content(lock_content)¶
- Parameters:
lock_content (
bool
) – The new item ‘lock content’ state.- Returns:
True
on success.- Return type:
Set the ‘lock content’ state of the specified item.
This procedure sets the specified item’s lock content state.
New in version 2.8.
- set_lock_position(lock_position)¶
- Parameters:
lock_position (
bool
) – The new item ‘lock position’ state.- Returns:
True
on success.- Return type:
Set the ‘lock position’ state of the specified item.
This procedure sets the specified item’s lock position state.
New in version 2.10.
- set_lock_visibility(lock_visibility)¶
- Parameters:
lock_visibility (
bool
) – The new item ‘lock visibility’ state.- Returns:
True
on success.- Return type:
Set the ‘lock visibility’ state of the specified item.
This procedure sets the specified item’s lock visibility state.
New in version 3.0.
- set_name(name)¶
-
Set the name of the specified item.
This procedure sets the specified item’s name.
New in version 2.8.
- set_tattoo(tattoo)¶
-
Set the tattoo of the specified item.
This procedure sets the specified item’s tattoo. A tattoo is a unique and permanent identifier attached to a item that can be used to uniquely identify a item within an image even between sessions.
New in version 2.8.
- set_visible(visible)¶
-
Set the visibility of the specified item.
This procedure sets the specified item’s visibility.
New in version 2.8.
- transform_2d(source_x, source_y, scale_x, scale_y, angle, dest_x, dest_y)¶
- Parameters:
source_x (
float
) – X coordinate of the transformation center.source_y (
float
) – Y coordinate of the transformation center.scale_x (
float
) – Amount to scale in x direction.scale_y (
float
) – Amount to scale in y direction.angle (
float
) – The angle of rotation (radians).dest_x (
float
) – X coordinate of where the center goes.dest_y (
float
) – Y coordinate of where the center goes.
- Returns:
The transformed item.
- Return type:
Transform the specified item in 2d.
This procedure transforms the specified item.
The transformation is done by scaling by the x and y scale factors about the point (source_x, source_y), then rotating around the same point, then translating that point to the new position (dest_x, dest_y).
If a selection exists and the item is a drawable, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then transformed as specified. The return value is the ID of the transformed floating selection.
If there is no selection or the item is not a drawable, the entire item will be transformed according to the specified parameters. The return value will be equal to the item ID supplied as input.
This procedure is affected by the following context setters:
Gimp.context_set_interpolation
(),Gimp.context_set_transform_direction
(),Gimp.context_set_transform_resize
().New in version 2.8.
- transform_flip(x0, y0, x1, y1)¶
- Parameters:
- Returns:
The flipped item.
- Return type:
Flip the specified item around a given line.
This procedure flips the specified item.
If a selection exists and the item is a drawable, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then flipped. The axis to flip around is specified by specifying two points from that line. The return value is the ID of the flipped floating selection.
If there is no selection or the item is not a drawable, the entire item will be flipped around the specified axis. The return value will be equal to the item ID supplied as input.
This procedure is affected by the following context setters:
Gimp.context_set_interpolation
(),Gimp.context_set_transform_direction
(),Gimp.context_set_transform_resize
().New in version 2.8.
- transform_flip_simple(flip_type, auto_center, axis)¶
- Parameters:
flip_type (
Gimp.OrientationType
) – Type of flip.auto_center (
bool
) – Whether to automatically position the axis in the selection center.axis (
float
) – coord. of flip axis.
- Returns:
The flipped item.
- Return type:
Flip the specified item either vertically or horizontally.
This procedure flips the specified item.
If a selection exists and the item is a drawable, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then flipped. If auto_center is set to
True
, the flip is around the selection’s center. Otherwise, the coordinate of the axis needs to be specified. The return value is the ID of the flipped floating selection.If there is no selection or the item is not a drawable, the entire item will be flipped around its center if auto_center is set to
True
, otherwise the coordinate of the axis needs to be specified. The return value will be equal to the item ID supplied as input.This procedure is affected by the following context setters:
Gimp.context_set_transform_resize
().New in version 2.2.
- transform_matrix(coeff_0_0, coeff_0_1, coeff_0_2, coeff_1_0, coeff_1_1, coeff_1_2, coeff_2_0, coeff_2_1, coeff_2_2)¶
- Parameters:
coeff_0_0 (
float
) – coefficient (0,0) of the transformation matrix.coeff_0_1 (
float
) – coefficient (0,1) of the transformation matrix.coeff_0_2 (
float
) – coefficient (0,2) of the transformation matrix.coeff_1_0 (
float
) – coefficient (1,0) of the transformation matrix.coeff_1_1 (
float
) – coefficient (1,1) of the transformation matrix.coeff_1_2 (
float
) – coefficient (1,2) of the transformation matrix.coeff_2_0 (
float
) – coefficient (2,0) of the transformation matrix.coeff_2_1 (
float
) – coefficient (2,1) of the transformation matrix.coeff_2_2 (
float
) – coefficient (2,2) of the transformation matrix.
- Returns:
The transformed item.
- Return type:
Transform the specified item in 2d.
This procedure transforms the specified item.
The transformation is done by assembling a 3x3 matrix from the coefficients passed.
If a selection exists and the item is a drawable, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then transformed as specified. The return value is the ID of the transformed floating selection.
If there is no selection or the item is not a drawable, the entire item will be transformed according to the specified matrix. The return value will be equal to the item ID supplied as input.
This procedure is affected by the following context setters:
Gimp.context_set_interpolation
(),Gimp.context_set_transform_direction
(),Gimp.context_set_transform_resize
().New in version 2.8.
- transform_perspective(x0, y0, x1, y1, x2, y2, x3, y3)¶
- Parameters:
x0 (
float
) – The new x coordinate of upper-left corner of original bounding box.y0 (
float
) – The new y coordinate of upper-left corner of original bounding box.x1 (
float
) – The new x coordinate of upper-right corner of original bounding box.y1 (
float
) – The new y coordinate of upper-right corner of original bounding box.x2 (
float
) – The new x coordinate of lower-left corner of original bounding box.y2 (
float
) – The new y coordinate of lower-left corner of original bounding box.x3 (
float
) – The new x coordinate of lower-right corner of original bounding box.y3 (
float
) – The new y coordinate of lower-right corner of original bounding box.
- Returns:
The transformed item.
- Return type:
Perform a possibly non-affine transformation on the specified item.
This procedure performs a possibly non-affine transformation on the specified item by allowing the corners of the original bounding box to be arbitrarily remapped to any values.
The 4 coordinates specify the new locations of each corner of the original bounding box. By specifying these values, any affine transformation (rotation, scaling, translation) can be affected. Additionally, these values can be specified such that the resulting transformed item will appear to have been projected via a perspective transform.
If a selection exists and the item is a drawable, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then transformed as specified. The return value is the ID of the transformed floating selection.
If there is no selection or the item is not a drawable, the entire item will be transformed according to the specified mapping. The return value will be equal to the item ID supplied as input.
This procedure is affected by the following context setters:
Gimp.context_set_interpolation
(),Gimp.context_set_transform_direction
(),Gimp.context_set_transform_resize
().New in version 2.8.
- transform_rotate(angle, auto_center, center_x, center_y)¶
- Parameters:
- Returns:
The rotated item.
- Return type:
Rotate the specified item about given coordinates through the specified angle.
This function rotates the specified item.
If a selection exists and the item is a drawable, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then rotated by the specified amount. If auto_center is set to
True
, the rotation is around the selection’s center. Otherwise, the coordinate of the center point needs to be specified. The return value is the ID of the rotated floating selection.If there is no selection or the item is not a drawable, the entire item will be rotated around its center if auto_center is set to
True
, otherwise the coordinate of the center point needs to be specified. The return value will be equal to the item ID supplied as input.This procedure is affected by the following context setters:
Gimp.context_set_interpolation
(),Gimp.context_set_transform_direction
(),Gimp.context_set_transform_resize
().New in version 2.8.
- transform_rotate_simple(rotate_type, auto_center, center_x, center_y)¶
- Parameters:
rotate_type (
Gimp.RotationType
) – Type of rotation.auto_center (
bool
) – Whether to automatically rotate around the selection center.center_x (
float
) – The hor. coordinate of the center of rotation.center_y (
float
) – The vert. coordinate of the center of rotation.
- Returns:
The rotated item.
- Return type:
Rotate the specified item about given coordinates through the specified angle.
This function rotates the specified item.
If a selection exists and the item is a drawable, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then rotated by the specified amount. If auto_center is set to
True
, the rotation is around the selection’s center. Otherwise, the coordinate of the center point needs to be specified. The return value is the ID of the rotated floating selection.If there is no selection or the item is not a drawable, the entire item will be rotated around its center if auto_center is set to
True
, otherwise the coordinate of the center point needs to be specified. The return value will be equal to the item ID supplied as input.This procedure is affected by the following context setters:
Gimp.context_set_transform_resize
().New in version 2.8.
- transform_scale(x0, y0, x1, y1)¶
- Parameters:
x0 (
float
) – The new x coordinate of the upper-left corner of the scaled region.y0 (
float
) – The new y coordinate of the upper-left corner of the scaled region.x1 (
float
) – The new x coordinate of the lower-right corner of the scaled region.y1 (
float
) – The new y coordinate of the lower-right corner of the scaled region.
- Returns:
The scaled item.
- Return type:
Scale the specified item.
This procedure scales the specified item.
The 2 coordinates specify the new locations of the top-left and bottom-roght corners of the original bounding box.
If a selection exists and the item is a drawable, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then scaled as specified. The return value is the ID of the scaled floating selection.
If there is no selection or the item is not a drawable, the entire item will be scaled according to the specified coordinates. The return value will be equal to the item ID supplied as input.
This procedure is affected by the following context setters:
Gimp.context_set_interpolation
(),Gimp.context_set_transform_direction
(),Gimp.context_set_transform_resize
().New in version 2.8.
- transform_shear(shear_type, magnitude)¶
- Parameters:
shear_type (
Gimp.OrientationType
) – Type of shear.magnitude (
float
) – The magnitude of the shear.
- Returns:
The sheared item.
- Return type:
Shear the specified item about its center by the specified magnitude.
This procedure shears the specified item.
The shear type parameter indicates whether the shear will be applied horizontally or vertically. The magnitude can be either positive or negative and indicates the extent (in pixels) to shear by.
If a selection exists and the item is a drawable, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then sheared as specified. The return value is the ID of the sheared floating selection.
If there is no selection or the item is not a drawable, the entire item will be sheared according to the specified parameters. The return value will be equal to the item ID supplied as input.
This procedure is affected by the following context setters:
Gimp.context_set_interpolation
(),Gimp.context_set_transform_direction
(),Gimp.context_set_transform_resize
().New in version 2.8.
- transform_translate(off_x, off_y)¶
- Parameters:
- Returns:
The translated item.
- Return type:
Translate the item by the specified offsets.
This procedure translates the item by the amounts specified in the off_x and off_y arguments. These can be negative, and are considered offsets from the current position. The offsets will be rounded to the nearest pixel unless the item is a path.
New in version 2.10.
Property Details¶
- Gimp.Item.props.id¶
- Name:
id
- Type:
- Default Value:
0
- Flags:
The item id for internal use