Live Chat

We'll need to share your messages (and your email address if you're logged in) with our live chat provider, Drift. Here's their privacy policy.

If you don't want to do this, you can email us instead at

image module

API Docs

The image module allows you to manipulate images in your Anvil app. Begin by importing the anvil.image module.

Get dimensions

To get the width and height of an image, use get_dimensions:

import anvil.image

# The image can be any Media object containing an image
image_media = URLMedia('')

width, height = anvil.image.get_dimensions(image_media)

print("The image is %s pixels wide and %s pixels high" % (width, height))

Generating thumbnails

To generate a thumbnail of an image (for uploading, for example) use the generate_thumbnail method.

# Resize the image to have a maximum dimension of 120px.
small_img = anvil.image.generate_thumbnail(image_media, 120)


To rotate an image clockwise by some number of degrees, use the rotate method.

# Rotate the image by 30 degrees.

rotated_image = anvil.image.rotate(img, 30)