Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
loops ; switch on/off masks ; export png
#1
Hi,

Can someone please help me for my first gimp script ?

I have a gimp file with these layers : a, b1, b2, c, d1, d2 and e.

I would like to do a script which exports several images from this gimp file. I need this script does a selection of the layers for each export, I wish in fact this :

image1.png : only with layers a, b1, c, d1 and e. (layers b2 and d2 are hidden)
image2.png : only with layers a, b1, c, d2 and e. (layers b2 and d1 are hidden)
image3.png : only with layers a, b2, c, d1 and e. (layers b1 and d2 are hidden)
image4.png : only with layers a, b2, c, d2 and e. (layers b1 and d1 are hidden)


So can someone explain me :

1. How to do loops,
2. How to switch on/off layers,
3. How to export ?

Thanks  Smile
Reply
#2
(12-03-2021, 04:17 PM)aka Wrote: Hi,

Can someone please help me for my first gimp script ?

I have a gimp file with these layers : a, b1, b2, c, d1, d2 and e.

I would like to do a script which exports several images from this gimp file. I need this script does a selection of the layers for each export, I wish in fact this :

image1.png : only with layers a, b1, c, d1 and e. (layers b2 and d2 are hidden)
image2.png : only with layers a, b1, c, d2 and e. (layers b2 and d1 are hidden)
image3.png : only with layers a, b2, c, d1 and e. (layers b1 and d2 are hidden)
image4.png : only with layers a, b2, c, d2 and e. (layers b1 and d1 are hidden)


So can someone explain me :

1. How to do loops,
2. How to switch on/off layers,
3. How to export ?

Thanks  Smile

Have you got specific names on the layers or are the mutually exclusive layers in a group?

Also, what is the export format and do you need specific format-related settings (JPEG quality...)?
Reply
#3
(12-03-2021, 05:22 PM)Ofnuts Wrote: Have you got specific names on the layers or are the mutually exclusive layers in a group?

Also, what is the export format and do you need specific format-related settings (JPEG quality...)?

Hi,

a, b1,.. are the names of the layers, I tought I put the gimp file with my first post.

I draw myself the pictures in gimp (with a wacom tablet), they are with colors and look like cartoons figures. I heard that, in this case, png is better than jpeg. Sorry, I have no ideas about specific format-related settings to choose ; perhaps can you give me an advice for that too ?

Thanks Smile


Attached Files
.xcf   forscript.xcf (Size: 11.13 KB / Downloads: 174)
Reply
#4
See https://www.gimp-forum.net/Thread-ofn-ex...mbinations
Reply
#5
(12-04-2021, 02:37 PM)Ofnuts Wrote: See https://www.gimp-forum.net/Thread-ofn-ex...mbinations

Thanks a lot !

And impossible for me to see the script in Gimp... I tried a lot of things, but it seems that something is missing : 

devel@k0:~/.config/GIMP/2.10/plug-ins$ ./ofn-export-layers-combinations.py
Traceback (most recent call last):
  File "./ofn-export-layers-combinations.py", line 30, in <module>
    from gimpfu import *
ImportError: No module named gimpfu

In theory, this package exists in debian 11 ( from https://packages.debian.org/search?searc...e&arch=any)

/usr/lib/gimp/2.0/python/gimpfu.py  gimp-python

But nothing on my computer :

devel@k0:~/.config/GIMP/2.10/plug-ins$ ls -l /usr/lib/gimp/2.0/
total 16
drwxr-xr-x   2 root root 4096 18 sep 08:30 environ
drwxr-xr-x   2 root root 4096 18 sep 08:30 interpreters
drwxr-xr-x   2 root root 4096 18 sep 08:30 modules
drwxr-xr-x 122 root root 4096 28 oct 06:41 plug-ins

root@k0:~# apt-get install gimp-python
Lecture des listes de paquets... Fait
Construction de l'arbre des dépendances... Fait
Lecture des informations d'état... Fait      
E: Impossible de trouver le paquet gimp-python

Does please someone know what to do ?
Reply
#6
See https://www.gimp-forum.net/Thread-Heal-S...1#pid18351

To make it short, Gimp uses Python 2.7 which is deprecated so distros post-January 2020 make it quite hard to use Python. But there are workarounds.
Reply
#7
(12-05-2021, 09:50 AM)Ofnuts Wrote: See https://www.gimp-forum.net/Thread-Heal-S...1#pid18351

To make it short, Gimp uses Python 2.7 which is deprecated so distros post-January 2020 make it quite hard to use Python. But there are workarounds.

OK, and I  have python 2.7.18 :

devel@k0:~/.config/GIMP/2.10/plug-ins$ python -V
Python 2.7.18

Have I to do like https://www.gimp-forum.net/Thread-Heal-S...1#pid18351  ?
Reply
#8
2.7.18 should be fine.

Otherwise, I run my own self-compiled Gimp on a pre-2020 distro so I can't really help for the particulars, but that thread seems to have nailed it.
Reply
#9
Hi,

I had some success on a debian buster. I installed gimp and gimp-python packages, put your script in /home/pi/.config/GIMP/2.10/plug-ins/ and :

1. I had to change the line
exportMenu='<Image>/File/Export/'
to
exportMenu='<Image>'
to see the script in gimp (I have a french menu, perhaps that changes something?)

2. When I run the script on the same image, I have only one (attached) file exported.

Can you please help me ?


Attached Files Image(s)
   
Reply
#10
Did you read the HTML doc? Did you put the layers in groups?
Reply


Forum Jump: