We should note that you can do the same thing with any other “programmable” file managers, like Konqueror. The logic behind what we’re doing is this: when you have a file selected, Thunar “maps” its full pathname to a parameter – “%f”. By creating a Custom Action for Thunar, in this case, an ImageMagick command, we can make use of ImageMagick to compress and resize images directly in Thunar.

Install Thunar and ImageMagick

Use your favorite software/package management solution to find and install Thunar and ImageMagick if they aren’t already installed in your distribution. For Debian-based distributions you could do it with: Since most distributions come with some GUI application that gives access to everything in their repositories, usually presented as an “App Store,” searching through it for the programs and clicking on an “Install” button is probably the better option for people who hate the terminal.

Visit ImageMagick’s Option Summary page

Although we will only talk about scaling down and saving any selected image file as a compressed JPG, ImageMagick offers dozens of other options for altering your image files. Visit its official Options Summary page to check out everything it can do. Using those options, you can expand on what we’ll build together, either creating a more sophisticated version of our command or different commands that manipulate your images in different ways.

Create a test folder and copy some pictures there

Never act on your original files – one wrong move, and they’ll be altered or, worse, gone forever. Create a test folder somewhere – like in your Pictures folder – and copy some files there we’ll use as … well… guinea pigs! When there, right-click on the empty space of Thunar’s file list display and select terminal from the menu.

Find the optimal compression/quality ratio

The next step is to find the best compression/quality ratio for you. Each of us is different, so what looks good for us might seem too low-quality for you. It also depends on the content of your images: the kittens in our test images, and photos in general, can take larger compression/lower quality settings than sharper illustrations. Those, in turn, can be compressed more than screenshots where text must remain legible. Do some test runs until you find the optimal value for you, using the command: Where INPUT_FILE is your original image, OUTPUT_FILE the compressed and converted result, and QQ a number from 1 to 100 – the higher the number, the better the quality and lesser the compression.

Resizing or scaling down your images

Resizing and scaling down are different, as with resizing you can also scale up. ImageMagick allows you to resize your images by using the command: Here we used the 1920 x 1200 resolution. If it sounds strange, it’s because we’re using a monitor with 16:10 instead of 16:9 ratio, which would come with a more typical 1920 x 1080 resolution. Whatever number you choose, ImageMagick, by default, will keep your image file’s proportions and scale it only in one dimension to avoid distorting it. However, this will also “scale up” any smaller images, and we wouldn’t want that since our goal is to reduce our images’ sizes for online use. You can tell ImageMagick to only resize images if their larger than the selected resolution. Just add > after the entered resolution to do so.

Add the command to Thunar

When you’ve found the desired compression/quality ratio and set your target resolution to downscale, copy the command from your terminal to the clipboard. Then, from Thunar, select “Edit > Configure custom actions …” Enter a name for your action and, if you want, a description. Then, paste the copied ImageMagick command into the Command field. Select the input filename in the command and change it to “%f,” then select the output filename and change it to “%f_output.” The command won’t work if you don’t set a condition for its appearance. Move to the Appearance Conditions tab and select “Image Files” so that our command will appear whenever any image files are selected. Click OK and your custom action will be saved for future use.

Try your custom action

The custom action will appear whenever you right-click on an image file. By selecting it, a new, compressed and scaled-down file will appear in the same folder with “_output” after its name. Unfortunately, Thunar isn’t versatile enough to only parse the “basename” to ImageMagick (“to remove the extension”), so we have to do it manually. There are ways to avoid that, but we’d have to create more complex scripts. However, that’s a story for another time. Until then, why not create some more alternative takes on your command, with different compression levels or resolution targets for your every need? They’ll only be a right-click away!