Previous topic

collada.material

Next topic

collada.material.Effect

This Page

collada.material.CImage

class collada.material.CImage(id, path, collada=None, xmlnode=None)

Bases: collada.DaeObject

Class containing data coming from a <image> tag.

Basically is just the path to the file, but we give an extended functionality if PIL is available. You can in that case get the image object or numpy arrays in both int and float format. We named it CImage to avoid confusion with PIL’s Image class.

__init__(id, path, collada=None, xmlnode=None)

Create an image object.

Parameters:
  • id (str) – A unique string identifier for the image
  • path (str) – Path relative to the collada document where the image is located
  • collada (collada.Collada) – The collada object this image belongs to
  • xmlnode – If loaded from xml, the node this data comes from

Methods

__init__(id, path[, collada, xmlnode]) Create an image object.
load(collada, localspace, node)
save() Saves the image back to xmlnode.

Attributes

data
floatarray
pilimage
uintarray
id

The unique string identifier for the image

path

Path relative to the collada document where the image is located

xmlnode

ElementTree representation of the image.

data

Raw binary image file data if the file is readable. If aux_file_loader was passed to collada.Collada.__init__(), this function will be called to retrieve the data. Otherwise, if the file came from the local disk, the path will be interpreted from the local file system. If the file was a zip archive, the archive will be searched.

pilimage

PIL Image object if PIL is available and the file is readable.

uintarray

Numpy array (height, width, nchannels) in integer format.

floatarray

Numpy float array (height, width, nchannels) with the image data normalized to 1.0.

save()

Saves the image back to xmlnode. Only the id attribute is saved. The image itself will have to be saved to its original source to make modifications.