GIMP Chat
http://gimpchat.com/

Is it possible to make a plugin that runs bash scripts on a clipboard
http://gimpchat.com/viewtopic.php?f=9&t=20309
Page 1 of 1

Author:  contrast_ [ Sat Mar 04, 2023 5:48 pm ]
Post subject:  Is it possible to make a plugin that runs bash scripts on a clipboard

If I could export clipboard data and run bash scripts I could get two image restoration tools (REAL-ESRGAN and GPFGAN) to work in Gimp. I have scripts that run said image restoration GANS and open their modified image in my image viewer and or Gimp. The problem is I don't know if there is a way to run them in Gimp on by exporting a composition as a png.


I guess the script would export a composition in a folder, run the gans and reopen the new image in Gimp.

Does anyone want to help me with this?

Here is the script on my own computer that runs REALESRGAN on an image then opens the modified image in Gimp. It will not work on any other computer in the world except mine as it expects unique directories.
#!/bin/bash

source ~/Applications/mc/etc/profile.d/conda.sh && conda activate base && /home/contrast/Applications/Real-ESRGAN-master/realesrgan-ncnn-vulkan -i "$@" -o /home/contrast/Pictures/REAL_ESRGAN/output.png -n realesrgan-x4plus s= 2  && sleep 9 && cd /home/contrast/Pictures/REAL_ESRGAN/
dirname=`ls -t | head -1`
flatpak run --branch=stable org.gimp.GIMP $dirname





Author:  ofnuts [ Sun Mar 05, 2023 2:16 am ]
Post subject:  Re: Is it possible to make a plugin that runs bash scripts on a clipbo

Why the clipboard? It is easy to export a layer to file (if all you have is a selection, copy it to a new layer first).

You can avoid unreadable one-liners by using "set -o errexit"

set -o errexit
source ~/Applications/mc/etc/profile.d/conda.sh
conda activate base && /home/contrast/Applications/Real-ESRGAN-master/realesrgan-ncnn-vulkan -i "$@" -o /home/contrast/Pictures/REAL_ESRGAN/output.png -n realesrgan-x4plus s= 2
sleep 9
cd /home/contrast/Pictures/REAL_ESRGAN/
dirname=`ls -t | head -1`
flatpak run --branch=stable org.gimp.GIMP $dirname


In modern bash, the backticks are pretty much a thing of the past (possibly because they are not always easy to distinguish from the single quotes). The preferred notation is "$()": "dirname=$(ls -t | head -1)"

The explicit "sleep" in the code has all kinds of bad vibes. What is the purpose?

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/