APC Australia

Fix and enhance photos in Linux

Alexander Tolstoy shares best practices for handling your smartphone photos on Ubuntu and other Linux distros.

-

Have you ever wondered what you should do next after pressing the shutter button on your camera? With a set of helpful applicatio­ns and utilities in Linux, you can add extra value to your images by enhancing them, fixing common issues and organising your workflow.

Nowadays, most people take photos with their smartphone­s while a smaller group still rely on their consumer-grade cameras, and as modern storage has grown to many gigabytes, many of us just store all our images on SD cards. Storing photos this way isn’t a bad idea, of course, but there’s a world of other amazing possibilit­ies and that’s where a little extra knowledge on image processing in Linux can be incredibly helpful.

We’ll start with transferri­ng photos from your device to a Linux machine and then proceed with other tasks.

TRANSFERRI­NG IMAGES

Basically, there are two main ways that USB devices, such as cameras and smartphone­s, connect to a PC. These are Mass Storage mode and MTP mode. The first is the simplest and most obvious — you see your device as a mounted removable drive, while the second (media transfer protocol) requires extra integratio­n in Linux desktops. Luckily, all main desktop environmen­ts have decent support for MTP and you’ll hardly notice that your MTP-equipped device isn’t a removable USB storage. For this tutorial, we’ll be using the Nautilus file manager, being a popular choice in Ubuntu Unity and dozens of Gnome-centric Linux distributi­ons (distros).

Of course, the simplest way to transfer images from your device to your hard drive is to use copy and paste. But this way can take a long time and bore you to death, especially when you need a lot of subdirecto­ries for, say, each date when you shot your pictures. There are dedicated applicatio­ns that do the job in a much easier way for you. One is Shotwell, the default photo organiser in Ubuntu and Fedora, another is Digikam, a Swiss Army knife of photo management with an advanced Import module and the third is Rapid Photo Downloader (RPD), which is a smaller tool that does what its name suggests.

The key feature of RPD is that you can set the naming convention to your liking (e.g. DDMMYY) and tell RPD to automatica­lly transfer your images once you insert an SD card or connect a camera. The applicatio­n will create all subdirecto­ries according to given rules and will do everything for you. RPD is distribute­d as a Python package and it’s distro-agnostic once you have all initial dependenci­es. For instance, let’s install it in Fedora:

$ sudo dnf install python3pip python3-wheel

$ python3 -m pip install --user --upgrade pip setuptools

To install RPD, download both the installati­on script and the tarball and then run as a regular user (i.e. without sudo ): $ ./install.py rapid-photodownl­oader-0.9.0a2.tar.gz

RPD can auto-detect the source of images, based on previous attempts and watching for connected USB storage. Make sure to review downloadin­g settings in ‘File > Preference­s’ and enable extra features, such as photo backup (images will be copied to several locations at a time). When you’re done, press the ‘Download’ button to start the transfer.

Sometimes, you will need to apply an edit or transforma­tion to a lot of images, which, for some of you, may have meant doing lots of routines by hand. Luckily, you don’t have to keep doing that and, in the following examples, we’ll cover how to automate bulk actions.

BULK ACTIONS

The first common action is resizing, e.g. you need to attach 20 images to an email, but the recipient doesn’t need that many megapixels in each photo while the web server would simply reject a very big attachment. The easiest way to scale down your photos is to install the dedicated plugin for the Nautilus file manager. In Fedora, do it with the following command:

$ sudo dnf install nautilus-image-converter

There is a very similar (yet different) extension in Ubuntu, which you can get this way:

$ sudo apt-get install nautilus-image-manipulato­r

Whichever you install, don’t forget to restart Nautilus (or simply log out and then log back in) for changes to take effect. Once you do that, select the scope of images you’d like to resize, right-click any of them and select ‘Resize images’. Both Ubuntu and Fedora-centric Nautilus extensions provide nearly the same features: they enable you to specify the new size in pixels or percentage, choose to save new files along with the originals (non-destructiv­e mode) and also apply a prefix to file names. As the names suggests, you can also mass-rotate images in the same way, just choose the appropriat­e item from the Nautilus right-click menu.

If you need more features for bulk actions, try Phatch — a photo-batch processor for Linux. Phatch can batch resize, rotate, apply shadows, perspectiv­e, rounded corners and duplicate directory hierarchie­s etc. It’s also available in many Linux distros, including Ubuntu and Fedora, so install it in a convenient way via APT, DNF or from within a graphical package manager. Keep in mind that Phatch also has a special Nautilus integratio­n extension called nautilusph­atch, which provides access to extra bulk actions from the Images context menu. In Phatch, pressing the big ‘+’ sign adds actions to the queue. The list is quite extensive and you can also put several actions in one queue in any combinatio­n. Phatch enables you to be more creative with your images and add special EXIF tags, watermarks and do image transforma­tion with a few mouse clicks. Don’t forget to put the Save action in the end of the queue in order to keep the original images safe and secure.

Importing images the right way partially solves the problem and you instantly get a well-organised directory structure. With thousands of images being collected through a period of time, you may want to do a more specific search and sort them by places, dates, people or any other criteria. There are Linux applicatio­ns that can do all of these things (and much more) by storing tags and other user-made metadata in databases. The most well-establishe­d photo organisers are Digikam and Shotwell. They are desktop heavyweigh­ts and, thus, are shipped with almost any Linux distro. Let’s move on and look at how to sort and tag images in Digikam.

When browsing your images in Digikam, select at least one of them, right-click and go to ‘Assign Tag > Add New Tag’. Enter the name of the new tag and optionally set the keyboard shortcut and that will allow you to seamlessly assign/clear that tag later on. When you’re done, your tag will appear in the Recently Assigned Tags of an image’s context menu. Sooner or later you will have many tags that need to be properly managed and reviewed. You can see the full tags tree either through context menu at ‘Assign Tag > More tags’ or by clicking on the tiny Tags button at the left-side panel in Digikam.

Initially, tags form a plain list, but they’re designed to form a hierarchy. If you select a tag and create another tag in its context menu, it will be placed inside that parent tag, so that you can create complex trees, such as ‘People > Relatives > Family > Brothers’, or, say, ‘Places > Vacation > Summer > America’. Of course, it takes some time and diligence to add tags manually, but it’s worth it. Tags add extra features to your library and simplify image searches: you can browse the convenient list of date-based subdirecto­ries with your images, but once you need to perform custom

searches (e.g. ‘show me all pictures of my dad’), tags are your best friends.

Shotwell has a very similar approach to managing tags and it also has a very useful left-side panel with events, folders and tags tree. Shotwell is also considered a lot simpler than Digikam while being more suitable for novice users. Shotwell is more user-friendly and robust while Digikam sports some cool features that others do not, such as automatic face recognitio­n and grouping photos by people.

If you shoot in the RAW format, you’ll have to process your ‘digital negatives’ with a specialise­d software, such as Darktable for Linux. However, the majority of Linux users are more worried about what to do with their ugly smartphone photos, so we’ll focus on fixing common issues of JPEGs that come out from your device already processed. Linux has a decent set of applicatio­ns that can do the job, but the most viable solution is Gimp (GNU Image Manipulati­on Program). Gimp has all we need to fix brightness, saturation, hue and sharpness of your images, so let’s load up an image in the app and roll up our sleeves:

FIXING BROKEN COLOUR LEVELS

When an image is shot against the light, the subject may appear too dark. Go to ‘Colors > Levels’ and find three handlers below the graph. The centre handle balances the darker/lighter variants of the image while the left and right handle can discard parts of the colour range. Gimp shows a live preview of what your image will look like after you apply your changes.

FIX A SKEWED HORIZON

The power of Gimp is in its tools and now it’s time for the Measure Tool. Of course, you just rotate the image by some rough degree, but it would be nice to know the exact angle, right? Select the Measure Tool and drag a line along the real horizon of the image. Take note of what has just appeared in the status area below the image. There you can see the precise angle, which you should enter in the rotating dialog.

REMOVE UNDESIRABL­E OBJECTS

One of the most valuable Gimp features is Clone Tool. Set the desired brush for it, with the correct size and smoothness, and you’re ready to remove, for instance, random people on your image’s background etc — use ‘Ctrl-click’ to select the source of cloning and then paint normally over the target area. But wait! Gimp has an even more advanced retouching brush — Healing Tool applies smarter heuristics and helps preserve texture and colour tones when cloning.

MAKE THE IMAGE SHARPER

For years, Gimp has been offering two options for sharpening images: Sharpen and Unsharp Mask. Both are found under the ‘Filters > Enhance’ menu section. They can improve blurred or slightly unfocused image, but don’t expect wonders from these tools. The good news is that you can attach the extra Refocus plugin (which you can find here: refocus.sourceforg­e.net) that uses a convolutio­n matrix to restore details that were not recognisab­le before. When installed, Refocus also resides at ‘Filters > Enhance’.

FIX WHITE BALANCE

Modern cameras use very smart algorithms for adjusting white balance, but they often fail when there’s artificial lighting or several sources of light in the scene. The common problem here is the yellowish tone of skin colour, so let’s fix it. Select the Color Picker tool and pick the most typical yellow colour that you want to remove. Create the new layer filled with that colour, then invert it (‘Colors > Invert’) to get the blueish colour and finally select Soft Light mode for the layer. You’ll notice that the yellow colour has now been subtracted from the image — you can then play with layer opacity to adjust the amount of the effect.

Filters are another way to make your photos look artistic without too much effort. This time, we quit Gimp and turn to more compact tools. The first one is Gnome Photos, which gained support for filters in 3.20. Open the photo you’d like to process in Gnome Photos and choose the Pencil button on the top-right side of its header bar to go to the editing mode. The Filters section contains a number of trendy retro filters, such as 1977, Brannan, Gotham, Hefe and Nashville — which are all simulating respective filmlike effects.

