Thunar, Create XCF Thumbnail for GIMP
Thunar Custom Action for GIMP XCF files.
Basic Tab
Name: Create XCF Thumbnail
Description: Generate a thumbnail for XCF files
Command: bash ~/bin/generate_xcf_thumbnail %F
Appearance Conditions Tab
File Pattern: *.xcf
Appears if selection contains: Image Files
To add a custom action open Thunar file manager from the menu select Edit -> Configure custom actions…
The Bash Script
#!/bin/bash
#
# Requires gimp, imagemagick.
#
# Example usage: bash ~/bin/generate_xcf_thumbnail file.xcf
#
# Thunar Action Setup
#
# Name: Create XCF Thumbnail
# Description: Generate a thumbnail for XCF files
# Command: bash ~/bin/generate_xcf_thumbnail %F
# Appearance Conditions
# File Pattern: *.xcf
# Appears if selection contains: Image Files
# Process each file passed as argument
for xcf_file in "$@"; do
# Ensure the file has a .xcf extension
if [[ "$xcf_file" == *.xcf ]]; then
# Use GIMP to export the XCF to JPG in non-interactive mode
gimp -i -b "(let* ((image (car (gimp-file-load RUN-NONINTERACTIVE \"$xcf_file\" \"$xcf_file\"))) \
(drawable (car (gimp-image-get-active-layer image)))) \
(gimp-file-save RUN-NONINTERACTIVE image drawable \"${xcf_file%.xcf}.jpg\" \"${xcf_file%.xcf}.jpg\") \
(gimp-image-delete image))" -b "(gimp-quit 0)"
# Resize the exported image to 256x256 using ImageMagick
if convert "${xcf_file%.xcf}.jpg" -resize 256x256 "${xcf_file%.xcf}.jpg"; then
notify-send "Thumbnail created for $xcf_file"
else
notify-send "Failed to create thumbnail for $xcf_file"
fi
else
echo "Skipping invalid XCF file: $xcf_file"
fi
done
The examples on this page use the bin directory within the user’s Home directory. Home -> User -> bin. Place the script in the bin folder.
Description
I have been using Linux and GIMP for decades, and I have never looked back. One minor issue I’ve noticed, which has persisted for a long time, is the problem with GIMP’s XCF files and their thumbnails. For some reason, they either never work or work randomly in various file managers. I would love to contribute to resolving this issue, but at the moment, I don’t know enough about it to start working on a solution. It could potentially take a long time to research and contribute in any meaningful way.
That’s where this workaround comes in as an immediate solution for me. It’s a robust approach, as I don’t ever recall having issues with JPEG thumbnails. The Thunar action paired with the script allows for a right-click option to “Create XCF Thumbnail.” A single XCF file or multiple can be selected. This simply creates a small JPEG version of the XCF with the same name. These images don’t take up much space and work well. There might be the occasional file with a hidden layer or other minor issue, but it’s usually enough to quickly see what the file is about. The script also has some information on adding to Thunar.
This is exactly what makes Linux and open-source software so great: the flexibility in workflow is indispensable. With open-source tools, you’re not locked into a rigid system. You can customise your environment, automate repetitive tasks, and create solutions tailored to your specific needs. Whether it’s tweaking scripts, modifying software behavior, or integrating different programs, the freedom to adapt your workflow is a powerful advantage that proprietary systems often lack. This adaptability is a key reason why Linux and open-source software continue to thrive in both personal and professional environments.
More on bash automation and graphic design. Watermark Images Thunar Action.