Switch to full style
Post all Gimp scripts and script writing questions here
Post a reply

Re: GEGL calls GMIC, REMBG, AIs or any bash string with our bash plugi

Sun Dec 10, 2023 5:17 pm

I know but that website doesn't run through a cli via bash

Re: GEGL calls GMIC, REMBG, AIs or any bash string with our bash plugi

Sun Dec 10, 2023 9:20 pm

I wrote new syntax that blurs the background after running REMBG.

It requires these two plugins of mine to work ideally. This only takes a few seconds on my machine.

https://github.com/LinuxBeaver/Threshol ... /releases/
https://github.com/LinuxBeaver/Gimp-Plu ... -/releases
(chrome text ships with edge smooth that it requires)

rembg_and_bg_blur.png
rembg_and_bg_blur.png (910.26 KiB) Viewed 41910 times


amazing_gegl_fun.png
amazing_gegl_fun.png (757.53 KiB) Viewed 41910 times



Bash Code

Code:
rembg i /tmp/in.png /tmp/out.png



GEGL Code
Code:

      id=all
src aux=[ ref=all

lb:threshold-alpha alphadegree=1
id=1 gimp:layer-mode layer-mode=normal opacity=0.7 aux=[ ref=1]

lb:edgesmooth alpha-percentile2=80

id=2 dst aux=[ ref=2 id=erase ]

id=3 dst-over aux=[ layer src=/tmp/in.png xor aux=[ ref=erase ] id=background_gap ]

xor aux=[ layer src=/tmp/out.png ]



gaussian-blur std-dev-x=30 std-dev-y=30

crop
median-blur radius=10 alpha-percentile=100
gimp:threshold-alpha value=0.4 lb:edgesmooth

bloom strength=9
]


over aux=[ layer src=/tmp/out.png
lb:threshold-alpha alphadegree=1 id=rembgremove gimp:layer-mode layer-mode=normal opacity=0.5 aux=[ ref=rembgremove] lb:edgesmooth alpha-percentile2=80
dropshadow grow-radius=10 radius=14 x=33 opacity value=1 ]

Re: GEGL calls GMIC, REMBG, AIs or any bash string with our bash plugi

Sun Dec 10, 2023 9:30 pm

Stat regarding a hopeful Windows version


I tested this plugin on Windows and it appears to by default trying to communicate with cmd.exe and not powershell. cmd.exe was rapidly opening and closing. When I typed in powershell --command it froze Gimp indefinitely and an error window popped up about reporting it. We are going to see if we can get a separate Windows version of this plug-in now that we know it at least tries to talk to Windows.

This will be the first GEGL plugin of mine that has two special versions for both Windows and Linux. In every other case what works on Windows works on Linux.

Re: GEGL calls GMIC, REMBG, AIs or any bash string with our bash plugi

Mon Dec 11, 2023 2:08 am

This instructs GEGL to remove a background with REMBG and fix rembg erosion, then blend the fish with the hard light blend mode on saturation followed up by a blue outline.

This requires these two plugins to work

https://github.com/LinuxBeaver/Threshol ... n/releases
https://github.com/LinuxBeaver/GEGL---C ... r/releases


fish_select.png
fish_select.png (483.92 KiB) Viewed 41802 times


Bash Command
Code:
rembg i /tmp/in.png /tmp/out.png


GEGL Syntax (requires two of my plugins)

Code:
lb:threshold-alpha alphadegree=1 id=rembgremove gimp:layer-mode layer-mode=normal opacity=0.5 aux=[ ref=rembgremove] lb:edgesmooth alpha-percentile2=80 ]
saturation scale=1.4
id=2 hard-light aux=[  ref=2 opacity value=0.4 saturation scale=1.6 ]
hue-chroma lightness=1
dropshadow x=0 y=0 radius=0 opacity=2 grow-radius=4  color=#00f4ff
median-blur radius=0
dropshadow x=9 y=0 opacity=0.9

Re: GEGL calls GMIC, REMBG, AIs or any bash string with our bash plugi

Mon Dec 11, 2023 4:08 pm

REAL ESRGAN AND IMAGE MAGICK CALLED FROM BASH IN GEGL
Image Magick was called to scale down RealESRGAN 4x to 25% of its original size
so it would fit the original image in Gimp's canvas. I used Lancoz interpolation which is the best Image Magick has.


real_esrgan.png
real_esrgan.png (351.41 KiB) Viewed 41748 times



The original string only works on my computer but I made a modified version that may work on other machines that have REALESRGAN and ImageMagick installed in generic directories.

Bash Command

Code:
realesrgan-ncnn-vulkan -i /tmp/in.png -o /tmp/out3.webp -n realesrgan-x4plus s= 2 && magick /tmp/out3.webp  -filter Lanczos -resize 25% /tmp/out4.webp && gmic /tmp/out4.webp output /tmp/out.png


GEGL Syntax
NA - this stays empty unless you want to put something

