Attached is a function, script-fu-copyright, that is used to apply a
copyright notice to the image in /tmp/temp.ppm and save the results
over the original file.  With gimp 1.0.0 the function was usable from
a bash prompt as follows:

gimp --no-interface --no-data -b '(script-fu-copyright 1 "\"Mumble\"" "\"SE\"")' 
'(gimp-quit 0)'

Upon upgrading to gimp 1.0.4, the function still works if run
interactively, but from the shell prompt I now get:

batch command: experienced an execution error.
gimp: tile ref count balance: 72

Gtk-CRITICAL **: file gtkmain.c: line 534 (gtk_main_quit): assertion `main_loops != 
NULL' failed.

I banged my head trying to debug this for hours and never got
anywhere.  Help?

Thanks,
DWF

(define (script-fu-copyright text placement)
  (let* (
    (theImage (car (file-pnm-load 0 "/tmp/temp.ppm" "/tmp/temp.ppm")))
    (theImageWidth (car (gimp-image-width theImage)))
    (theImageHeight (car (gimp-image-height theImage)))
    (points (if (< theImageWidth 300) 10 12))
    (theTextExtents (gimp-text-get-extents
      text points POINTS "adobe" "helvetica" "bold" "r" "normal" "*"))
    ; 0.925 is the fudge factor
    (theTextWidth (* (car theTextExtents) 0.925))
    (theTextHeight (cadr theTextExtents))
    (placeX)
    (placeY)
        )
    (gimp-palette-set-foreground '(255 255 255))
    (if (= (strcmp placement "NW") 0)
      (begin
        (set! placeX 3)
        (set! placeY 3)
      ))
    (if (= (strcmp placement "NE") 0)
      (begin
        (set! placeX (- (- theImageWidth 3) theTextWidth))
        (set! placeY 3)
      ))
    (if (= (strcmp placement "SW") 0)
      (begin
        (set! placeX 3)
        (set! placeY (- theImageHeight theTextHeight))
      ))
    (if (= (strcmp placement "SE") 0)
      (begin
        (set! placeX (- (- theImageWidth 3) theTextWidth))
        (set! placeY (- theImageHeight theTextHeight))
      ))
    (gimp-text theImage -1 placeX placeY text
       0 TRUE points POINTS "adobe" "helvetica" "bold" "r" "normal" "*")
    (gimp-image-flatten theImage)
    (file-pnm-save 1 theImage (car (gimp-image-active-drawable theImage))
      "/tmp/temp.ppm" "/tmp/temp.ppm" 1)
  )
)
(script-fu-register
 "script-fu-copyright"                      ; function name
 "<Toolbox>/Xtns/Script-Fu/Copyright"  ; menu position
 "Adds copyright notice to an image."         ; short description
 "David Flater"                           ; author
 "Copyright 1999 David Flater"           ; copyright notice
 "August 1, 1999"                        ; date created/modified
 ""                                        ; image types it can work on
 SF-VALUE "Text String" "\"(C) 1999 David Flater.  http://www.flaterco.com/\""
 SF-VALUE "Placement" "\"SE\""
)

Reply via email to