Gimp.Parasite

Fields

Name

Type

Access

Description

data

[object]

r/w

the parasite data, the owner os the parasite is responsible for tracking byte order and internal structure

flags

int

r/w

the parasite flags, like save in XCF etc.

name

str

r/w

the parasite name, USE A UNIQUE PREFIX

size

int

r/w

the parasite size in bytes

Methods

class

new (name, flags, data)

compare (b)

copy ()

free ()

get_data ()

get_flags ()

get_name ()

has_flag (flag)

is_persistent ()

is_type (name)

is_undoable ()

Details

class Gimp.Parasite

Arbitrary pieces of data which can be attached to various GIMP objects.

classmethod new(name, flags, data)
Parameters:
  • name (str) – the new Gimp.Parasite name.

  • flags (int) – see libgimpbase/gimpparasite.h macros.

  • data ([int] or None) – the data to save in a parasite.

Returns:

a new Gimp.Parasite.

Return type:

Gimp.Parasite

Creates a new parasite and save data which may be a proper text (in which case you may want to set size as strlen(data) + 1) or not.

compare(b)
Parameters:

b (Gimp.Parasite) – a Gimp.Parasite

Returns:

True if self and b have same contents, False otherwise.

Return type:

bool

Compare parasite’s contents.

copy()
Returns:

a newly allocated Gimp.Parasite with same contents.

Return type:

Gimp.Parasite

Create a new parasite with all the same values.

free()

Free self's dynamically allocated memory.

get_data()
Returns:

parasite’s data.

Return type:

[int]

Gets the parasite’s data. It may not necessarily be text, nor is it guaranteed to be None-terminated. It is your responsibility to know how to deal with this data. Even when you expect a nul-terminated string, it is advised not to assume the returned data to be, as parasites can be edited by third party scripts. You may end up reading out-of-bounds data. So you should only ignore num_bytes when you all you care about is checking if the parasite has contents.

get_flags()
Returns:

self flags.

Return type:

int

get_name()
Returns:

self's name.

Return type:

str

has_flag(flag)
Parameters:

flag (int) – a parasite flag

Returns:

True if self has flag set, False otherwise.

Return type:

bool

is_persistent()
Returns:

True if self is persistent, False otherwise.

Return type:

bool

is_type(name)
Parameters:

name (str) – a parasite name.

Returns:

True if self is named name, False otherwise.

Return type:

bool

Compare parasite’s names.

is_undoable()
Returns:

True if self is undoable, False otherwise.

Return type:

bool