Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
script to merge files into layers and set a layer mask
#1
Hallo,

I need a script for batch mode:

There are files t0.tif and t1.tif (single page tifs) in the current directory.

The script should open these files and put them into a single file as layers
(t0.tif as bottom and t1.tif as top layer).

Then, the script should set "grain merge" to the top layer and add a white
layer mask.

I am somewhat familiar with (scheme)lisp, but I have no knowledge on
script-fu.

Finally, the script should save the file in standard gimp format.

Daniel
Reply
#2
Hallo,

well, I should provide some motivation.    The first person who posts a working script (as below) gets exclusively a high resolution tif (3526 x 3246)  of the attached photo for private usage.  (I am the copyright holder and I have the permission to publish the photo.)

The script has to be written in python-fu, and I want to call the script from cygwin under windows 20 (64bit).

I have files t00.tif, ..., t11.tif (single page tifs) in the current directory.  The script should generate a single file with
t00.tif, ..., t11.tif as layers.    t00.tif should be the top layer, ..., t11 the bottom layer.

The above 11 layers should get a white layer mask, and the mix method should be "grain merge".

Best regards,
Daniel


Attached Files Image(s)
   
Reply
#3
I wrote this based on your first incomplete specification to give me some practice with Python-Fu, and as you've now changed to a new incomplete specification, you can regard this as a starter for you to continue with.


.zip   danieldd.zip (Size: 1.11 KB / Downloads: 4)
Reply
#4
(09-14-2020, 07:28 AM)Kevin Wrote: I wrote this based on your first incomplete specification to give me some practice with Python-Fu, and as you've now changed to a new incomplete specification, you can regard this as a starter for you to continue with.

Thank you,   I will have a look at the script late in the evening.

Daniel
Reply
#5
Hallo,

based on Kevins script I wrote the code, below.

When I copy and paste the code into Gimp's python console, it works fine. 
However, when I want to run the code outside Gimp (e.g. by double clicking
GIMP 2/bin/python.exe), it cannot import from gimpfu.




Code:
ImportError: No module named gimpfu


My script code:


Code:
import os,glob
from gimpfu import *

ctrl = 0
os.chdir('D:/z')
for tiffile in glob.glob('*tif'):
  print tiffile
  tiffile = 'D:/z/' + tiffile
  if ctrl == 0:
    image = pdb.gimp_file_load(tiffile,tiffile)
    ctrl = 1
  else:
    newlayer = pdb.gimp_file_load_layer(image, tiffile)
    image.add_layer(newlayer, -1)
    newlayer.mode = LAYER_MODE_GRAIN_MERGE
    mask_channel = newlayer.create_mask(ADD_MASK_WHITE)
    newlayer.add_mask(mask_channel)

pdb.gimp_display_new(image)
gimp.displays_flush()
Reply
#6
You can't run GIMP scripts/plug-ins outside GIMP.

For the code I wrote, I made a windows batch file (.bat) with this inside:

Code:
"C:\Program Files\GIMP 2.10\bin\gimp-console-2.10.exe" -df -b "(python-fu-danieldd RUN-NONINTERACTIVE \"P1320328_sml.JPG\" \"P1320578_sml.JPG\" \"fred.xcf\")" -b "(gimp-quit 0)"

And I've deleted your message with the link to your image because I'm not interested in having a copy of it, but thanks anyway.
Reply


Forum Jump: