Wand – Convert image format
Last Updated :
08 May, 2020
Image Format describes how an image data is being stored. Different image formats have different merits and demerits. There are around 7 most common image formats which are used in different cases.
For example – The advantage of JPEG format is that it supports 24-bit color with up to 16 million colors. Thus, having high resolution. While PNG format have Low Resolution.
Image file formats :
1. JPEG(.jpeg)
2. PNG(.png)
3. TIFF(.tif or.tiff)
4. GIF(.gif)
5. Bitmap(.bmp)
6. EPS(.eps)
Note: To study in detail about Image Formats refer – Image Formats Article.
We can convert one image format to another using Wand library in Python using format
property.
Syntax :
wand.image.format = 'final_format'
Code :
from wand.image import Image
with Image(filename = 'koala.png' ) as img:
img. format = 'jpeg'
img.save(filename = 'koala.jpg' )
|
In output, we will get an image with name koala.jpeg
with jpeg image format.
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...