Saturday, August 30, 2025
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
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32249 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6617 POSTS0 COMMENTS
Nicole Veronica
11792 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11838 POSTS0 COMMENTS
Shaida Kate Naidoo
6731 POSTS0 COMMENTS
Ted Musemwa
7013 POSTS0 COMMENTS
Thapelo Manthata
6689 POSTS0 COMMENTS
Umr Jansen
6701 POSTS0 COMMENTS