Saturday, November 16, 2024
Google search engine
HomeLanguagesWand Python – Introduction and Installation

Wand Python – Introduction and Installation

Imagemagick is a tool developed to convert images from one format to another. Due to a versatile range of image formats and its precise and simple working, it has a huge community support. We can get images from pdf files.
Wand is a binding developed for python by Imagemagick.wWand opens and manipulate images. Wand provides a large number of functions for image manipulation.

Uses of Wand Library:
1. Read/Write images of different formats
2. Converting images from one form to another
3. Scaling and Cropping
4. Add simple effects to image
5. Add Special effects to images
6. Transform images
7. Other color Enhancements

Installation:
Using pip:
Wand can be easily installed by running

$ pip install Wand

in a terminal oR Command Prompt.

Installation on Linux:
we can install Wand in Linux by running the below command

sudo apt-get install libmagickwand-dev

If we need SVG, WMF, OpenEXR, DjVu, and Graphviz support we have to install libmagickcore5-extra as well, to install libmagickcore5-extra run,

sudo apt-get install libmagickcore5-extra

in your terminal.

Installation on Mac:
We can simply install wand by using brew command as below

 brew install imagemagick

in terminal.

Installation on Windows:
You could build ImageMagick by yourself, but it requires a build toolchain like Visual Studio to compile it. The easiest way is simply downloading a prebuilt binary of ImageMagick for your architecture (win32 or win64). You can download it from here.

Below is a simple use case example of Wand library where we write python code to convert image from jpeg format to png
Example:




from __future__ import print_function
from wand.image import Image
  
with Image(filename ='koala.jpeg') as img:
    with img.convert('png') as converted:
        converted.save(filename ='png_koala.png')


Output:

RELATED ARTICLES

Most Popular

Recent Comments