Image Utility

class lwsdk.LWImageUtil(*args)

Bases: object

Proxy of C++ PCore::LWImageUtil class

 create(int w, int h, int type) → LWPixmapID

Create a new image. The type specifies the organization of the pixel data and may be any of the Image I/O pixel types.

 destroy(LWPixmapID img)

Release resources allocated by LWImageUtil::create(). The LWPixmapID is no longer valid after this is called.

 getAttr(LWPixmapID img, int tag) → PyObject

Gets the value of an attribute for an image. The tag is one of the lwsdk.LWIMPAR_* symbols defined in lwimageio.h.

The method returns a Python tuple containing the result code (e.g., 1 if found) in the first element, and the value of the attribute (whose type is dependent on the provided tag) in the second. The value's data type may be one of string, integer or double, again, depending on the tag

 getIndex8Map(LWPixmapID img) → PyObject

Get the color index map for lwsdk.LIMTYP_INDEX8 images. If supported, the map's RGB colors are returned in a Python tuple, or None if indexed color mapping is not supported by the image format.

 getInfo(LWPixmapID img) → (width, height, type)

Returns a Python tuple with the integer width, height and pixel type of an image.

 getLineTyped(LWPixmapID img, int arg1, int arg2, void arg3) → int

!! OVERRIDE REQUIRED !!

 getMakerNote(LWPixmapID img, int tag) → PyObject

Gets the value of a MakerNote attribute for an image. The tag is one of the lwsdk.LWMN_* symbols defined in lwimageio.h.

This method returns a Python tuple containing the result code (e.g., 1 if found) in the first element, and the value of the note (as a string) in the second, or None.

 getPixel(LWPixmapID img, int x, int y) → PyObject

Get the value of a pixel in the image. The pixel value is returned as a Python tuple containing the red, green, blue and, if supported, alpha values of the pixel.

Check the len() of the returned tuple to determine if the alpha is included.

 getPixelTyped(LWPixmapID img, int x, int y, int type) → PyObject

Get the value of a pixel in the image in a given format type. Similar to LWImageUtil::getPixel(), this method will return the pixel element values in the requested format. For example, depending upon the lwsdk.LWIMTYP_* tag type used, the data types may be int, float, or double. However, since Python does not explicitly handle "float" data types, they will be implicitly promoted to doubles when they enter Python space.

 resample(LWPixmapID img, int w, int h, int mode) → LWPixmapID

Create a new image by resizing an existing image. The mode determines how the existing pixels will be resampled and can be one of the following values:

lwsdk.LWISM_SUBSAMPLING
lwsdk.LWISM_MEDIAN
lwsdk.LWISM_SUPERSAMPLING
lwsdk.LWISM_BILINEAR
lwsdk.LWISM_BSPLINE
lwsdk.LWISM_BICUBIC

 save(LWPixmapID img, int saver, char name) → int

Save the image to a file using the specified format. The format is determined by the choice of image saver, which can be one of Layout's built-in image savers or any of the installed ImageSaver class plug-ins. Use the LWImageUtil::saverCount() and LWImageUtil::saverName() functions to determine what formats are available and which saver index to use.

 saverCount() → int

Returns the number of available image savers.

 saverName(int saver) → char

Returns the name of an image saver.

 setAttr(LWPixmapID img, tag, void data) → int

!! OVERRIDE REQUIRED !!

 setIndex8Map(LWPixmapID img, map) → int

!! OVERRIDE REQUIRED !!

 setLineTyped(LWPixmapID img, int arg1, int arg2, void arg3) → int

!! OVERRIDE REQUIRED !!

setMakerNote(self, LWPixmapID img, tag, char arg1) → int
 setPixel(LWPixmapID img, int x, int y, data[]) → PyObject

Set the value of a pixel in the image. The format of the pixel data should be a Python sequence, and the data type of each element will depend on the pixel type of the image.

 setPixelTyped(LWPixmapID img, int x, int y, int type, data[]) → PyObject

Set the value of a pixel in the image. The pixel is assumed to be of the given format type. The format of the pixel data should be a Python sequence, and the data type of each element will depend on the pixel type of the image.

Previous topic

Image List

Next topic

Item Instancer Funcs

This Page