A simple way to resize an image programmatically, using the PythonMagick module. This module is a python port of the the magick++ library.
Resize an image with PythonMagick
#Â AUTHOR: Gribouillis for the python forum at www.daniweb.com
import PythonMagick as Magick
in_name = 'scilab01.png'
out_name = 'scilab01_small.png'
img = Magick.Image(in_name)
geometry = img.size()
w, h = geometry.width(), geometry.height()
new_width = 800
factor = new_width/float(w)
new_height = int(h * factor)
img.resize("{}x{}".format(new_width, new_height))
img.write(out_name)
arronlee 0 Newbie Poster
Gribouillis 1,391 Programming Explorer Team Colleague
Nils_1 0 Newbie Poster
Gribouillis 1,391 Programming Explorer Team Colleague
Nils_1 0 Newbie Poster
Gribouillis 1,391 Programming Explorer Team Colleague
Nils_1 0 Newbie Poster
Gribouillis 1,391 Programming Explorer Team Colleague
Gribouillis 1,391 Programming Explorer Team Colleague
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.