It is currently Thu Jul 04, 2024 3:50 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Is it possible to make a plugin that runs bash scripts on a clipboard
PostPosted: Sat Mar 04, 2023 5:48 pm  (#1) 
Offline
GimpChat Member
User avatar

Joined: Oct 31, 2020
Posts: 1456
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






Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: Is it possible to make a plugin that runs bash scripts on a clipbo
PostPosted: Sun Mar 05, 2023 2:16 am  (#2) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4756
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?

_________________
Image


Top
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) GEGL calls GMIC, REMBG, AIs or any bash string with our bash plugin

87

No new posts How to make G'MIC runs faster?

6

No new posts Attachment(s) Commands to make scripts fwd & bwd compatible

10

No new posts Attachment(s) Baby's first GEGL plugin - a very basic GEGL plugin anyone can make.

9

No new posts Attachment(s) Create a 'clipboard' brush & mandala with Symmetry Painting

25



* Login  



Powered by phpBB3 © phpBB Group