It is currently Fri Aug 07, 2026 5:24 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: v2 script stopped working in Gimp3
PostPosted: Tue May 13, 2025 5:05 pm  (#1) 
Offline
New Member

Joined: May 13, 2025
Posts: 2
I had a script which stopped working after moving to gimp 3 (linux). It was based off one of the tutorial scripts in here: gimp org /tutorials / Basic_Batch/
Here is the original script from the tutorial. By the way - this tutorial obviously still shows v2 scripting which no longer works in gimp!
(define (batch-unsharp-mask pattern
                              radius
                              amount
                              threshold)
  (let* ((filelist (cadr (file-glob pattern 1))))
    (while (not (null? filelist))
           (let* ((filename (car filelist))
                  (image (car (gimp-file-load RUN-NONINTERACTIVE
                                              filename filename)))
                  (drawable (car (gimp-image-get-active-layer image))))
             (plug-in-unsharp-mask RUN-NONINTERACTIVE
                                   image drawable radius amount threshold)
             (gimp-file-save RUN-NONINTERACTIVE
                             image drawable filename filename)
             (gimp-image-delete image))
           (set! filelist (cdr filelist)))))


Now if I run it - it no longer works, says "batch command experienced an execution error:
Error: car: argument 1 must be: pair "

I pinned this one down to (filelist (cadr (file-glob pattern 1)))
What can be wrong with it?


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: v2 script stopped working in Gimp3
PostPosted: Tue May 13, 2025 11:54 pm  (#2) 
Offline
Global Moderator
User avatar

Joined: May 16, 2010
Posts: 16152
Executables, Python or SCM filters need to be re-written for Gimp-3. Gimp-2 versions will not work.

More info here.
https://gegl.org/operations/

And here.
https://gegl.org/operations/gegl-unsharp-mask.html

_________________
Image


Top
 Post subject: Re: v2 script stopped working in Gimp3
PostPosted: Wed May 14, 2025 12:05 am  (#3) 
Offline
Global Moderator
User avatar

Joined: May 16, 2010
Posts: 16152
Here is an example of a scm i wrote for Gimp-3 but i never released as it doesn't seem to work as well on an image as the version for Gimp-2.
;;; Plugin  : Embroidery Stitcher
;;; Author  : Rod Detmer
;;; Date    : August 1st 2012
;;; Revision: Gimp-3.0
;;;                
;;; Version : 1.0
;;; Latest version at: http://www.gimpchat.com/viewtopic.php?f=9&t=4858&p=60447#p60447
;;; Required : Gimp 3.0 or later
;;;
;;; Description:
;;; Creates an embroidery effect on your Image
;;; -----------------------------------------------------------------------------
;;;
;;; License:
;;; This program is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 2 of the License, or
;;; (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, write to the Free Software
;;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

#!/usr/bin/env gimp-script-fu-interpreter-3.0

(define (script-fu-embroidery-stitcher image drawable)
  (gimp-context-push)
  (gimp-image-undo-group-start image)

              (let* ((emlayer (car (gimp-layer-new-from-visible image image "Embroided layer"))))
          
;copy the image to a new layer and name it
   (gimp-image-insert-layer image emlayer 0 0)


;Create filter and merge filter with set properties
(gimp-drawable-merge-new-filter emlayer "gegl:noise-spread" 0 LAYER-MODE-REPLACE 1.0
        "amount-x" 7 "amount-y" 7 "seed" 0)



;Create filter and merge filter with set properties
(gimp-drawable-merge-new-filter emlayer "gegl:edge-neon" 0 LAYER-MODE-REPLACE 1.0
        "radius" 4.081 "amount" 0.080)



;set layer mode for Embroided layer
  (gimp-layer-set-mode emlayer LAYER-MODE-HSV-VALUE-LEGACY)
 
;set opacity for Embroided layer
  (gimp-layer-set-opacity emlayer 68)
 
 
;display the new image
  (gimp-displays-flush image)
  (gimp-context-pop)
  (gimp-image-undo-group-end image)
             )
 
)


(script-fu-register "script-fu-embroidery-stitcher"
"Embroidery-Stitcher"
"creates an embroidery effect and using more colors result in better outcome"
"Rod Detmer"
"Rod Detmer"
"August 2012"
"RGB* GRAY*"
SF-IMAGE "The Image" 0
SF-DRAWABLE "The Drawable" 0
)

(script-fu-menu-register "script-fu-embroidery-stitcher" "<Image>/Rod/Artistic")



Showing how to add a GEGL operation within Scheme.

Hope that helps. :bigthup

Remember the scm has to go into a folder with the same name as the script and placed in the plugins folder.
Hence this line at the top of the script
#!/usr/bin/env gimp-script-fu-interpreter-3.0

_________________
Image


Top
 Post subject: Re: v2 script stopped working in Gimp3
PostPosted: Sun Dec 28, 2025 12:46 pm  (#4) 
Offline
New Member

Joined: May 13, 2025
Posts: 2
No sorry but this does not help me with my particular error, which happens on line
  (filelist

                        (vector-ref
                        (cadr
                                 (file-glob #:pattern  pattern #:filename-encoding TRUE)

                        )
                        0)
                )

Where can I find information on these: vector-ref, cadr, car, file-glob ?

The error I get is
Quote:
: car: argument 1 must be: pair


Also I don't use this scm as a plugin, I run it as as batch script.
Script loads JPG files in the folder, applies an enhancement, then saves each file. Used to run it from command line like that:
gimp -i --batch-interpreter plug-in-script-fu-eval -b '(batch-levels-stretch "*.JPG")'

It used to perfectly work before, I am now contemplating to install older version of Gimp

There is no information whatsoever on how to fix it, no examples of new scripts, no documentation, Gimp 3.2 RC2 still includes folder with default old scripts which are not working, I thought if someone decides to majorly break ALL of the scripts - at least provide some examples of the new ones, at least those which are provided as part of the release?

script-fu-util.scm, part of 3.0 package, contains function with-files, which is broken with the same error.
; For example, to invert the colors of all of the PNG files in the
; start directory:
;
;    gimp -i -b '(with-files "*.png" (gimp-drawable-invert layer FALSE) \
;                 (gimp-file-save 1 image layer filename))'
;
; To do the same thing, but saving them as jpeg instead:
;
;    gimp -i -b '(with-files "*.png" (gimp-drawable-invert layer FALSE) \
;                 (gimp-file-save 1 image layer \
;                  (string-append basename ".jpg") ))'

; butlast is needed below.
; Not in R5RS but in simply-scheme and chicken dialects.
; aka drop-right.
; Returns new list with right element deleted.
(define (butlast x)
  (if (= (length x) 1)
    '()
    (reverse (cdr (reverse x)))
  )
)

(define-macro (with-files pattern . body)
  (let ((loop (gensym))
        (filenames (gensym))
        (filename (gensym)))
    `(begin
       (let ,loop ((,filenames (cadr (file-glob ,pattern 1))))
         (unless (null? ,filenames)
           (let* ((filename (car ,filenames))
                  (image (catch #f (car (gimp-file-load RUN-NONINTERACTIVE
                                                        filename))))
                  (layer (if image (vector-ref (gimp-image-get-selected-layers image) 0) #f))
                  (basename (unbreakupstr (butlast (strbreakup filename ".")) ".")))
             (when image
               ,@body
               (gimp-image-delete image)))
           (,loop (cdr ,filenames))
         )
       )
     )
  )
)


Top
 Post subject: Re: v2 script stopped working in Gimp3
PostPosted: Sun Dec 28, 2025 2:07 pm  (#5) 
Offline
GimpChat Member

Joined: Mar 04, 2011
Posts: 2610
There is documentation for Gimp 3 script-fu but it is slow coming. You can have a script-fu plugin which will have some advantages. https://developer.gimp.org/resource/scr ... hanges-v3/

At the moment, for batch processing try the batcher plugin https://github.com/kamilburda/batcher where you can apply those gegl filters, as many as you like, Example:

Attachment:
batcher.jpg
batcher.jpg [ 95.75 KiB | Viewed 2655 times ]


Top
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]



* Login  



Powered by phpBB3 © phpBB Group