pgmagick is a GraphicsMagick binding for Python. This module provides methods for Image Editing and Manipulation. pgmagick is written by Hideo Hattori.
We can do a lot of things using this library such as :
- Resize, rotate, sharpen, color reduce, or add special effects to an image.
- Create transparent image assets.
- Compare two images.
- Create a gradient image.
- Draw Text.
- Draw Text of 2 byte code.
- Get image size
- Edge extraction
- Create GIF animation using images.
- Add frames to image.
- Converts images from one format to another.
Installation :
There are two ways to install
pgmagick:
- Windows: Execute following command in Command Prompt-
pip install pgmagick
- Ubuntu : Execute the following command in Terminal-
### Ubuntu11.10+ ###
$ apt-get install python-pgmagick
### Ubuntu10.04+ ###
$ apt-get install libgraphicsmagick++1-dev
$ apt-get install libboost-python1.40-dev
Example#1: Let's discuss a code to resize the image-
For illustration purpose I have taken following sample image-
👁 Image
Output:
👁 Image
Example#2: Let's discuss a code to scale the image-
I have used the same sample image for input as in above example.