Returns a PIL Image object of instagram compatible aspect ratio when supplied with an image URL or an image object.
Project description
Instaresizer
Description
Instagram only allows images between aspect rations 16:9 (landscape) and 4:5 (portrait) mode to be uploaded. Images that are wider than 16:9 or taller than 4:5 are not supported by Instagram for uploads. Instaresizer is an image resizer that can be used to convert images of any aspect ratio to instagram supported aspect ratios. This resizer converts the image to optimal dimensions depending on the original image's orientation. If the image is too wide, it fills transparent pixels on top and bottom to bring the image to the supported aspect ratio of 16:9. Similarly if the image is too tall, it fills in the left and right of the image with transparent pizels to bring the aspect ratio to 4:5.
Usage
Installation
pip install instaresizer
Example
Importing the library
#!/usr/bin/env python3
from instaresizer import instasize
Usage - resizing remote image file supplied via a URL.
This is useful if the image is publicly accessible with no additional authentication requirements.
image_url = 'https://s3.amazonaws.com/images.seroundtable.com/30th-anniversary-of-the-world-wide-web-google-1552390014.gif'
img = instasize.resize_remote(image_url)
img.save('resized_file.png', 'PNG')
Usage - resizing local image file.
image = Image.open("test_image.jpeg")
img = instasize.resize_image(image)
img.save('resized_file.png', 'PNG')
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file instaresizer-0.0.5.tar.gz.
File metadata
- Download URL: instaresizer-0.0.5.tar.gz
- Upload date:
- Size: 15.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a05694b88c063a5a86fd447fcb57ed981e16a6954d89f4f82bcfd201e3eb389e
|
|
| MD5 |
c057d56de393abab0abb03fb673edd30
|
|
| BLAKE2b-256 |
294b797e9c47c7b07061f8f85620d11af66dc52f5511999d33b3017c53401163
|
File details
Details for the file instaresizer-0.0.5-py3-none-any.whl.
File metadata
- Download URL: instaresizer-0.0.5-py3-none-any.whl
- Upload date:
- Size: 15.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
40d4d98cc026c32f4c8758ca85246ea15d57ec371ba1cc331f8fd93f81b87097
|
|
| MD5 |
1fa4c2685d616bb55c1ed92c4fcf144b
|
|
| BLAKE2b-256 |
ed23d42ac9388b902560ea9cc2006b330e60612576beb780937c2526a658ee91
|