Scribbles and Snaps

Compare Photos with ImageMagick and a KDE Service Menu Action

Need to compare two photos side-by-side? Using the convert tool, you can quickly stitch two or more photos together and compare the result in any image viewer:

convert photo1.jpg photo2.jpg +append compare.jpg

The example command above stitches photo1.jpg and photo2.jpg from left to right (i.e. photo1.jpg + photo2.jpg), but you can use -append instead of +append to reverse the order (i.e. photo2.jpg + photo1.jpg). In both cases, the stitched image is saved under the compare.jpg name.

If you use KDE as your preferred graphical desktop environment, you can create a context action to stitch file pairs in the Dolphin file manager. Create a text file and paste the following code into it:

[Desktop Entry]
Type=Service
ServiceTypes=KonqPopupMenu/Plugin
MimeType=image/JPG;image/JPEG;image/jpeg;image/JPG;image/jpg;
Actions=Compare
[Desktop Action Compare]
Name=Compare Photos
Exec=convert %F +append compare.jpg
Icon=image-x-applix-graphics

Save the file under the compare.desktop name and move it to /usr/share/kservices5/ServiceMenus:

sudo cp compare.desktop /usr/share/kservices5/ServiceMenus/

Open Dolphin, select a pair of JPEG files you want to compare, right-click on the selection, and choose the Actions → Compare Photos action to resize the image. This generates a compare.jpg file with the selected photos side by side. You can then use your preferred image viewer to examine the photos.

This is an excerpt from the Linux Photography book. Get your copy here.