Previous section To contents Next section

12.3 Image.Layer

CLASS
Image.Layer

DESCRIPTION

SEE ALSO
layers

METHOD
Image.Layer.alpha,
Image.Layer.image,
Image.Layer.set_image

SYNTAX
object set_image(object(Image.Image) image)
object set_image(object(Image.Image) image, object(Image.Image) alpha_channel)
object|int(0) image()
object|int(0) alpha()

DESCRIPTION
Set/change/get image and alpha channel for the layer. You could also cancel the channels giving 0 instead of an image object.

NOTE
image and alpha channel must be of the same size, or canceled.

METHOD
Image.Layer.alpha_value,
Image.Layer.set_alpha_value

SYNTAX
object set_alpha_value(float value)
double alpha_value()

DESCRIPTION
Set/get the general alpha value of this layer. This is a float value between 0 and 1, and is multiplied with the alpha channel.

METHOD
Image.Layer.autocrop,
Image.Layer.find_autocrop

SYNTAX
object autocrop()
object autocrop(int(0..1) left, int(0..1) right, int(0..1) top, int(0..1) bottom)
array(int) find_autocrop()
array(int) find_autocrop(int(0..1) left, int(0..1) right, int(0..1) top, int(0..1) bottom)

DESCRIPTION
This crops (of finds) a suitable crop, non-destructive crop. The layer alpha channel is checked, and edges that is transparent is removed.

(What really happens is that the image and alpha channel is checked, and edges equal the fill setup is cropped away.)

find_autocrop() returns an array of xoff,yoff,xsize,ysize, which can be fed to crop().

NOTE
A tiled image will not be cropped at all.

left...bottom arguments can be used to tell what sides cropping are ok on.

SEE ALSO
crop and Image.Image->autocrop

METHOD
Image.Layer.mode,
Image.Layer.set_mode,
Image.Layer.available_modes

SYNTAX
object set_mode(string mode)
string mode()
array(string) available_modes()

DESCRIPTION
Set/get layer mode. Mode is one of these:

"normal", "add", "subtract", "multiply", "divide", "modulo", "invsubtract", "invdivide", "invmodulo", "difference", "max", "min", "bitwise_and", "bitwise_or", "bitwise_xor",

"replace", "red", "green", "blue",

"replace_hsv", "hue", "saturation", "value", "color",

"darken", "lighten",

"dissolve", "behind", "erase",

available_modes() simply gives an array containing the names of these modes.

NOTE
image and alpha channel must be of the same size, or canceled.

METHOD
Image.Layer.clone

SYNTAX
object clone()

DESCRIPTION
Creates a copy of the called object.

RETURNS
the copy

METHOD
Image.Layer.create

SYNTAX
void create(object image, object alpha, string mode)
void create(mapping info)
void create()
void create(int xsize, int ysize, object color)
void create(object color)

DESCRIPTION
The Layer construct either three arguments, the image object, alpha channel and mode, or a mapping with optional elements:
"image":image,
// default: black

"alpha":alpha, // alpha channel object // default: full opaque

"mode":string mode, // layer mode, see mode. // default: "normal"

"alpha_value":float(0.0-1.0), // layer general alpha value // default is 1.0; this is multiplied // with the alpha channel.

"xoffset":int, "yoffset":int, // offset of this layer

"fill":Color, "fill_alpha":Color, // fill color, ie what color is used // "outside" the image. default: black // and black (full transparency).

"tiled":int(0|1), // select tiling; if 1, the image // will be tiled. deafult: 0, off

The layer can also be created "empty", either giving a size and color - this will give a filled opaque square, or a color, which will set the "fill" values and fill the whole layer with an opaque color.

All values can be modified after object creation.

NOTE
image and alpha channel must be of the same size.

METHOD
Image.Layer.crop

SYNTAX
object crop(int xoff, int yoff, int xsize, int ysize)

DESCRIPTION
Crops this layer at this offset and size. Offset is not relative the layer offset, so this can be used to crop a number of layers simuntaneously.

The fill values are used if the layer is enlarged.

RETURNS
a new layer object

NOTE
The new layer object may have the same image object, if there was no cropping to be done.

METHOD
Image.Layer.fill,
Image.Layer.fill_alpha,
Image.Layer.set_fill

SYNTAX
object set_fill(Color color)
object set_fill(Color color, Color alpha)
object fill()
object fill_alpha()

DESCRIPTION
Set/query fill color and alpha, ie the color used "outside" the image. This is mostly useful if you want to "frame" a layer.

METHOD
Image.Layer.set_misc_value,
Image.Layer.get_misc_value

SYNTAX
mixed set_misc_value( mixed what,  mixed to )
mixed get_misc_value( mixed what )

DESCRIPTION
Set or query misc. attributes for the layer.

As an example, the XCF and PSD image decoders set the 'name' attribute to the name the layer had in the source file.

METHOD
Image.Layer.xoffset,
Image.Layer.yoffset,
Image.Layer.set_offset

SYNTAX
object set_offset(int x, int y)
int xoffset()
int yoffset()

DESCRIPTION
Set/query layer offset.

METHOD
Image.Layer.tiled,
Image.Layer.set_tiled

SYNTAX
object set_tiled(int yes)
int tiled()

DESCRIPTION
Set/query tiled flag. If set, the image and alpha channel will be tiled rather then framed by the fill values.

METHOD
Image.Layer.ysize,
Image.Layer.xsize

SYNTAX
int xsize()
int ysize()

DESCRIPTION
Query layer offset. This is the same as layer image/alpha image size.

Previous section To contents Next section