Fast image processing with ExactImage
Less is More
Automate image processing with this quick and easy-to-use photo tool suite.
Anyone processing images automatically in batch mode needs lean, easy-to-use tools. The program of choice is usually convert
from the ImageMagick suite [1]; however, this program has some drawbacks. In particular, convert
does not necessarily impress with its stability. This is not typically a major issue, but in case of complex command lines, you might see the program calls abort with a (mostly incomprehensible) error message and produce incorrect results, or even none at all.
In fact, even composing a command line for convert
proves to be a task that should not be underestimated: The program supports no fewer than 300 different options that often exhibit strange syntax. Many options serve very specific tasks and require experience and a great deal of background knowledge on the part of the user – for example, do you know offhand what calling convert
… -resize 200\>x300^
… would give you?
Many users also complain about the lack of effectiveness of the ImageMagick tools. The programs are not especially quick, nor do they deliver particularly brilliant results – in part because of the massive functional diversity, which is often not needed.
The GraphicsMagick [2] suite is an attempt to resolve these issues; another competitor goes by the name of ExactImage [3]. Both provide only a subset of ImageMagick's repertoire and restrict their feature set to the most important functions.
What differences exist between the three suites? Although ImageMagick comes with almost 20 different programs, GraphicsMagick is a single program – along with three configuration tools; ExactImage provides seven tools (Table 1).
Table 1
ExactImage Programs*
Program | Function |
---|---|
|
Reads barcodes |
|
Groups multiple images as a multipage TIFF |
|
Universal converter; counterpart to |
|
Identifies image files; counterpart to |
|
Detects images of empty pages |
|
Uses hOCR files to generate searchable PDFs |
|
Optimizes image files for archiving |
*Additionally, |
Although GraphicsMagick tries to cover most of ImageMagick's functions, the tiny ExactImage suite delivers only one universal tool (econvert
, as a counterpart to convert
), as well as some programs for very specific tasks, such as reading barcodes and detecting blank pages.
And, Action!
Like convert
from the ImageMagick tools, econvert
is the main tool when it comes to creating new images from existing ones. The syntax follows the structure:
$ econvert -i <input file> -<option> ... -o <output file>
The main thing here is to pay attention to the correct order of the individual components; otherwise, econvert
(just like convert
) might ignore the specified options. Starting with a single input file, you can use multiple switches -<option>
-o <output file>
to create as many output files as you like on a single command line.
The way the ExactImage tools work is completely controlled by various options, just like ImageMagick (Table 2). ExactImage supports only a subset of the available image formats, and they differ in terms of input and output (Table 3). That said, ExactImage does support the main image formats to a large extent.
Table 2
Important Options
Option | Function |
---|---|
|
Compression method for output, say, |
|
Defines the quality as a percentage, default: 75 |
|
Resolution in X and Y direction |
|
Defines the width and height of the output file for raw image formats |
|
Scales by the stated factor |
|
Crops the image to the specified section |
|
Automatic cropping (from the bottom edge) |
|
Mirrors vertically |
|
Mirrors horizontally |
|
Rotates the image through the stated angle |
|
Adjusts the brightness (-1 to +1) |
|
Adjusts the contrast (-1 to +1) |
|
Adjusts the saturation (-1 to +1) |
|
Adjusts the lightness (-1 to +1) |
|
Adjusts the hue (-360 to +360) |
|
Creates a negative |
|
Adjusts the gamma |
|
"Normalizes" the colors in the image |
|
Converts images to one of the color models |
|
Generates shade as per Floyd-Steinberg |
|
Generates shade as per Riemersma |
|
Gaussian blur |
|
Finds edges |
|
Sets the drawing color |
|
Sets the background color |
|
Sets the font |
|
Outputs the text at the specified position at the specified size |
|
Rotates texts |
|
Line thickness |
|
Draw line between specified points |
Table 3
Image Formats
Abbreviation | Image Format |
---|---|
BMP |
Windows primitive bitmap format |
Digital Camera RAW |
Raw data formats supported by DCRAW |
Encapsulated PostScript |
Single-sided PostScript |
GIF |
The legacy bitmap format |
JPEG |
Classic JPEG |
JPEG2000 |
The new JPEG variant |
OpenEXR |
HDR bitmap format with up to 32-bit floats per channel |
PBM |
Portable bitmap format |
PCX |
Picture Exchange, widespread exchange format |
|
Write-only, with embedded JPEG and JPEG2000 and fonts |
PNG |
Standard bitmap format |
PostScript |
Write-only, with embedded JPEG |
RAW |
Raw image files |
SVG |
Scalable vector graphics, read-only |
Targa, TGA |
Truevision Advanced Raster Graphics Array, up to 32 bits per channel |
TIFF |
The classic standard |
XPM |
X Window bitmaps (mainly for icons) |
When scaling with --scale
, the algorithm automatically determines which method to use. If you are not satisfied with the results it delivers, you can set the method yourself. The options in this case are:
--bicubic-scale
--bilinear-scale
--box-scale
--ddt-scale
--nearest-scale
Moreover, the --thumbnail
fast filter generates thumbnails.
The example in Listing 1 once again illustrates the use of econvert
. It produces three different output files from one input file.
Listing 1
Using econvert
Who Are You?
The second important program from the ExactImage suite is edentify
, which is used to identify the format of an image. The example shown in Listing 2 is deliberately difficult: Identifying raw data formats is already a challenging task, and this is again aggravated by the DNG created by the conversion. Listing 3 shows the way ImageMagick handles this job with identify
.
Listing 2
Using edentify
Listing 3
Using identify
Although edentify
provides reasonably correct information and does not even try to guess file sizes, it outputs many error messages. ImageMagick's identify
takes a different approach. First, it converts the raw data to a bitmap format, which it then analyzes.
Whether this approach makes sense is doubtful. The file sizes specified by identify
are totally wrong because they relate to the bitmap files generated by the conversion, rather than the originals. Evaluating a DNG as a TIFF can be seen as reasonably correct, because DNG was designed as an extension of the TIFF standard.
The ability to display specific information about images with edentify
is interesting. This is achieved by specifying a "format string" as an argument for the -f
option. For example, -f "%f"
gives you the file name, -f "%w"
the width, and so on. Table 4 summarizes the most important variants. To connect several strings, you can use \t
(tabulator), \n
(newline) or \r
(carriage return).
Table 4
Format Strings
Abbreviation | Meaning |
---|---|
|
Directory |
|
Full file name |
|
File name without extension |
|
Path |
|
Width |
|
Height |
|
Color depth per channel |
|
X resolution |
|
Y resolution |
|
Image depth |
All told, edentify
offers only limited features; again, you might need to resort to ImageMagick's identify
.
Utilities
The other programs from the ExactImage suite are more specialized. For example, bardecode
automatically evaluates scanned bar codes; this still works even with relatively poor images. The e2mtiff
tool merges multiple images into a multipage TIFF file:
$ e2mtiff x1.jpg x2.png ... -o <out>.tiff
Multipage TIFFs are not particularly widespread nor particularly popular on Linux. However, Gimp can open and edit them. Figure 1 shows what a multipage TIFF looks like in Gimp when you load it. You can now individually edit the pages, which exist as layers (Figure 2), or convert them to new images by dragging them over the toolbox with the mouse.
The optimize2bw
program prepares scanned pages to improve their suitability for subsequent processing with OCR. The empty-page
program detects blank pages, so you can discard them up front. Finally, hocr2pdf
is the probably the most-used tool in the ExactImage program suite.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Fedora 40 Beta Released Soon
With the official release of Fedora 40 coming in April, it's almost time to download the beta and see what's new.
-
New Pentesting Distribution to Compete with Kali Linux
SnoopGod is now available for your testing needs
-
Juno Computers Launches Another Linux Laptop
If you're looking for a powerhouse laptop that runs Ubuntu, the Juno Computers Neptune 17 v6 should be on your radar.
-
ZorinOS 17.1 Released, Includes Improved Windows App Support
If you need or desire to run Windows applications on Linux, there's one distribution intent on making that easier for you and its new release further improves that feature.
-
Linux Market Share Surpasses 4% for the First Time
Look out Windows and macOS, Linux is on the rise and has even topped ChromeOS to become the fourth most widely used OS around the globe.
-
KDE’s Plasma 6 Officially Available
KDE’s Plasma 6.0 "Megarelease" has happened, and it's brimming with new features, polish, and performance.
-
Latest Version of Tails Unleashed
Tails 6.0 is based on Debian 12 and includes GNOME 43.
-
KDE Announces New Slimbook V with Plenty of Power and KDE’s Plasma 6
If you're a fan of KDE Plasma, you'll be thrilled to hear they've announced a new Slimbook with an AMD CPU and the latest version of KDE Plasma desktop.
-
Monthly Sponsorship Includes Early Access to elementary OS 8
If you want to get a glimpse of what's in the pipeline for elementary OS 8, just set up a monthly sponsorship to help fund its continued existence.
-
DebConf24 to be Held in South Korea
Busan will be the location of the latest DebConf running July 28 through August 4