It is currently Wed Apr 17, 2024 9:31 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 48 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: How to automate saving, closing and opening of images?
PostPosted: Tue Jul 31, 2012 4:24 am  (#1) 
Offline
GimpChat Member

Joined: Jul 31, 2012
Posts: 22
Hi all!

I have a question about how to optimize my work in gimp. I am not sure it is about scripting, but I found no solution yet...

The thing is: There a directory with few tenth of a *.xcf images, and the operator opens them one by one starting from the first image (and doing some stuff on them between the closing and opening the images). The sequence I want to automate is:
1. save current image
2. close it
3. open next image in directory

The question: Is there a way to automate it? If this sequence cannot be done by script, is there other ways to do it?


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: How to automate saving, closing and opening of images?
PostPosted: Wed Aug 01, 2012 3:10 pm  (#2) 
Offline
Script Coder
User avatar

Joined: Jul 14, 2010
Posts: 697
As far as I know, there is no way to close an image using a script, etc.

see here: http://www.gimptalk.com/index.php?/topi ... t-problem/

-Rob A>

_________________
Image
Fantasy Cartography and Mapping by RobA


Top
 Post subject: Re: How to automate saving, closing and opening of images?
PostPosted: Thu Aug 02, 2012 9:25 am  (#3) 
Offline
Script Coder
User avatar

Joined: Jul 14, 2010
Posts: 697
Always one to beat a dead horse, I figured out a way to make this work, using parasites. I think saulgoode is the only other person to have used parasites in a script, so I have no idea if this is the "best" way to do things, but it works on my windows box running gimp 2.6.11

Basically, instead of opening an image with file open, I have provided two scripts:

File->kobyakov->Open First xcf...
File->kobyakov->Save then Open Next xcf

The first script pops up a directory selector. Once a directory is selected, the script does some rudimentary error checks (is there at least one xcf file in that directory), then opens the first xcf file. Behind the scenes, it saves the display number into the image as an image parasite.

The second script has no parameters. It simply saves the current xcf file (overwriting the version on disk, with a bit of error checking - must be a file that exists on the disk, must be an xcf file), then checks for the parasite (meaning it was opened with the first script), and if it finds that parasite, closes the image. It then (regardless of finding the parasite or not) open the next xcf in the same directory. If there are no more xcf files, it generates a message that there are no more xcf files.

To keep it simple, the files are processed in whatever order gets returned by file-glob. I have some code for a list sort I can throw in if there is a need to process the images sorted alphabetically/numerically - just let me know.

The script is attached - hope this does what you needed.

-Rob A>


Attachments:
kobyakov.scm [4.35 KiB]
Downloaded 212 times

_________________
Image
Fantasy Cartography and Mapping by RobA
Top
 Post subject: Re: How to automate saving, closing and opening of images?
PostPosted: Thu Aug 02, 2012 10:15 am  (#4) 
Offline
GimpChat Member
User avatar

Joined: Jan 13, 2011
Posts: 2240
Location: Poland
Thank you very much Rob.
It works well (XP 32 bit, Gimp 2.8.1) and is very useful !
Can I ask for the file type selection ?

_________________
Image

Slava
Ukraini!


Top
 Post subject: Re: How to automate saving, closing and opening of images?
PostPosted: Thu Aug 02, 2012 10:27 am  (#5) 
Offline
Script Coder
User avatar

Joined: Jul 14, 2010
Posts: 697
MareroQ wrote:
Thank you very much Rob.
It works well (XP 32 bit, Gimp 2.8.1) and is very useful !
Can I ask for the file type selection ?


Probably, but a few questions -

By file type I assume you mean "jpg" "png" "xcf" etc.

Do you want to select all of one filetype in a directory, or multiple filetypes at once?

Is it OK to specify the filetype with the "open first" and then the "open next" will use the same specified filetype? (otherwise the file-glob would return different results and be non-predicatable)

-Rob A>

_________________
Image
Fantasy Cartography and Mapping by RobA


Top
 Post subject: Re: How to automate saving, closing and opening of images?
PostPosted: Thu Aug 02, 2012 10:29 am  (#6) 
Offline
GimpChat Member

Joined: Jul 31, 2012
Posts: 22
Man..... I did not leave a message after your first reply because I did not believe that it is possible.

But now I have no words to express what I am feeling....................... Are you a kind of magician?

The script just works! :tyspin

First thing I want to say - I am not feel right to have my last name mentioned in it - I did nothing to make it done. Please, name it some other way.

Second, I hope you understand that you made some wonderful work making retouchers job a bit easier than it is. Starting from now, they do not have to push a lot of buttons to get through a bunch of files!

The only thing I suggest to change - is to let the operator to pick the first image (not a directory) since not every work can be done at one attempt (and then the script should pass through the files alphabetically - the default for every file manager).

By the way, it works fine on Gimp 2.6.8 (Ubuntu).


Last edited by kobyakov on Thu Aug 02, 2012 10:38 am, edited 1 time in total.

Top
 Post subject: Re: How to automate saving, closing and opening of images?
PostPosted: Thu Aug 02, 2012 10:38 am  (#7) 
Offline
GimpChat Member

Joined: Jul 31, 2012
Posts: 22
RobA wrote:
Do you want to select all of one filetype in a directory, or multiple filetypes at once?
-Rob A>

In my case xcf is the only choice. In general, such go-through does have a sense when dealing with a bunch of images of a same type (imho). The thing which is important here - is the operator's confidence that he made them all, did not miss a single one (when opening the first image he can see the first one to do by the date).


Top
 Post subject: Re: How to automate saving, closing and opening of images?
PostPosted: Thu Aug 02, 2012 10:58 am  (#8) 
Offline
GimpChat Member
User avatar

Joined: Jan 13, 2011
Posts: 2240
Location: Poland
My request concerns the possibility to choose one type of file.

_________________
Image

Slava
Ukraini!


Top
 Post subject: Re: How to automate saving, closing and opening of images?
PostPosted: Thu Aug 02, 2012 11:19 am  (#9) 
Offline
Script Coder
User avatar

Joined: Jul 14, 2010
Posts: 697
kobyakov wrote:
The only thing I suggest to change - is to let the operator to pick the first image (not a directory) since not every work can be done at one attempt (and then the script should pass through the files alphabetically - the default for every file manager).


OK - here is an addition. I left the "Open First xcf..." but now there is also an "Open Specific xcf..." that can be used for the first image open.

I've also moved these three under File->Sequential and renamed the scheme file, as per your request, so you will have to delete the old one when switching to this one.

Haven't yet made it work with other filetypes yet... It will not be too hard to make it work with ONE specified filetype.

-Rob A>


Attachments:
sequential_processing.scm [5.35 KiB]
Downloaded 287 times

_________________
Image
Fantasy Cartography and Mapping by RobA
Top
 Post subject: Re: How to automate saving, closing and opening of images?
PostPosted: Thu Aug 02, 2012 11:23 am  (#10) 
Offline
Script Coder
User avatar

Joined: Jul 14, 2010
Posts: 697
MareroQ wrote:
My request concerns the possibility to choose one type of file.


OK - which types? They will have to be coded into a picklist then parsed from option values to strings

xcf, jpg, png, bmp any other?

-Rob A>

_________________
Image
Fantasy Cartography and Mapping by RobA


Top
 Post subject: Re: How to automate saving, closing and opening of images?
PostPosted: Thu Aug 02, 2012 11:51 am  (#11) 
Offline
GimpChat Member

Joined: Jul 31, 2012
Posts: 22
<skip this>....

UPD: Tried on a some new files - it works fine! The message "Last xcf file in directory!" appears at the bottom of the Gimp's main window.

:gimp


Last edited by kobyakov on Thu Aug 02, 2012 12:48 pm, edited 1 time in total.

Top
 Post subject: Re: How to automate saving, closing and opening of images?
PostPosted: Thu Aug 02, 2012 12:44 pm  (#12) 
Offline
GimpChat Member
User avatar

Joined: Jan 13, 2011
Posts: 2240
Location: Poland
Important for me to choose the file types are *.png, *.tiff, *.jpg, *.bmp, and *.orf (selfishly - the type of camera).

_________________
Image

Slava
Ukraini!


Top
 Post subject: Re: How to automate saving, closing and opening of images?
PostPosted: Thu Aug 02, 2012 2:11 pm  (#13) 
Offline
Script Coder
User avatar

Joined: Jul 14, 2010
Posts: 697
MareroQ wrote:
Important for me to choose the file types are *.png, *.tiff, *.jpg, *.bmp, and *.orf (selfishly - the type of camera).


okey dokey-

Give the attached a go.

Menu options are:
File->Sequential->Open First File... This allows you to select a directory and a file type (currently "xcf" "jpg" "bmp" "png" "tiff" and "orf") and will open the first file of that type (case insensitive)
File->Sequential->Open Specific File... This allows you to select a file (currently "xcf" "jpg" "bmp" "png" "tiff" and "orf") and will open that file, setting the sequential filetype to match that file.
File->Sequential->Save and Close then Open Next File This will save, then close the file opened by either of the previous methods (or by this menu item, if called again) then open the next file in the directory of the same filetype. If no files remain a message is generated.

One caveat - if multiple images are open by either of the first two menu items, the "Save and Close then Open Next File" will only continue to work on the last one opened....i.e. the script will not support more than one sequential stream going at a time.

This would probably even more handy if you map a hot key to the save, close and open next item.

While I did this more for the challenge, would this be of value to post up at the plugin registry?

-Rob A>


Attachments:
Sequential_processing.scm [7.23 KiB]
Downloaded 190 times

_________________
Image
Fantasy Cartography and Mapping by RobA
Top
 Post subject: Re: How to automate saving, closing and opening of images?
PostPosted: Fri Aug 03, 2012 10:40 am  (#14) 
Offline
GimpChat Member
User avatar

Joined: Jan 13, 2011
Posts: 2240
Location: Poland
Thanks.
Once again, thank you very much.
Are you a kind of magician?
I hope you understand that you made some wonderful work making retouchers job a bit easier than it is. Starting from now, they do not have to push a lot of buttons to get through a bunch of files!

Every solution, breaking the theoretical limits, should be disseminated.
Entirely different matter - the matter is an interest in the collection - this is the script for the holders of more files.

_________________
Image

Slava
Ukraini!


Top
 Post subject: Re: How to automate saving, closing and opening of images?
PostPosted: Tue Jan 08, 2013 6:02 am  (#15) 
Offline
GimpChat Member

Joined: Jul 31, 2012
Posts: 22
Hi!

MareroQ wrote:
...this is the script for the holders of more files...

Also this is the script for those who have to do the same work on few (tenth or thousands) files. Retouchers etc.

I use this script to retouch my images and it really helps to save time! I must say again :tyspin

I have noticed one thing. Sometime it is necessary to do a quick correction on some file(s) in the directory. Open them again one by one with script is too slow, but when I open files using standart "Open file..." next time the script avoid them.

Is it possible to force the script to run in strict alphabetical order (default sorting in any file browser, I think we all get used to that)?


Top
 Post subject: Re: How to automate saving, closing and opening of images?
PostPosted: Tue Dec 29, 2015 1:16 pm  (#16) 
Offline
GimpChat Member

Joined: Jul 31, 2012
Posts: 22
Hi!

Unfortunately, the script does not work in development version 2.9.3

I changed procedure names according to the gimp error messages, but after opening the first file "save and open again" results in "Last file in directory!" message...

Rob, can I ask you to fix it?


Top
 Post subject: Re: How to automate saving, closing and opening of images?
PostPosted: Tue Dec 29, 2015 4:55 pm  (#17) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4734
My own implementation in Python. Doesn't work like Rob's so it could be more resilient to v2.9 changes (never tested in on 2.9 though...). Basically it saves the file and looks for a like-named file with the next number in the same directory (so no need to open the first in any special way) and opens it.

_________________
Image


Top
 Post subject: Re: How to automate saving, closing and opening of images?
PostPosted: Tue Dec 29, 2015 6:57 pm  (#18) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
kobyakov wrote:
Unfortunately, the script does not work in development version 2.9.3

Try running GIMP using the --pdb-compat-mode on switch.

And FWIW, here is my script for supporting this type of workflow.

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: How to automate saving, closing and opening of images?
PostPosted: Wed Dec 30, 2015 5:51 am  (#19) 
Offline
GimpChat Member

Joined: Jul 31, 2012
Posts: 22
ofnuts: could you provide a link to your script?

saulgoode: I changed procedure names, the script goes through files in directory.
But when it comes to the last file it writes "No image available for sequential edit" and leave the image as is - it does not save it and close. one should manually do it - hit some keys and finalize the sequence. Could you fix it?


Top
 Post subject: Re: How to automate saving, closing and opening of images?
PostPosted: Wed Dec 30, 2015 7:33 am  (#20) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4734
kobyakov wrote:
ofnuts: could you provide a link to your script?

saulgoode: I changed procedure names, the script goes through files in directory.
But when it comes to the last file it writes "No image available for sequential edit" and leave the image as is - it does not save it and close. one should manually do it - hit some keys and finalize the sequence. Could you fix it?


File is here: http://sourceforge.net/projects/gimp-to ... p/download

_________________
Image


Last edited by ofnuts on Wed Dec 30, 2015 3:53 pm, edited 1 time in total.

Top
Post new topic Reply to topic  [ 48 posts ]  Go to page 1, 2, 3  Next

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) Gimp still running after an hour of closing it down

9

No new posts Attachment(s) how to automate the procedure?

14

No new posts Attachment(s) Automate merge of multiple files horizontally

3

No new posts Can ScriptFu or anything in Gimp automate the creation of layer groups

7

No new posts Attachment(s) GIMP 2.10.12 is not opening on Mac

10


cron

* Login  



Powered by phpBB3 © phpBB Group