1. Products
  2.   Image
  3.   Python
  4.   Wand
 
  

Open Source Python API for Images

ctypes-based simple ImageMagick Binding for Python

Wand is an open source Python API for manipulating images. The API is a ctypes-based simple ImageMagick binding for Python. Using the API you can read images, write images, add image effects, add special effects, transform images, perform color enhancement, manage image distortion, handle drawing, read EXIF info manage layers and sequences, and more,

Compared to other python bindings for MagicWand, the wand offers pythonic and modern interfaces, binding through ctypes and only C API, and easy installation through pip.

Previous Next

Getting Started with Wand

The recommended way to install wand is via Pip. Please use the following command to install Pip.

Install Wand via Pip

pip install Wand

Read, Write & Resize Images via Free Python API

Wand API allows reading, writing, resizing & cropping images programmatically. Using the API, you open an existing image, read the input stream, read a blob, open an empty image, open and a pseudo image. While writing images you can convert images to JPEG, save them to a new file, save it to a stream, and get a binary output image. Furthermore, you can resize, crop, and transform images easily.

Transform Images via Free Python API


# crop top left corner
img.transform('50%')

# scale height to 100px and preserve aspect ratio
img.transform(resize='x100')

# if larger than 640x480, fit within box, preserving aspect ratio
img.transform(resize='640x480>')

# crop a 320x320 square starting at 160x160 from the top left
img.transform(crop='320+160+160')

Add Effects in Images via Python

This open-source python API wand allows adding effects to your images programmatically. Using the API, you can blur images, use despeckle, edge, emboss, Kuwahara, shade, sharpen and spread effects. Furthermore, you can special effects like add noise, blue shifts, charcoal, color matrix, colorize, FX, and more.

Add Emboss Effect to Image via Python


from wand.image import Image

with Image(filename="hummingbird.jpg") as img:
    img.transform_colorspace('gray')
    img.emboss(radius=3.0, sigma=1.75)
    img.save(filename="effect-emboss.jpg")

Convert Images to Other Formats via Python

The open source Python library wand gives software developers the capability to export images to other supported file formats inside their Python applications. You can use the format property to know about the image format. Developers can convert their images to numerous popular image file formats such as GIF, JPEG, BMP, PNG, SVG, TIFF, and many more. The library supports the image conversion without any changes of the original image or users can apply different effects before writing it the desired format. It provides several method for saving your image, such as saving image to a file, write an image into a output stream or get a binary string of the image.

Convert PNG Image to JPEG via Python

from wand.image import Image

with Image(filename='pikachu.png') as original:
    with original.convert('jpeg') as converted:
        # operations to a jpeg image...
        pass

 English