Functions¶
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Details¶
- Babl.component(name)¶
- Parameters:
name (
str
) –- Return type:
Returns the babl object representing the color component given by name such as for example “R”, “cyan” or “CIE L”.
- Babl.conversion_get_destination_space(conversion)¶
- Parameters:
conversion (
Babl.Object
) –- Return type:
Returns the RGB space defined for the destination of conversion.
- Babl.conversion_get_source_space(conversion)¶
- Parameters:
conversion (
Babl.Object
) –- Return type:
Returns the RGB space defined for the source of conversion.
- Babl.exit()¶
Deinitializes the babl library and frees any resources used when matched with the number of calls to
Babl.init
().
- Babl.fast_fish(source_format, destination_format, performance)¶
- Parameters:
- Return type:
Create a faster than normal fish with specified performance (and thus corresponding precision tradeoff), values tolerance can hold:
None
and “default”, means do same asBabl.fish
(), other values understood in increasing order of speed gain are: “exact” “precise” “fast” “glitch”Fast fishes should be cached, since they are not internally kept track of/made into singletons by babl and many creations of fast fishes will otherwise be a leak.
- Babl.fish(source_format, destination_format)¶
- Parameters:
- Return type:
Create a babl fish capable of converting from source_format to destination_format, source and destination can be either strings with the names of the formats or
Babl.Object
-format objects.
- Babl.format(encoding)¶
- Parameters:
encoding (
str
) –- Return type:
Returns the babl object representing the color format given by name such as for example “RGB u8”, “CMYK float” or “CIE Lab u16”, creates a format using the sRGB space, to also specify the color space and TRCs for a format, see
Babl.format_with_space
.
- Babl.format_exists(name)¶
-
Returns 1 if the provided format name is known by babl or 0 if it is not. Can also be used to verify that specific extension formats are available (though this can also be inferred from the version of babl).
- Babl.format_get_bytes_per_pixel(format)¶
- Parameters:
format (
Babl.Object
) –- Return type:
Returns the bytes per pixel for a babl color format.
- Babl.format_get_encoding(babl)¶
- Parameters:
babl (
Babl.Object
) –- Return type:
Returns the components and data type, without space suffix.
- Babl.format_get_model(format)¶
- Parameters:
format (
Babl.Object
) –- Return type:
Return the model used for constructing the format.
- Babl.format_get_n_components(format)¶
- Parameters:
format (
Babl.Object
) –- Return type:
Returns the number of components for the given format.
- Babl.format_get_space(format)¶
- Parameters:
format (
Babl.Object
) –- Return type:
- Babl.format_get_type(format, component_index)¶
- Parameters:
format (
Babl.Object
) –component_index (
int
) –
- Return type:
Returns the type in the given format for the given component_index.
- Babl.format_has_alpha(format)¶
- Parameters:
format (
Babl.Object
) –- Return type:
Returns whether the format has an alpha channel.
- Babl.format_is_format_n(format)¶
- Parameters:
format (
Babl.Object
) –- Return type:
Returns whether the format is a format_n type.
- Babl.format_is_palette(format)¶
- Parameters:
format (
Babl.Object
) –- Return type:
check whether a format is a palette backed format.
- Babl.format_n(type, components)¶
- Parameters:
type (
Babl.Object
) –components (
int
) –
- Return type:
- Babl.format_with_space(encoding, space)¶
- Parameters:
encoding (
str
) –space (
Babl.Object
) –
- Return type:
Returns the babl object representing the color format given by name such as for example “RGB u8”, “R’G’B’A float”, “Y float” with a specific RGB working space used as the space, the resulting format has -space suffixed to it, unless the space requested is sRGB then the unsuffixed version is used. If a format is passed in as space the space of the format is used.
- Babl.get_model_flags(model)¶
- Parameters:
model (
Babl.Object
) –- Return type:
- Babl.get_name(babl)¶
- Parameters:
babl (
Babl.Object
) –- Return type:
Returns a string describing a
Babl.Object
object.
- Babl.get_version()¶
- Returns:
- major:
The major version number
- minor:
The minor version number
- micro:
The micro version number
- Return type:
Get the version information on the babl library
- Babl.icc_get_key(icc_data, icc_length, key, language, country)¶
- Babl.icc_make_space(icc_data, icc_length, intent, error)¶
- Parameters:
icc_data (
str
) –icc_length (
int
) –intent (
Babl.IccIntent
) –error (
str
) –
- Return type:
- Babl.init()¶
Initializes the babl library.
- Babl.introspect(babl)¶
- Parameters:
babl (
Babl.Object
) – ABabl.Object
introspect a given BablObject
- Babl.model(name)¶
- Parameters:
name (
str
) –- Return type:
Returns the babl object representing the color model given by name such as for example “RGB”, “CMYK” or “CIE Lab”.
- Babl.model_is(babl, model_name)¶
- Parameters:
babl (
Babl.Object
) –model_name (
str
) –
- Returns:
0 if the name of the model in babl does not correspond to the provided model name.
- Return type:
- Babl.model_with_space(name, space)¶
- Parameters:
name (
str
) –space (
Babl.Object
) –
- Return type:
The models for formats also have a space in babl, try to avoid code needing to use this.
- Babl.new_palette(name, format_u8, format_u8_with_alpha)¶
- Parameters:
name (
str
) –format_u8 (
Babl.Object
) –format_u8_with_alpha (
Babl.Object
) –
- Return type:
create a new palette based format, name is optional pass in
None
to get an anonymous format. If you pass in with_alpha the format also gets an 8bit alpha channel. Returns the BablModel of the color model. If you pass in the same name the previous formats will be provided again.
- Babl.new_palette_with_space(name, space, format_u8, format_u8_with_alpha)¶
- Parameters:
name (
str
) –space (
Babl.Object
) –format_u8 (
Babl.Object
) –format_u8_with_alpha (
Babl.Object
) –
- Return type:
create a new palette based format, name is optional pass in
None
to get an anonymous format. If you pass in with_alpha the format also gets an 8bit alpha channel. Returns the BablModel of the color model. If you pass in the same name the previous formats will be provided again.
- Babl.palette_reset(babl)¶
- Parameters:
babl (
Babl.Object
) –
reset a palette to initial state, frees up some caches that optimize conversions.
- Babl.palette_set_palette(babl, format, data, count)¶
- Parameters:
babl (
Babl.Object
) – aBabl.Object
format (
Babl.Object
) – The pixel formatdata (
bytes
) – The pixel datacount (
int
) – The number of pixels in data
Assign a palette to a palette format, the data is a single span of pixels representing the colors of the palette.
- Babl.process(babl_fish, source, destination, n)¶
- Parameters:
- Return type:
Process n pixels from source to destination using
Babl.fish
, returns number of pixels converted.
- Babl.process_rows(babl_fish, source, source_stride, dest, dest_stride, n, rows)¶
- Babl.sampling(horizontal, vertical)¶
- Parameters:
- Return type:
Returns the babl object representing the horizontal and vertical sampling such as for example 2, 2 for the chroma components in YCbCr.
- Babl.space(name)¶
- Parameters:
name (
str
) –- Return type:
Returns the babl object representing the specific RGB matrix color working space referred to by name.
Babl.Object
knows of: sRGB, Rec2020, Adobish, Apple and ProPhoto
- Babl.space_from_chromaticities(name, wx, wy, rx, ry, gx, gy, bx, by, trc_red, trc_green, trc_blue, flags)¶
- Parameters:
wx (
float
) – The X-coordinate of the color space’s white pointwy (
float
) – The Y-coordinate of the color space’s white pointrx (
float
) – The X-coordinate of the red primaryry (
float
) – The Y-coordinate of the red primarygx (
float
) – The X-coordinate of the green primarygy (
float
) – The Y-coordinate of the green primarybx (
float
) – The X-coordinate of the blue primaryby (
float
) – The Y-coordinate of the blue primarytrc_red (
Babl.Object
) – The red component of the TRC.trc_green (
Babl.Object
orNone
) – The green component of the TRC (can beNone
if it’s the same as trc_red).trc_blue (
Babl.Object
orNone
) – The blue component of the TRC (can beNone
if it’s the same as trc_red).flags (
Babl.SpaceFlags
) – TheBabl.SpaceFlags
- Return type:
Creates a new babl-space/ RGB matrix color space definition with the specified CIE xy(Y) values for white point: wx, wy and primary chromaticities: rx,ry,gx,gy,bx,by and TRCs to be used. After registering a new babl-space it can be used with
Babl.space
() passing its name;Internally this does the math to derive the RGBXYZ matrix as used in an ICC profile.
- Babl.space_from_icc(icc_data, icc_length, intent)¶
- Parameters:
icc_data (
str
) – pointer to icc profile in memoryicc_length (
int
) – length of icc profile in bytesintent (
Babl.IccIntent
) – the intent from the ICC profile to use.
- Returns:
- error:
pointer to a string where decoding errors can be stored, if an error occurs,
None
is returned and an error message is provided in error.
- Return type:
(
Babl.Object
, error:str
)
Create a babl space from an in memory ICC profile, the profile does no longer need to be loaded for the space to work, multiple calls with the same icc profile and same intent will result in the same babl space.
On a profile that doesn’t contain A2B0 and B2A0 CLUTs perceptual and relative-colorimetric intents are treated the same.
If a BablSpace cannot be created from the profile
None
is returned and a static string is set on the conststr
*value pointed at with &value containing a message describing why the provided data does not yield a babl space.
- Babl.space_from_rgbxyz_matrix(name, wx, wy, wz, rx, gx, bx, ry, gy, by, rz, gz, bz, trc_red, trc_green, trc_blue)¶
- Parameters:
wx (
float
) – The X-coordinate of the color space’s white pointwy (
float
) – The Y-coordinate of the color space’s white pointwz (
float
) – The Z-coordinate of the color space’s white pointrx (
float
) – The X-coordinate of the red primarygx (
float
) – The X-coordinate of the green primarybx (
float
) – The X-coordinate of the blue primaryry (
float
) – The Y-coordinate of the red primarygy (
float
) – The Y-coordinate of the green primaryby (
float
) – The Y-coordinate of the blue primaryrz (
float
) – The Z-coordinate of the red primarygz (
float
) – The Z-coordinate of the green primarybz (
float
) – The Z-coordinate of the blue primarytrc_red (
Babl.Object
) – The red component of the TRC.trc_green (
Babl.Object
orNone
) – The green component of the TRC (can beNone
if it’s the same as trc_red).trc_blue (
Babl.Object
orNone
) – The blue component of the TRC (can beNone
if it’s the same as trc_red).
- Return type:
Creates a new RGB matrix color space definition using a precomputed D50 adapted 3x3 matrix and associated CIE XYZ whitepoint, as possibly read from an ICC profile.
- Babl.space_get(space)¶
- Parameters:
space (
Babl.Object
) – ABabl.Object
instance- Returns:
- xw:
The X-coordinate of the color space’s white point
- yw:
The Y-coordinate of the color space’s white point
- xr:
The X-coordinate of the red primary
- yr:
The Y-coordinate of the red primary
- xg:
The X-coordinate of the blue primary
- yg:
The Y-coordinate of the green primary
- xb:
The X-coordinate of the blue primary
- yb:
The Y-coordinate of the blue primary
- red_trc:
The red component of the TRC.
- green_trc:
The green component of the TRC (can be
None
if it’s the same as red_trc).- blue_trc:
The blue component of the TRC (can be
None
if it’s the same as red_trc).
- Return type:
(xw:
float
, yw:float
, xr:float
, yr:float
, xg:float
, yg:float
, xb:float
, yb:float
, red_trc:Babl.Object
, green_trc:Babl.Object
, blue_trc:Babl.Object
)
query the chromaticities of white point and primaries as well as trcs used for r g a nd b, all arguments are optional (can be
None
).
- Babl.space_get_gamma(space)¶
- Parameters:
space (
Babl.Object
) –- Return type:
- Babl.space_get_icc(babl)¶
- Parameters:
babl (
Babl.Object
) – aBabl.Object
- Returns:
pointer to ICC profile data.
- length:
Length of the profile in bytes.
- Return type:
Return pointer to ICC profile for space note that this is the ICC profile for R’G’B’, though in formats only supporting linear like EXR GEGL chooses to load this lienar data as RGB and use the sRGB TRC.
- Babl.space_get_rgb_luminance(space)¶
- Parameters:
space (
Babl.Object
) – a BablSpace- Returns:
- red_luminance:
Location for the red luminance factor.
- green_luminance:
Location for the green luminance factor.
- blue_luminance:
Location for the blue luminance factor.
- Return type:
(red_luminance:
float
, green_luminance:float
, blue_luminance:float
)
Retrieve the relevant RGB luminance constants for a babl space.
Note: these luminance coefficients should only ever be used on linear data. If your input space is non-linear, you should convert your pixel values to the linearized variant of space before making any computation with these coefficients. See #83.
- Babl.space_is_cmyk(space)¶
- Parameters:
space (
Babl.Object
) –- Returns:
1 if space is CMYK, 0 otherwise.
- Return type:
- Babl.space_is_gray(space)¶
- Parameters:
space (
Babl.Object
) –- Returns:
1 if space is grayscale, 0 otherwise.
- Return type:
- Babl.space_is_rgb(space)¶
- Parameters:
space (
Babl.Object
) –- Returns:
1 if space is RGB, 0 otherwise.
- Return type:
- Babl.space_with_trc(space, trc)¶
- Parameters:
space (
Babl.Object
) –trc (
Babl.Object
) –
- Return type:
Creates a variant of an existing space with different trc.
- Babl.trc(name)¶
- Parameters:
name (
str
) –- Return type:
Look up a TRC by name, “sRGB” and “linear” are recognized strings in a stock babl configuration.
- Babl.trc_gamma(gamma)¶
- Parameters:
gamma (
float
) –- Return type:
Creates a
Babl.Object
TRC for a specific gamma value, it will be given a name that is a short string representation of the value.