Batch optimize images for web from the command line

Sometimes you just need to optime a batch of images in a folder to upload to the web. This can be easily made with the Abraia Command Line Interface (CLI). This tool simplifies to compress all your JPEG, PNG, and WebP images contained in a local folder.

Batch image optimization terminal

You just need to install the CLI tool and write a simple command to perfectly optimize all your images in a folder. You can also resize your images with just one command.

Batch tool installation

Abraia's CLI is a multiplatform tool (Windows, Mac, Linux) free and easy to install. It just requires Python 2.6.5 or higher. So, if you are on Windows install Python, or continue if you are a Mac or Linux user.

Open a terminal (command line) and write the commands bellow to install or upgrade Abraia CLI:

$ pip install -U abraia
$ abraia --version

The first time you run Abraia CLI you need to configure your free API key. Go to the settings tab and copy the API key to configure it in the command line:

$ abraia configure
Abraia Key []: your_abraia_key

Batch optimize your images

Once the tool is installed you can start optimizing your images. Write the command abraia followed by the subcomand optimize and specify the folder path to be optimized. By default it always creates a file or folder copy with the image results.

$ abraia optimize [path]

Batch resize your images

You can also resize your images with just to specify the target width or height. For example, to get a set of images with a fixed width of 300px preserving the aspect ratio of each image:

$ abraia optimize --width 300 [path] [dest]

To use our smart cropping technology and get the compressed results for all the images contained in a folder structure, it is so simple as:

$ abraia optimize --width 300 --height 300 [path] [dest]

Batch watermark your images

Using templates, you can easily watermark and edit a set of images to make they look consistent in your site or social media channel. This can be made creating a template with the graphical editor in the Abraia console. Once created the template, you can start using it to brand your images by batches.

$ abraia optimize --action brand.atn [path] [dest]

With this simple command your are going to edit and compress all your images with the created template. You can also take advantage from our smart cropping technology to automatically crop and edit your images preserving the content and aesthetics, or to automatically create photo collages and compositions.