aaphoto Makes Your Photos A+

by Paul Arnote (parnote)

Deep in the recesses of the PCLinuxOS repository, unassumingly and quietly tucked into the long list of available applications, there’s a little hidden gem, just waiting to be uncovered. When you rub and shine and polish this gem, it will take your photos and make them even better.

Well, that may be going a little far, but aaphoto can work magic on your photos that have suffered from improper exposure or bad lighting conditions. In short, it can take many of your previously unusable photos and make them usable. Let me show you.

The aaphoto application is a small (112 KiB) command line utility, so you will need to know a little bit about running an application from the command line in a terminal session. But don’t worry – it’s not hard.

Currently up to version 0.41, aaphoto is written by Andras Horvath, from Hungary, and is undergoing active development. The most current version (and the version available in the PCLinuxOS repository) was released on June 12, 2011. The application is cross platform, written for Linux, FreeBSD and Windows. Here is the description of aaphoto, from Synaptic:

aaPhoto (CLI) (Auto Adjust Photo) corrects the colors of the image and generates a new image file on the disk. Two main functions: automatic color correction and resizing!

The program tries to give a solution for the automatic color correction of photos. This means setting the contrast, color balance, saturation and gamma levels of the image by analization.

This can be a solution for those kind of users who are not able to manage and correct images with complicated graphical softwares, or just simply don't intend to spend a lot of time with manually correcting the images one-by-one.

The program handles the following image formats: mif, pnm/pgm / ppm, bmp, ras, jp2, jpc, jpg, png.

Service menus for KDE4 are integrated, but the command line offers more options.

As with most command line tools, aaphoto is controlled by a host of command line switches. The following options are supported:

    -h   --help          Print this help

    -v   --version       Print version information

    -a   --autoadjust    Auto adjust the colors of the image

    -o   --output        Set output directory

         --overwrite     Overwrite mode, the original source file is replaced

                (Not recommended! NEVER EVER overwrite an original file, if you can avoid it!)

         --jpg           JPEG image output

         --jp2           JPEG 2000 image output

         --png           PNG image output with alpha channel support

         --bmp           BMP image output

    -r   --resize        Resize image taking the longer side in % or pixels

         --rotate90      Rotate image with 90 degrees clockwise

         --rotate180     Rotate image with 180 degrees

         --rotate270     Rotate image with 90 degrees counter-clockwise

         --flipx         Mirror image horizontally

         --flipy         Mirror image vertically

         --noexif        Save image without EXIF info

    -q   --quality       Set image quality from 1 to 100

    -t   --threads       Set number of working threads (default: autodetect)

    -s   --silent        Silent mode, no information printed during operation

         --quiet         ...same as above

    -V   --verbose       Print verbose information about processing

         --test          Print detailed test information into image

The order of the command line switches is NOT important. Just be sure that the source file (the filename of the image you are trying to improve) is the last thing listed on the command line. You can view the “help” for aaphoto at any time by entering aaphoto --help at a command line prompt in a terminal session, or you can view it on the web here. You can also visit the web homepage for aaphoto here, or visit the aaphoto wiki here. Note that the latter two pages are written in Hungarian, but Chromium browser offers to automatically translate them for you into your native language. There is an English language translation of the aaphoto homepage here.

Take a second to review the command line switches, and you will soon see that aaphoto does more than color correction of your photos. It will also rotate images, resize images, mirror images, set image quality, and strip EXIF information from your images. There may be other graphics manipulation applications that do more, but aaphoto does an admirable job with the tasks that it does cover. Plus, aaphoto does it fairly quickly.

The “magic” performed by aaphoto happens when aaphoto analyzes the histogram of the image, then tweaks various settings such as contrast, color balance, saturation and gamma levels.

Some examples

All this talk means nothing by itself, so let’s see some examples of what aaphoto is capable of.

From one of my recent bicycle trips on my vacation in August, here is an image that – until I discovered aaphoto – was pretty much unusable.

Notice the haze across the image from shooting into the relatively low morning sun. The colors are all muted and a lot of the detail in the photo is lost.

Here is the same image, after running it through aaphoto.

You’ll notice that there is still some lens flare in the upper right corner of the image, but now a lot of the haze is gone, and the colors are a lot more vivid. While not perfect, aaphoto has made the image usable, and restored the image to how I remember seeing the image in my mind. The aaphoto command line I used to improve the image is this:

aaphoto --png -a --rotate270 original_photo.jpg

The --png switch tells aaphoto to output the finished file as a PNG graphic file. The -a switch tells aaphoto to automatically correct the colors in the photo. The --rotate270 switch tells aaphoto to rotate the image 90 degrees counter-clockwise (or 270 degrees clockwise). Finally, the command line is ended with the name of the image I want to improve.

Here are some other images that aaphoto helped improve. The command line used is shown under the improved image.

aaphoto --png -a original_photo.jpg

aaphoto --png -a original_photo.jpg

aaphoto --png -a original_photo.jpg

aaphoto --png -a original_photo.jpg

In the last photo, the changes are subtle. In the original, my face took on a blueish hue, due to all the blue in the photo. In the “improved” image, the skin tones are improved, the amount of shadow under my PCLinuxOS hat has been reduced, and the colors are more vivid (like in the leaves and foliage behind me).

“Service Menus”

Under KDE4, some KDE service menus are installed when you install aaphoto. Unfortunately, the installed KDE service menus are of very limited use – unless you know how to write your own KDE service menus (and that is a topic for a whole ‘nother article). Compared to the KDE service menus, you will find aaphoto to be much more useful when used from the command line.

Still, here is the installed service menus under KDE4:

As you can see, the KDE service menus leverage only a fraction of the capabilities of aaphoto. Mirror image as a service menu? I would have thought that the image resizing or image rotation functions would be much more useful additions to the service menu. I can’t even think of the last time I had to mirror an image.

Fortunately, “service menus” are much easier to create for Thunar and Nautilus users – except that neither call them “service menus.” Under Thunar, they are called “Custom Actions,” and under Nautilus, they are called “Nautilus Scripts.”

Under Thunar’s Custom Actions, the aaphoto command will take the following form:

aaphoto --png -a -r600 %n

The above command will convert a single image image (%n) to a PNG file, auto correct the color, and resize it to 600 pixels wide (along its longest border). You can customize the command as you see fit, to include the command line options you desire. Just be sure to give each different command its own, unique name.

Under Nautilus, you can create a custom script, similar to the one below:


while [ $# -gt 0 ]; do


   aaphoto --png -a -r600 "$picture" "600-$picture"



This Nautilus Script does exactly the same as the Thunar Custom Action above, but only on multiple files. Also, just as with the Thunar Custom actions above, you can alter this script to include the command line options you want. Also, give each script its own unique name.


As you can see, aaphoto comes in just short of working miracles on photos with skewed colors, either due to exposure or poor lighting conditions. Certainly, you will be able to find photos that aaphoto cannot resurrect and correct. But, in my experience, those instances are few and far between. Without a doubt, aaphoto is a very powerful tool that should be in every computer user’s arsenal of graphics tools.