Free Trial
10 days, no credit_card

<< More Tutorials

How to resize an image by height in Python 3 using rethumb?

To resize an image or photo in Python 3 use the following code:

from urllib.request import urlopen

param_operation = "height"
param_value = 100 # New height in pixels.

image_url = "http://images.rethumb.com/image_coimbra_600x300.jpg"
image_filename = "resized-image.jpg"

response = urlopen("http://api.rethumb.com/v1/{0}/{1}/{2}".format(param_operation, param_value, image_url))
fh = open(image_filename, "wb")
fh.write(response.read())
fh.close()

Start using this example now

Use the following commands to get started:

$ git clone https://github.com/rethumb/rethumb-python3-examples.git
$ cd rethumb-python3-examples
$ python3 resize-by-height.js

More examples using Python 3