Image

The Image widget is used to display an image.

wimg = Image(source='mylogo.png')

Asynchronous loading

To load an image asynchronously (for example from an external webserver), use the AsyncImage subclass

aimg = AsyncImage(source='http://mywebsite.com/logo.png')

Alignement

By default, the image is centered and fitted inside the widget bounding box. If you don’t want that, you can inherit from Image and create your own style.

For example, if you want your image to take the same size of your widget, you can do

class FullImage(Image):
    pass

And in your kivy language file, you can do

<FullImage>:
    canvas:
        Color:
            rgb: (1, 1, 1)
        Rectangle:
            texture: self.texture
            size: self.size
            pos: self.pos
class kivy.uix.image.Image(**kwargs)

Bases: kivy.uix.widget.Widget

Image class, see module documentation for more information.

allow_stretch

If True, the normalized image size will be maximized to fit in the image box. Otherwise, if the box is too tall, the image will not be streched more than 1:1 pixels

New in version 1.0.7.

allow_stretch is a BooleanProperty, default to False

anim_delay

Delay of animation if the image is sequenced (like animated gif). If the anim_delay is set to -1, the animation will be stopped.

New in version 1.0.8.

anim_delay is a NumericProperty, default to .25 (4 FPS)

color

Image color, in the format (r, g, b, a). This attribute can be used for ‘tint’ an image. Be careful, if the source image is not gray/white, the color will not really work as expected.

New in version 1.0.6.

color is a ListProperty, default to [1, 1, 1, 1].

image_ratio

Ratio of the image (width / float(height)

image_ratio is a AliasProperty, and is read-only.

keep_ratio

If False along with allow_stretch being True, the normalized image size will be maximized to fit in the image box disregarding the aspect ratio of the image. Otherwise, if the box is too tall, the image will not be streched more than 1:1 pixels

New in version 1.0.8.

keep_ratio is a BooleanProperty, default to True

mipmap

Indicate if you want OpenGL mipmapping to be apply on the texture or not. Read Mipmapping for more information.

New in version 1.0.7.

mipmap is a BooleanProperty, default to False.

norm_image_size

Normalized image size withing the widget box.

This size will be always fitted to the widget size, and preserve the image ratio.

norm_image_size is a AliasProperty, and is read-only.

reload()

Reload image from disk. This facilitates re-loading of image from disk in case of contents having been changed.

New in version 1.3.0.

Usage:

im = Image(source = '1.jpg')
# -- do something --
im.reload()
# image will be re-loaded from disk
source

Filename / source of your image.

source a StringProperty, default to None.

texture

Texture object of the image.

Depending of the texture creation, the value will be a Texture or TextureRegion object.

texture is a ObjectProperty, default to None.

texture_size

Texture size of the image.

Warning

The texture size is set after the texture property. So if you listen on the change to texture, the property texture_size will be not yet updated. Use self.texture.size instead.

class kivy.uix.image.AsyncImage(**kwargs)

Bases: kivy.uix.image.Image

Asynchronous Image class, see module documentation for more information.