I also tested running REALESRGAN, GFPGAN and REMBG at at once and it worked but took over 25 seconds. It probably would have took 30 minutes a few days ago before the update.

Re: GEGL calls GMIC, REMBG, AIs or any bash string with our bash plugi

Mon Dec 11, 2023 5:19 pm

Here's GEGL calling an image magick filter followed by GEGL's Sharpen. This loads instantly because it is just a simple lighting filter


image_magick_instant.png
image_magick_instant.png (580.73 KiB) Viewed 41741 times


Bash Command
Code:
magick /tmp/in.png +level-colors red, /tmp/out.png


GEGL Command
Code:
  unsharp-mask scale=2



Learn how to write image magick syntax here
https://imagemagick.org/script/command-line-options.php

Learn how to write GEGL syntax here
gegl.org/

Re: GEGL calls GMIC, REMBG, AIs or any bash string with our bash plugi

Mon Dec 11, 2023 7:58 pm

UPDATE, THIS CODE REQUIRES GEGL'S BLENDING OPTION TO BE SET TO NORMAL, as opposed to the default replace.


Here is an example of me using the system's GEGL + REMBG then Gimp's GEGL to recolor an object inside the image.

The car goes from Yellow to Aqua Blue.

recolor_car_aqua_blue.png
recolor_car_aqua_blue.png (898.69 KiB) Viewed 41729 times


Command for Bash box
Code:
gegl i /tmp/in.png /tmp/outgegl.png -- gegl:gegl string=' hue-chroma hue=134 saturation scale=0.8 levels out-high=0.9 unsharp-mask scale=0.8  ' && rembg /tmp/outgegl.png -o /tmp/out.png



Command for GEGL box
Code:

lb:threshold-alpha alphadegree=1
id=1 gimp:layer-mode layer-mode=normal opacity=0.2 aux=[ ref=1]

Re: GEGL calls GMIC, REMBG, AIs or any bash string with our bash plugi

Mon Dec 11, 2023 9:28 pm

UPDATE, THIS CODE REQUIRES GEGL'S BLENDING OPTION TO BE SET TO NORMAL, as opposed to the default replace.

Recolor an
object study 2. Make the duck blue.

blue_duck.png
blue_duck.png (1 MiB) Viewed 41726 times



Or saturate and color adjust the duck (more realistic)

duck_saturate.png
duck_saturate.png (929.64 KiB) Viewed 41726 times



COMMAND FOR BASH BOX


Code:
rembg i /tmp/in.png /tmp/out.png


COMMAND FOR GEGL BOX (Requires my plugins chrome and Threshold alpha 2)
Code:
lb:threshold-alpha alphadegree=1
id=1 gimp:layer-mode layer-mode=normal opacity=0.2 aux=[ ref=1]
unsharp-mask scale=0.3
saturation scale=1.6
levels out-low=0.004
hue-chroma lightness=1
bloom strength=4

Re: GEGL calls GMIC, REMBG, AIs or any bash string with our bash plugi

Tue Dec 12, 2023 7:13 am

REMBG AND BASH BOX IN MY GEGL EFFECTS PLUGIN

I got bash box working in an unreleased version of my layer effects engine. GEGL Effects is applying effects after REMBG, but it can also do any other bash string.


Here is the download to my GEGL Effects layer effects engine that does NOT include this update. But soon it will!
https://github.com/LinuxBeaver/GEGL-Eff ... L/releases



Now that we know GEGL is capable of doing all this, its safe to say Gimp's future is secured.

Re: GEGL calls GMIC, REMBG, AIs or any bash string with our bash plugi

Tue Dec 12, 2023 7:32 am

It is so exciting to see REMBG inside an unreleased version of GEGL Effects! Its amazing how these workflows are being automated.

rembg_in_gegl_effects.png
rembg_in_gegl_effects.png (611.98 KiB) Viewed 41672 times

Re: GEGL calls GMIC, REMBG, AIs or any bash string with our bash plugi

Tue Dec 12, 2023 4:56 pm

AI IN GEGL EFFECTS

It is working consistent and stable in GEGL Effects. I will push the GEGL Effects December 12 update soon and now everyone gets to see my special Linux Desktop that looks like Windows XP, lol.

AI_in_gegl_effects.png
AI_in_gegl_effects.png (1.09 MiB) Viewed 44846 times


AI_effects_2.png
AI_effects_2.png (1.04 MiB) Viewed 44846 times

Re: GEGL calls GMIC, REMBG, AIs or any bash string with our bash plugi

Tue Dec 12, 2023 8:06 pm

Download for the GEGL Effects update with Bash to call AI is here. But it is Linux only and doesn't work on Flatpak





