Switch to full style
Post all Gimp scripts and script writing questions here
Post a reply

Commands to make scripts fwd & bwd compatible

Fri Sep 11, 2020 10:11 pm

(gimp-edit-fill drawable FILL-FOREGROUND) is OK 2-10 but fails in 2-8 bwds
Whereas
(gimp-edit-fill drawable FOREGROUND-FILL) is OK 2-10 & 2-8
Should our scripts be only for 2-10 or 2-8 as well ?

Re: Commands to make scripts fwd & bwd compatible

Fri Sep 11, 2020 10:27 pm

If you're asking everybody, it's a good question. If you're asking me in regards to gimpscripts.net, we are only dealing with 2.10 - simply because our workload would triple with the site, and no one's getting paid (well, maybe brownie points for the 2.10 diehards out there).

Re: Commands to make scripts fwd & bwd compatible

Fri Sep 11, 2020 11:15 pm

Mahvin my only interest is that scripts can be compatable with 2-6,2-8 & 2-10, shown below is an example of 'gimp-edt-fill'
Add this before your script starts with (define (script-fu-'blurb' and it will cover your script and answ (gimp-version-meets? check)

Code:
;
;Helper function to check the gimp version
(define (gimp-version-meets? check)
  (let ((c (map string->number (strbreakup check ".")))
        (v (map string->number (strbreakup (car (gimp-version)) "."))))
  (if (> (car v) (car c)) #t
  (if (< (car c) (car v)) #f
   (if (> (cadr v) (cadr c)) #t
   (if (< (cadr v) (cadr c)) #f
     (if (>= (caddr v) (caddr c)) #t #f)))))))
;

then replace 'gimp-edit-fill' with

Code:
(gimp-edit-fill  drawable (cond ((gimp-version-meets? "2.10.0") FILL-FOREGROUND ) (else FOREGROUND-FILL)))

Re: Commands to make scripts fwd & bwd compatible

Fri Sep 11, 2020 11:31 pm

Nice!

Re: Commands to make scripts fwd & bwd compatible

Fri Sep 11, 2020 11:56 pm

Thanks Mahvin That and other minor changes make it possible for me to run scripts across all 3 gimp platforms although no one should be using 2-6

Re: Commands to make scripts fwd & bwd compatible

Sat Sep 12, 2020 1:24 am

Hi Graechan.

You are absolutely right that plugins should be universal - however, the behavior of Gimp developers is a bit strange:
1. Due to the removal of around 35 plugins in 2.10 (compared to 2.8) many plugins stopped working - what was done: removed the scripts.
2. When the time comes for Gimp-3.0, those based on Python2 will stop working (not much left).
3. Most of the plugins for Gimp-2.8 have already been tweaked and I expect backwards compatibility will be bypassed someday so I'm focusing on adjusting them only to 2.10 (because for 2.8 they are original or already reworked). There is not enough time and people willing to enter your code into many plugins. :gaah

Re: Commands to make scripts fwd & bwd compatible

Sat Sep 12, 2020 1:51 am

MareroQ I'm not concerned with deleted plugins as such, but with plugins that have changed parameters it's strange that in 'gimp-edit-fill' FOREGROUND-FILL works in gimps 2.8 and 2.10

even though the 2.10 'procedure browser' shows FILL-FOREGROUND. Gimp doesn't tell us the full story

Re: Commands to make scripts fwd & bwd compatible

Sat Sep 12, 2020 2:17 am

You can not be backward and forward compatible in a script unless you insert some sort of trapping to use applicable blocks of code.

These 'old' scripts are only complatible because of the Gimp developers use of backward compatibility. Run Gimp 2.10.x with the switch --pdb-compat-mode=off and see how compatible the script really is.

In normal use, and the various releases. Before Gimp 2.10.12, GEGL had not replaced fixed compatibility of some plugins, example bump-map (I know, bad example from me). Then Gimp 2.10.14 is not very compatible at all. The developers implementation of the pdb links to GEGL I find has improved with 2.10.20. The only certain way to run an old script is use an 'old' Gimp.

Re: Commands to make scripts fwd & bwd compatible

Sun Sep 13, 2020 12:06 am

Rich2005 that there is snake language (python). I downloaded and installed my 2-10-20 from gimp, instead of playing with parameters to enter an 'alpha' answer simply enter the numeric value
(gimp-edit-fill drawable 0),this will succeed in past and present gimps the same applies to layer-modes

Re: Commands to make scripts fwd & bwd compatible

Sun Sep 13, 2020 3:08 am

....(gimp-edit-fill drawable 0),this will succeed in past and present gimps the same applies to layer-modes...


Indeed it does and I have done that myself in the past. I believe this is generally considered bad practice.
While Gimp 2.10.20 is the best so far for backward compatibility, taking gimp-edit-fill as the example.

Gimp 2 is usually (but not always) compiled with --pdb-compat-mode=on as default
Procedure browser shows it is deprecated, new plugins/scripts should not use it but we are talking old plugins/scripts here.

mode-on.jpg
mode-on.jpg (152.24 KiB) Viewed 3704 times


This procedure gimp-edit-fill does not actually exist, run Gimp with --pdb-compat-mode=off and see what you get.

mode-off.jpg
mode-off.jpg (55.17 KiB) Viewed 3704 times


Even then not quite the same as Gimp 2.8 although where you might use 'NO-FILL(5)' I do not know ;)

mode-28.jpg
mode-28.jpg (124.48 KiB) Viewed 3704 times


As MareroQ wrote above, nothing is future proof.

Re: Commands to make scripts fwd & bwd compatible

Sun Sep 13, 2020 10:20 pm

While nothing can be done to future proof Gimp it can be backward compatible and still use the commands applicable to the current version
((cond ((gimp-version-meets? "2.10.0") gimp-drawable-edit-fill) (else gimp-edit-fill)) drawable 0)

Most of my scripts run in 2.8 and 2.6 so to allow for the nuiences of 2.10 is no problem
Post a reply