One thing that has been bugging me for a while is how to better automate PDF generation from camera images that first need to be ‘exif orientation info cleaned‘, rotated, and shrunken. There are great tools and command line options available for each individual task but nothing really useful for GUI users to combine them into a single action. So I set out to build a GUI tool for Linux myself for the purpose.
As we usually handle images from cameras in the Linux / Gnome / Nautilus file manager, the best way to simplify and combine these actions would be to integrate them into the file manager. And fortunately, Nautilus has a number of ways to write extensions for it, e.g. via shell scripts or a Python API. So I chose the Python API and wrote an extension that adds a menu item in the right-click context menu when used on a directory. When the menu item is selected, a dialog box opens and one can select which actions to perform on all images in the directory. Some sensible options are pre-selected.
The current version of the plug-in uses a number of shell commands to get the job done. Some of these could also be done with native Python libraries but there is one catch: Even in Ubuntu 20.04, Nautilus still uses Python 2.7 for executing Python extensions. As Python 2.7 is deprecated and no longer maintained now, Ubuntu 20.04 doesn’t include pip for Python 2 to install additional packages. One could of course force that into the OS but there is a good reason why it was removed. However, the core of Python 2.7 is still used in many places in Ubuntu 20.04, so that functionality is still there. As a consequence I’ve decided to call shell commands instead of going the native Python way. The irony: Some of these shell commands are written in Python 3. In other words, Nautilus calls a Python 2.7 extension that calls the shell that invokes Python 3 code. Mind boggling.
There doesn’t seem to be a central directory for Nautilus extensions so the best I can do is to link to the source that I have put on Gitlab from here and hope people who are interested will find it via a web search. Enjoy!