Wand resize() function in Python
Resize image refers to change dimensions of original image in order to convert original image in dimensions that are perfect to use.Scaling Down refers to decrease dimensions of images and make image size smaller. While Scaling Up refers to increase dimensions of an image, and making image size larger.
resize() function is used in order to Resize an image.
Syntax:
wand.image.resize(width=None, height=None, filter='undefined', blur=1)
Parameters :
Parameter |
Input Type |
Description |
width |
numbers.Integral |
New width of image |
height |
numbers.Integral |
New height of image |
filter |
basestring or numbers.Integral |
A filter type to use for resizing. |
blur |
numbers.Real |
The blur factor where > 1 is blurry, < 1 is sharp |
Example 1 :
Input Image :
Python3
from wand.image import Image
with Image(filename = 'gog.png' ) as img:
img.resize( 50 , 50 , filter = 'undefined, blur = 1 )
img.save(filename = 'resized_gog.png' )
|
Output :
Example 2 :
Input Image :
Input will be from a url.GeeksforGeeks
Python3
import urllib3
from cStringIO import StringIO
from wand.image import Image
from wand.display import display
http = urllib3.PoolManager()
f = StringIO(r.data)
with Image( file = f) as img:
img.resize( 400 , 300 )
img.save(filename = 'gogurl.png' )
display(img)
|
Output :
Last Updated :
18 Aug, 2021
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...