Location to put binaries (there's a lot of them)
Code:
/home/(USERNAME)/.local/share/gegl-0.4/plug-ins


Then Restart Gimp go to GEGL Operations and look for GEGL Effects Continual Edition. Remember, GEGL Effects is both an image outline tool and a text styling engine but in the case of this I am using it for image outlining. If you already have these binaries overwrite all of them with the latest version.

Remember you need to have the AI installed and remember to check and uncheck the bash checkbox to run the bash command.




GEGL_Effects_AI_ready.png
GEGL_Effects_AI_ready.png (1.06 MiB) Viewed 18243 times



Don't bother compiling on windows it won't work there. we tried.

Re: GEGL calls GMIC, REMBG, AIs or any bash string with our bash plugi

Tue Dec 12, 2023 8:10 pm

When will a windows version be available?

Re: GEGL calls GMIC, REMBG, AIs or any bash string with our bash plugi

Tue Dec 12, 2023 8:30 pm

This only took a few seconds.

split_view_effects.png
split_view_effects.png (636.26 KiB) Viewed 18241 times


AI_power_gegl_effects.png
AI_power_gegl_effects.png (511.1 KiB) Viewed 18241 times


and it can save and apply the same setting on anything else.

But it looks like in this case the inner glow is to expansive on the turtle, so users will have to change the original setting.

preset_gegl.png
preset_gegl.png (686.5 KiB) Viewed 18241 times

Re: GEGL calls GMIC, REMBG, AIs or any bash string with our bash plugi

Tue Dec 12, 2023 8:31 pm

mackenzieh wrote:When will a windows version be available?


If I get a professional to help me call Windows PowerShell. I don't know how to do this, but I guess Liam could try. I am sorry and understand that you want this on Windows.

Re: GEGL calls GMIC, REMBG, AIs or any bash string with our bash plugi

Wed Dec 13, 2023 1:03 am

The plan now is to get a Windows version using Windows SubSystem for Linux instead of powershell as that can use bash.

Re: GEGL calls GMIC, REMBG, AIs or any bash string with our bash plugi

Wed Dec 13, 2023 6:33 pm

This should be obvious to point out that commands that work on one image.
funs.png
funs.png (896.81 KiB) Viewed 18196 times


final_love.png
final_love.png (405.08 KiB) Viewed 18196 times



Do not always turn out proper on another image.
bash_turtle.png
bash_turtle.png (952.51 KiB) Viewed 18196 times


Lastly, every time a GEGL preset is made the user still has to manually check and uncheck the bash checkbox in tab 9 and we already discussed way earlier in this thread how it loads the previous image file.

Re: GEGL calls GMIC, REMBG, AIs or any bash string with our bash plugi

Sat Dec 16, 2023 2:42 am

This is now on Github. The same download on Github is also on GimpChat


https://github.com/LinuxBeaver/AI_in_Gi ... /tree/main

Re: GEGL calls GMIC, REMBG, AIs or any bash string with our bash plugi

Sat Dec 30, 2023 5:32 pm

This bash plugin was not working for a lot of people because the REMBG command changed recently or at least in the past year. months. Here is a list of both rembg commands.

Latest REMBG is
Code:
rembg i /tmp/in.png /tmp/out.png


2022 REMBG is
Code:
rembg /tmp/in.png -o /tmp/out.png



The bash plugin both stand alone and GEGL Effects version updated today. To contain the newest line of code for REMBG in default. This does not count as a new version release.

Re: GEGL calls GMIC, REMBG, AIs or any bash string with our bash plugi

Sun Dec 31, 2023 4:34 am

We got the plugin working on Flatpak Linux
Image

It requires a special build of the source code linked here that you must manually edit and compile, as well as a package called flatpak-spawn (that you don't need to compile). This code now also contains the GEGL Effects bash build added mid day (dec 31st 2023)
bash_flatpak_requires_code_editing.zip
(316.34 KiB) Downloaded 117 times


If you want Flatpak bash to work for you have to compile and replace "/home/contrast/tmp/" with your username and directory of choice. This is only for flatpak. Non flatpak users don't have to do this. The reason why is because flatpak can't use the /tmp/ directory.

First install flatpak-spawn
Code:
sudo dnf install flatpak-spawn


Code:
sudo apt install flatpak-spawn


Then download this code and open bash-buddy.c and gegleffectspending.c


then replace /home/contrast/tmp/in.png and /home/contrast/tmp/out.png with whatever directory in your own home you like such as this example. /home/john/eggs/in.png /home/john/eggs/out.png

Image shows this "search and replace" process.
this_is_the_way_to_do_it.png
this_is_the_way_to_do_it.png (4.94 KiB) Viewed 14561 times


then compile by running build_linux.sh and put the file in /home/(USERNAME)/.var/app/org.gimp.GIMP/data/gegl-0.4/plug-ins
and restart Gimp and go to GEGL operations.

then if that is the case a command like
Code:
flatpak-spawn --host rembg i /home/john/eggs/in.png /home/john/eggs/out.png
will work. Consider making the directory short as possible. It CANNOT use /tmp/

Lastly if you only want the bash AI plugin without GEGL Effects. Ignore all binaries but bash-buddy and spawn if you want GEGL Effects make use of all the binaries.
Post a reply