The alternativ­e way is to use XnRetro — which is a dedicated applicatio­n for applying retro-styled effects to photos. However, XnRetro isn’t open source and it comes as a single universal 32-bit tarball for all Linux distros. This means you may have to satisfy XnRetro’s missing dependenci­es manually (as well as hold your nose) but it shouldn’t be too tiresome in most cases.

The main XnRetro window has the colour adjustment side-panel on the right, but that’s not actually what we’re looking for. The real sweet features are to be found along the lower part of the window. Here, XnRetro has a list of 20 retro-filters and most of them mimic historic photo film manufactur­ers. There are other tabs here, such as Light, Vignette and Frame, and you can combine effects from different categories and create a very stylish custom filter variation for your photograph­s. Note: The Square Output option is turned on by default — as it assumes that you want to have Instagram-style square photos and crops your images upon saving.

EXPORTING IMAGES

While it’s perfectly fine to store your photo library on your hard drive, you might want to share you photos, screenshot­s, drawings or artistic collages with other people. Instead of doing everything by hand, consider using Linux applicatio­ns that have built-in capabiliti­es for publishing images. We’ll start with Online Services,

a configurat­ion module, that can be found in Gnome and Unity. It provides system-wide integratio­n with services such as Google, Flickr, Facebook, AIM and a whole lot more. Regarding image processing, we will probably want to connect to Flickr, a popular imagehosti­ng website.

Once you provide the required credential­s in the Online Accounts dialog for Flickr, you’ll be able to see your published photos with the Gnome Photos applicatio­n. To upload a new photo to Flickr, it’s more sensible to use Shotwell’s publishing feature. Select one or several images in the thumbnail view, then go to ‘File > Publish’ and select Flickr from the drop-down list. Notice that the list of available services in Shotwell’s export dialog depends on how many accounts you connect in that system-wide Online Accounts setting, and even if you add them all, the list will still be quite limited. To enjoy more options, switch to Digikam. We’ve already mentioned that Digikam may seem overwhelmi­ng for new users, but when it comes to publishing images online, Digikam shines. You just select images, open the Export menu and there are over 20 different services that Digikam has specialise­d connection plug-ins for. These include services such as Imageshack, Imgur, Flickr, Zoomr, Picasaweb, Facebook Schwup, Yandex. Fotki and SmugMug as well as different alternativ­e formats, such as Flash or local web gallery.

If you’re not fond of Digikam and don’t use Gnome or Unity either, there are several standalone tools that can be used for exporting images. First, take a look at Frogr, a Flickr uploader for Linux ( ppa:mariospr/frogr). You don’t have to use any sort of photo organisers to use Frogr, just select files from your directorie­s and you’re ready to go. For Facebook integratio­n, try Bloom, which isn’t open source but offers a free version ( antaki.ca/bloom).

As images are just a type of file, the discussion about creating a backup copy of your photo library can look like a regular review of backup tools for Linux. However, there are special points to consider that are true specifical­ly for images.

First, make sure you can do backups with software of your choice (Déjà Dup, Lucky Backup, KUP, Bacula and so on) and confirm that it’s possible to extract photos from the backup copy. Then keep in mind that almost all backup tools compress files into archives, which is good for convenienc­e, but doesn’t save any space in the case of images (e.g. JPEGs are already compressed).

If you copy your image library to an external hard drive, putting the whole directory structure into an archive (even uncompress­ed, such as TAR) is strongly recommende­d. This is because copying one large file is a lot faster for your USB media than scrabbling with thousands of small files.

Another concern that some people miss is what files should be backed up. It’s not just your ~/Pictures directory, but also settings and databases of Shotwell, Digikam or any other program you use. For instance, make sure you include the digikam4.db and thumbnails-digikam.db from your ~/Pictures directory as well a ~/.local/ share/shotwell/data/photos.db. There’s also the ~/.thumbnails directory. If you don’t want to generate these thumbnails from scratch after restoring from backup, include it in your backup copy as well.

 ??  ?? XnRetro is a wonderful all-in- one solution for applying creative and trendy effects to your photos.
XnRetro is a wonderful all-in- one solution for applying creative and trendy effects to your photos.
 ??  ?? In Digikam, you can add many tags to a single image, and later on, manipulate tags in any way.
In Digikam, you can add many tags to a single image, and later on, manipulate tags in any way.
 ??  ?? RPD is one of the best tools for transferri­ng images from your device to your Linux machine.
RPD is one of the best tools for transferri­ng images from your device to your Linux machine.
 ??  ??
 ??  ?? In this Gimp dialog, you can adjust colour levels with high precision, and even pick a white/ black/grey point to auto-fi x white balance.
In this Gimp dialog, you can adjust colour levels with high precision, and even pick a white/ black/grey point to auto-fi x white balance.
 ??  ?? Gnome — and Unity — enable you to integrate with various online services, some of which are focused on images.
Gnome — and Unity — enable you to integrate with various online services, some of which are focused on images.

Newspapers in English

Newspapers from Australia