Skip to content

Instantly share code, notes, and snippets.

@Christopher-Hayes
Last active October 23, 2022 10:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Christopher-Hayes/fd1be7ee982726845e7d76f106d0cda8 to your computer and use it in GitHub Desktop.
Save Christopher-Hayes/fd1be7ee982726845e7d76f106d0cda8 to your computer and use it in GitHub Desktop.
GThumb Scripts

GThumb Scripts

I love GThumb, listed here are a couple scripts I use with GThumb.

### Copy Stable Diffusion image prompt to clipboard
# The "Parameters" EXIF tag is based on Automatic1111's web UI
# Note that this script just copies the prompt, not the whole config.
# The whole config can be copied by replacing the last "paramStr" with "exifStr"
# Dependencies:
# exiftool: sudo apt install exiftool
exifStr=$(exiftool -Parameters %F) && paramStr=$(echo "$exifStr" | sed -n 's/.*:\ \(.*\)Negative prompt.*/\1/p') && echo "$paramStr" | xclip -selection clipboard
### Remove image background
# This creates a new image with the background removed. The new file will have a "-nobg" appended to the filename.
# Dependencies
# rembg: https://github.com/danielgatis/rembg
# rembg is installed with PIP. Mine is in a conda env, GThumb was throwing an error unless I gave it the full path
# if rembg doesn't work by itself doesn't work, run `whereis rembg` in the CLI to get its path.
/home/chris/anaconda3/bin/rembg i %F %Q{ %P/%N-nobg%E }
### View (all) EXIF data
# GThumb natively supports showing EXIF data; however, it struggles with non-standard EXIF data.
# This script uses "exiftool" to show all EXIF data in a YAD popup window.
# Dependencies:
# yad: sudo apt install yad
# exiftool: sudo apt install exiftool
exiftool %F | yad --text-info --title="exiftool: %B" --fontname="Monospace 10" --width=600 --height=800
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment