It is currently Mon Aug 24, 2026 5:41 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Tutorial for running GIMP in headless mode from a batch file
PostPosted: Wed Mar 01, 2017 1:58 am  (#1) 
Offline
GimpChat Member

Joined: Mar 01, 2017
Posts: 5
I recently found the script to export multiple layers (from khalim19), where it picks up the name of the PNG file from the layer name.

It changed my life... ;-)

I want to automate my workflow further however as I have several XCF files I am wanting to generate PNG's from. What I would like is a simple example of how you would achieve this with command line arguments to Gimp.exe.

Or if there is a better way (BIMP ? - which I suppose is a contraction of Batch and GIMP?).

Any pointers gratefully received.


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: Tutorial for running GIMP in headless mode from a batch file
PostPosted: Wed Mar 01, 2017 2:15 am  (#2) 
Offline
Administrator
User avatar

Joined: Aug 10, 2012
Posts: 14172
Location: Native to NYC living in Arizona, Gimp 2.8 - 3.0, Win 11 PC.
RrnR wrote:
I recently found the script to export multiple layers (from khalim19), where it picks up the name of the PNG file from the layer name.

It changed my life... ;-)

I want to automate my workflow further however as I have several XCF files I am wanting to generate PNG's from. What I would like is a simple example of how you would achieve this with command line arguments to Gimp.exe.

Or if there is a better way (BIMP ? - which I suppose is a contraction of Batch and GIMP?).

Any pointers gratefully received.

There is a plug-in called,
Export Layers as separate PNG's.

What it does is,
it exports all the layers of a given XCF file as a separate PNG image.

I often put the XCF file I wish to run this script on,
into it's own folder.
This way all the PNG image can be easily found.

Not sure if this is axactly what you're looking for,
but place the PY file into your User plugins folder and you'll find it under,
File>Export Layers as separate PNGs.


Attachment:
Export_Layers_as_separate_PNGs.zip [1.24 KiB]
Downloaded 329 times

_________________
Image
"A wise man learns more from a foolish question than a fool can learn from a wise answer"
Image


Top
 Post subject: Re: Tutorial for running GIMP in headless mode from a batch file
PostPosted: Wed Mar 01, 2017 4:19 am  (#3) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there
You could start learning from the GIMP Batch mode guide: https://www.gimp.org/tutorials/Basic_Batch/

Kevin


Top
 Post subject: Re: Tutorial for running GIMP in headless mode from a batch file
PostPosted: Wed Mar 01, 2017 3:45 pm  (#4) 
Offline
GimpChat Member

Joined: Mar 01, 2017
Posts: 5
Thanks for your replies.

@Wallace I already have a similar plug-in installed. It exports any layers it finds with a name enclosed in square brackets, however, the workflow to regenerate all the images is:

- load the xcf file
- select the "Export layers" menu entry
- click OK on the dialog
- click OK on the PNG format settings dialog.
- close xcf file
- ...
- repeat for the next xcf file ....

I just want to do that from a batch file.

@paynekj - Thanks - I'll look at that tutorial.


Top
 Post subject: Re: Tutorial for running GIMP in headless mode from a batch file
PostPosted: Thu Mar 02, 2017 4:26 pm  (#5) 
Offline
GimpChat Member

Joined: Mar 01, 2017
Posts: 5
I would still love some assistance on this. I am trying to call the procedure that exports layers from a batch file. I started by trying to call the procedure from the Python script console. The procedure browser suggests the syntax of the call is:

>>> pdb.plug_in_export_layers(image, file_extension, output_directory, layer_groups_as_folders, ignore_invisible, autocrop, use_image_size, file_ext_mode, strip_mode, square_bracketed_mode, crop_to_background, merge_layer_groups, empty_folders, ignore_layer_modes, overwrite_mode)


My command fails however:

>>> pdb.plug_in_export_layers("test.xcf", "png", "", 0, 0, 0, 0, 2, 2, 3, 0, 0, 0, 0, 0)
Traceback (most recent call last):
  File "<input>", line 1, in <module>
TypeError: wrong parameter type


Not a particularly helpful error message. Can somebody give me a clue where I might be going wrong? (I also tried replacing all the zero parameters with None).


Top
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]



* Login  



Powered by phpBB3 © phpBB Group