Skip to main content

Abraia Python SDK

Project description

PyPI Build Status Coverage Status Analytics

Abraia API client for Python

Python client for the Abraia API, used to smartly 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

Optimized and smart cropped skater

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 and CLI works in Windows, Mac, and Linux with Python 3, and can be installed with a simple command:

pip install -U abraia

Verify that the abraia CLI is correctly installed:

abraia --version

If you get a message of command not found try to uninstall the package and install it again globally:

pip uninstall abraia
sudo pip install abraia

Finally, configure your free API Key using the command bellow:

abraia configure

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

Batch output

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

Resized lion

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

Smart cropped lion

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

Image editing

Using templates images can be easily edited and consistently branded. You just need to use or create a template in the web editor to edit a batch of images from the command line.

abraia optimize --action test.atn --width 333 images/lion.jpg images/branded.jpg

Branded lion

As a result you get a perfectly branded and optimized image ready to be used on your website, ecommerce, marketplace, or social media.

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.

from abraia import Abraia

abraia = 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 croppend bird Smart cropped birds

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')

PNG Jaguar original PNG Jaguar optimized JPEG Jaguar optimized

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

This version

0.6

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

abraia-0.6.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

abraia-0.6-py2.py3-none-any.whl (9.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file abraia-0.6.tar.gz.

File metadata

  • Download URL: abraia-0.6.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.1 CPython/3.6.7

File hashes

Hashes for abraia-0.6.tar.gz
Algorithm Hash digest
SHA256 3d948ea15053bf31aa8ed5233af5327cc0de20fb71f67e5b18f6c3743dfe07bc
MD5 97f17d2223d00878eb18b0e933909d33
BLAKE2b-256 359321e4b9cb430e4253f45c3169cd322645902c89e01f20f0344db98e6b5229

See more details on using hashes here.

File details

Details for the file abraia-0.6-py2.py3-none-any.whl.

File metadata

  • Download URL: abraia-0.6-py2.py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.1 CPython/3.6.7

File hashes

Hashes for abraia-0.6-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 87e8c92a2098ca07d05b43d1b465d164785997c0f0902d0fb05b173e939b5f74
MD5 5aa42dc78cff9986fa9d9bae2b2e489f
BLAKE2b-256 d809727719a2e7c20002880ebf1283e1cdcc479a8509afe1d0a882a7fa84aff8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page