
We often receive JPG images that do not meet our size requirements, so they must be resized. This article shows how to resize JPG images in Python with a step-by-step guide and code snippets.
This article covers the following topics:
- Python API to resize JPG images
- Resize JPG images
- JPG image resizer using resize type
- Resize the JPG image proportionally
- Try JPG image resizing online
- Free learning resources
Resize Images in Python - Free Download
We will use Aspose.Imaging for Python to resize images programmatically. The API lets developers create, load, manipulate, convert, and compress raster and vector images in many supported file formats.
Please download the package or install the API from PyPI using the following pip command:
pip install aspose-imaging-python-net
Resize JPG Images in Python
You can resize a JPG image in Python by following these steps:
- Load the image file with the Image class.
- Call Image.resize(int, int) to set the new dimensions.
- Use Image.save(string) to write the resized image to a file.
The code sample below demonstrates how to resize an image in Python.
Resize JPG Images with a Resize Type
You can also specify a resize type. Pass ResizeType to Image.resize(int, int, ResizeType). The ResizeType enum defines several resizing techniques. See the full list here.
The sample below shows how to resize an image with a resize type in Python.
Proportional Image Resizing in Python
Resizing by fixed width and height can distort the image if the aspect ratio is not calculated correctly. Proportional resizing avoids this issue.
Steps:
- Load the image with the Image class.
- Set the desired height and width.
- Use Image.resize_width_proportionally(int) and Image.resize_height_proportionally(int) to keep the aspect ratio.
- Save the result with Image.save(string).
The following code shows how to resize an image proportionally in Python.
If you need a specific resize type while resizing proportionally, use the overloads Image.resize_width_proportionally(int, ResizeType) and Image.resize_height_proportionally(int, ResizeType).
Resize Images with a Free License
You can get a free temporary license to resize images without evaluation limitations.
Resize JPG Image Online
Resize JPG images online with this free image resizer web app, built using the same API.

JPG Image Resizer – Learning Resources
Explore more about creating, manipulating, and converting images with these resources:
Conclusion
In this article, we learned how to resize JPG images programmatically in Python. The code samples demonstrate simple resizing and resizing with a specific type. You can download the full source code package from GitHub. For questions, visit our free support forum.