Saturday, September 21, 2024
Google search engine
HomeLanguagesPython – Scaling image using pgmagick

Python – Scaling image using pgmagick

Scaling is the process of resizing an image. We deal with the dimensions of an image. Scaling down deals with making image smaller while Scaling up refers to increase the size of image. Scaling is a very important process in image manipulation because sometimes we get image size smaller than expected and sometimes it is very large. So, in order to make image of perfect size to use Scaling is performed. In this article we will learn how we can perform scaling using pgmagick in python. Code : 

Python3




# importing library
from pgmagick.api import Image
 
img = Image('gog.png')
 
# scaling image
img.scale((150, 100), 'lanczos')
img.write('scale_gog.png')


Input Image: Output: Scaling JPEG image – JPEG Stands for Joint Photographic Experts Group. Due to high number color support upto 2^24 i.e. 16, 777, 216 this is used in commonly every digital camera. And support varying levels of compression. 

Python3




# importing library
from pgmagick import Image, Blob
 
img = Image(Blob(open('koala.jpeg').read()))
 
# scaling image
img.scale('250x200')
img.write('scale_koala.jpeg')


Input Image: Output:

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments