Abraia Python SDK
Project description
Abraia API client for Python
Python client for the Abraia API, used to smartly transform and optimize (compress) images on-line. Read more at https://abraia.me/docs.
Optimize images for Web with no quality damage based on perception-driven technology.
- Optimal image compression with our perceptual adjustment to preserve the quality and maximize the compression.
- Smart crop and resize images with our saliency and aesthetic based model which balances between content and aesthetics.
abraia optimize --width 800 --height 400 https://images.pexels.com/photos/700948/pexels-photo-700948.jpeg images/skater.jpg
The example takes a 10.1MB image by Willian Was from Pexels with a size of 4865x3321 pixels and automatically generates a 94.4kB header of 800x400 pixels, cropping, resizing, and optimizing the image to directly be used on Web.
Installation
The Abraia python client works in Windows, Mac, and Linux with Python 2 and 3 (python>=2.6.5).
Install the API client and the CLI with a simple command:
pip install -U abraia
Verify that the abraia CLI is correctly installed:
abraia --version
Finally, configure your API Keys using the command bellow:
abraia configure
You can create a free account to get your API Keys.
Command line interface
With the CLI tool you can optimize and resize images by batches.
You can easily compress a folder of images with a simple command:
abraia optimize images
To resize an image you just need to specify the width
or the height
of
the image:
abraia optimize --width 500 images/lion.jpg images/lion_500.jpg
To automatically crop and resize
specify both the width
and height
size parameters:
abraia optimize --width 333 --height 333 images/lion.jpg images/lion_333x333.jpg
To filter and image specify some of the available filters:
abraia optimize --width 333 --height 333 --filter desaturate images/lion.jpg images/filtered.jpg
Moreover, images can be converted from one format to another changing the filename extension for the destination file.
abraia optimize images/jaguar.png images/jaguar.jpg
Fluent API
Abraia fluent API is the easiest way to compress and transform images with python. You just need to define the source of the image, the transformation operation, and the sink for the resultant image.
import abraia
abraia.from_file('images/bird.jpeg').resize(
width=375, height=375).to_file('images/bird_375x375.jpg')
abraia.from_url('https://api.abraia.me/files/demo/birds.jpg').resize(
width=750).to_file('images/birds_750.jpg')
abraia.from_store('birds.jpg').resize(
width=375, height=375).to_file('images/birds_375x375.jpg')
Smart cropped image examples
All the operation parameters are automatically chosen to provide the best results balancing quality and file size for a perfectly responsive website.
PNG and WebP images can significantly optimized also.
abraia.from_file('images/jaguar.png').to_file('jaguar_o.jpg')
abraia.from_file('images/jaguar.png').to_file('jaguar.jpg')
Original PNG (45KB) vs optimized PNG (15.8KB) vs optimized JPEG (14.1KB)
License
This software is licensed under the MIT License. View the license.
Project details
Release history Release notifications | RSS feed
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
File details
Details for the file abraia-0.4.1.tar.gz
.
File metadata
- Download URL: abraia-0.4.1.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.20.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc105b0b112ee0fdccde24d98850b0a915566c754e423f5c226f5d13e7b503d5 |
|
MD5 | 36647dea7209e396ea9409f679bed505 |
|
BLAKE2b-256 | 374c739e0ef28656d05279952599e0e09276dff1cbab0ead8615658b8f19d941 |
File details
Details for the file abraia-0.4.1-py2.py3-none-any.whl
.
File metadata
- Download URL: abraia-0.4.1-py2.py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.20.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 857d9b12f74a8147bafa8f536c2fd717e566b5427d3ddf41fb9f52c81f6845e6 |
|
MD5 | c556c9d3d0986f2ec030213707d01eab |
|
BLAKE2b-256 | 979842b280c19880c444cb29a2b25b19f099ccdde64fde5dd7c81aab9ae4640e |