How to convert and resize images for web from the command line
The Abraia CLI tool provides a simple way to bulk convert and optimize your images and
photos for web. Enabling the conversion from different input formats to get images in the right formats to be
used in the web - JPEG, WebP, or PNG -. Moreover, it supports a number of transformations that can be applied
to image batches. So you can easily convert your images to be directly published on the web.
With the Abraia CLI tool you can easily optimize images and photos by batches. For
instance, you can easily compress a folder of images with a simple command:
abraia optimize images
images is the folder path to be optimized. -By default it always creates
a folder copy with the image results.-
Abraia CLI tool installation
Abraia CLI is a multiplatform tool (Windows, Mac, Linux) based on Python (Python 2.6.5 or
higher), that can be be installed with a simple command:
python -m pip install -U abraia
If you are on Windows install Python first,
otherwise open a terminal or command line and write the previous command to install or upgrade the Abraia CLI.
The first time you run Abraia CLI you need to configure your API
key, just write the command bellow and paste your API key.
$ abraia configure
Now, you are ready to convert your images from the command line.
Convert SVG to PNG
Converting a SVG image to PNG, now is so simple as to type the command bellow:
abraia convert bat.svg bat.png
The SVG vector image is rendered in a Chrome instance to provide maximum fidelity, and
preserving the transparent background.
Convert image to WebP
The JPEG image format is still the most common format to publish photos on the web.
However, converting images to WebP provides a significant improvement for web publishing. To convert an image
to WebP just write a simple command like bellow:
abraia convert garlic.jpg garlic.webp
The same can be used to convert a GIF animation to WebP and save several bytes.
abraia convert bob-sponge.gif bob-sponge.webp
Convert PSD to JPG
A .PSD file is a layered image file used in Adobe PhotoShop for saving data. You can
easily convert then, and get the result of flattening all the visible layers with a command like bellow:
abraia convert strawberry.psd strawberry.jpg
The previous command just convert a PSD file to JPEG, automatically adding a white
background, in this case, because the JPEG format does not support transparency. Instead, using the PNG format
you can preserve the transparent background.
abraia convert strawberry.psd strawberry.png
Resize and compress images for web
To resize your images just specify the target
For example, 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 automatically crop all your images contained in a folder using our smart cropping
technology, you just need to specify both
height of the output image.
abraia optimize --width 300 --height 300 [path] [dest]