Friday, May 22, 2026
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

2 COMMENTS

Most Popular

Dominic
32514 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6892 POSTS0 COMMENTS
Nicole Veronica
12012 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12107 POSTS0 COMMENTS
Shaida Kate Naidoo
7016 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6975 POSTS0 COMMENTS
Umr Jansen
6963 POSTS0 COMMENTS