You are here

Get GIMP version (so scripts can be backwards compatible to 2.6)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
Rate this item!
AttachmentSize
GetGIMPVersion.scm6.82 KB

Get GIMP version (so scripts can be backwards compatible to 2.6)

I just created this stand alone script so that I can make my scripts work in 2.8 and 2.6. This used to be part of another script I had, so I'm not sure whether or not I needed to do script-fu-register, but it's working for me in 2.8.0 without having that.

There is an example usage in the header, but I'm showing it here, too:

; Example usage:
;
; ; Determine if GIMP version is greater than 2.6.X
; (set! gimpVersionHigherThan2pt6ptX (isGimpVersionHigherThan2pt6ptX))
;
; (if (= gimpVersionHigherThan2pt6ptX TRUE)
; (begin
; (gimp-image-insert-layer theImage ImageCopyLayer 0 -1) ; (gimp-image-insert-layer image layer parent position)
; ) ; end begin condition is true
; (begin
; ; This works in 2.6.x but is deprecated in 2.7.x and higher.
; (gimp-image-add-layer theImage ImageCopyLayer -1)
; ) ; end begin condition is false
; ) ; end if

Tags: 
GIMP Version: 
Scripting Engine: 

Comments

here is the one I use:

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 v) (car v)) #f (if (> (cadr v) (cadr c)) #t (if (> (cadr v) (cadr c)) #f (if (>= (caddr v) (caddr c)) #t #f)))))))

Use like so (highest version first):

(if (gimp-version-meets? "2.7.0")
(begin
; whatever applies to >= 2.7.0+
)
(begin ; less than 2.7.0
; whatever applies to earlier than 2.7.0
)

-Rob A>

Subscribe to Comments for "Get GIMP version (so scripts can be backwards compatible to 2.6)"