Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Open a file in Gimp from the command line
#1
Hi,

I'd like to open a file in Gimp as part of a shell script on OS X Sierra (I use the Partha Bagchi build).

If Gimp is not launched, it works perfectly with the following command:

open McGimp-2.10.8.app --args ~/Documents/Archive/scanpic.jpg

But I don't know how to open a file with the script when Gimp is already launched. In this case, Gimp comes to the forefront but the file is not opened.

Any idea how to achieve that?

dw
Reply
#2
Gimp should come to the forefront but with the image. You can anyway force Gimp to start a new independent Gimp instance using the -n (or --new-instance parameter) to make it use a new instance.

I can only recommend you to check the docs (or just gimp --help...) for other parameters that are useful when running in batch (-i, -v, -d...).
Reply
#3
A few try-outs but no success from a batch file.

As Ofnuts points out the commands are

-n, --new-instance
Start a new GIMP instance.

-a, --as-new
Open images as new.

In linux from a terminal or a bash file gimp path-to-/file.ext will start Gimp and open the image.

From a terminal gimp --as-new path-to-/another_file.ext opens another_file in the same Gimp. Both files are open.

This is not working from a bash script. The first command opens Gimp with the file. Then nothing happens until closing Gimp, then the second command starts. Tried some options starting separate executable bash files from a main bash file. Still no good. I know it is the way bash spawns the processes but can not find a way around it. Ofnuts will know Smile
Reply
#4
Thanks Ofnuts and Rich2005 for your help!
I think I found a path to the solution but I have still a last mile to walk.

With this alternative command, I can open a new instance of Gimp if needed or stay in the opened instance:

open ~/Documents/Archive/scanpic1.jpg -a gimp <-- launch a new gimp and open the file

open ~/Documents/Archive/scanpic2.jpg -a gimp <-- open the second file in the existing gimp

There is still a bit of work that I have to do. Gimp looks like a symlink to the "old" 2.8 that's still on my system. I have to check if its really the case and then link the word "gimp" to the 2.10.8 build that I'm using since I discovered Partha Bagchi's build by reading posts in this forum! And of course I also need to check if I can integrate this in my script.

dw

Edit: it works in the script (with 2.8 for now) but I can't find how to link mcgim 2.10.8 to the alias gimp. Maybe, as 2.10 is an app which does not rely on X11 anymore (from my understanding) it has to be done some other way?
Reply


Forum Jump: