Image — Kivy v1.0.1-dev documentation

# Image

Core classes for loading image and convert them to `Texture`. The raw image data can be keep in memory for further access.

Note

Saving image is not yet supported.

class `kivy.core.image.` `Image`(arg, **kwargs)

  Bases: `kivy.event.EventDispatcher`

  Load an image, and store the size and texture.

  Parameters : | arg : can be str or Texture or Image object A string is interpreted as a path to the image to be loaded. You can also provide a texture object or an already existing image object. In the latter case, a real copy of the given image object will be returned. keep_data : bool, default to False Keep the image data when texture is created opacity : float, default to 1.0 Opacity of the image scale : float, default to 1.0 Scale of the image texture_rectangle : bool, default to True Use rectangle texture is available (if false, will use the nearest power of 2 size for texture) texture_mipmap : bool, default to False Create mipmap for the texture

  `filename`

    Get/set the filename of image

  `height`

    Image height

  `image`

    Get/set the data image object

  static `load`(filename, **kwargs)

    Load an image

    Parameters : | filename : str Filename of the image keep_data : bool, default to False Keep the image data when texture is created

  `read_pixel`(x, y)

    For a given local x/y position, return the color at that position.

    Warning

    This function can be used only with images loaded with keep_data=True keyword. For examples

        m = Image.load('image.png', keep_data=True)
        color = m.read_pixel(150, 150)

    Parameters : | x : int Local x coordinate of the pixel in question. y : int Local y coordinate of the pixel in question.

  `size`

    Image size (width, height)

  `texture`

    Texture of the image

  `width`

    Image width

class `kivy.core.image.` `ImageData`(width, height, fmt, data)

  Bases: `object`

  Container for data image : width, height, fmt and data.

  Warning

  Only RGB and RGBA format are allowed.