gimp-comment in batch file
This discussion is connected to the gimp-user-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.
This is a read-only list on gimpusers.com so this discussion thread is read-only, too.
gimp-comment in batch file | David Woodfall | 03 Jun 17:59 |
gimp-comment in batch file | saulgoode@flashingtwelve.brickfilms.com | 04 Jun 02:37 |
gimp-comment in batch file | saulgoode@flashingtwelve.brickfilms.com | 04 Jun 02:46 |
gimp-comment in batch file | David Woodfall | 04 Jun 20:51 |
gimp-comment in batch file | David Woodfall | 04 Jun 21:15 |
gimp-comment in batch file | Sven Neumann | 05 Jun 08:58 |
gimp-comment in batch file
Hi,
I'm trying to write a batch scm to insert a comment into a tiff. Here is the test code. It appears to function correctly but does not seem to add the comment:
(define (batch-test pattern)
(let* (
(filelist (cadr (file-glob pattern 1)))
(filename2)
(filename)
(image)
(drawable)
)
(while filelist
(set! filename (car filelist))
(set! image (car (file-tiff-load RUN-NONINTERACTIVE filename filename)))
(set! drawable (car (gimp-image-flatten image)))
(set! gimp-comment "Some Test Text")
(file-tiff-save RUN-NONINTERACTIVE image drawable "test.tif" "test.tif" 0)
(gimp-image-delete image)
(set! filelist (cdr filelist))
)
)
)
I have no idea if (set! gimp-comment "Some Test Text") is the right way of doing this but googling doesn't shed much light on it.
gimp-comment in batch file
In order to change the "gimp-comment" you must change a parasite that is attached to the image. The following code defines a function that will set the 'gimp-comment' parasite to the passed string. (Note: I don't have access to the GIMP right now, so I haven't tested it; though I think it will work.)
Include the function definition in your file (I recommend inserting it right after the '(define (batch-test pattern)' line) and replace your
(set! gimp-comment "Some Test Text")
with
(add-comment image "Some Test Text")
;;----------------------------------------------------------
;; 'add-comment' attaches "gimp-comment" parasite to 'image'
;; with the value of the passed 'string'
;;
(define (add-comment image string)
(*catch 'errobj
(gimp-image-parasite-find image "gimp-comment")
(if (not (null? errobj))
(gimp-image-parasite-detach image "gimp-comment")
)
)
(gimp-image-parasite-attach (list "gimp-comment"
3
(bytes-append string)))
)
----------------------------------- Quoting David Woodfall :
Hi,
I'm trying to write a batch scm to insert a comment into a tiff. Here is the test code. It appears to function correctly but does not seem to add the comment:
(define (batch-test pattern) (let* (
(filelist (cadr (file-glob pattern 1))) (filename2)
(filename)
(image)
(drawable)
)
(while filelist
(set! filename (car filelist)) (set! image (car (file-tiff-load RUN-NONINTERACTIVE filename filename)))
(set! drawable (car (gimp-image-flatten image))) (set! gimp-comment "Some Test Text") (file-tiff-save RUN-NONINTERACTIVE image drawable "test.tif" "test.tif" 0)
(gimp-image-delete image)
(set! filelist (cdr filelist)) )
)
)I have no idea if (set! gimp-comment "Some Test Text") is the right way of doing this but googling doesn't shed much light on it.
gimp-comment in batch file
OOPS! The 'if' statement should be "(if (null? errobj)". I had my logic backwards.
Quoting saulgoode@flashingtwelve.brickfilms.com:
;;---------------------------------------------------------- ;; 'add-comment' attaches "gimp-comment" parasite to 'image' ;; with the value of the passed 'string' ;;
(define (add-comment image string) (*catch 'errobj
(gimp-image-parasite-find image "gimp-comment") (if (not (null? errobj))
(gimp-image-parasite-detach image "gimp-comment") )
)
(gimp-image-parasite-attach (list "gimp-comment" 3 (bytes-append string))) )
gimp-comment in batch file
On (20:46 03/06/07), saulgoode@flashingtwelve.brickfilms.com put forth the proposition:
OOPS! The 'if' statement should be "(if (null? errobj)". I had my logic backwards.
Quoting saulgoode@flashingtwelve.brickfilms.com:
;;---------------------------------------------------------- ;; 'add-comment' attaches "gimp-comment" parasite to 'image' ;; with the value of the passed 'string' ;;
(define (add-comment image string) (*catch 'errobj
(gimp-image-parasite-find image "gimp-comment") (if (not (null? errobj))
(gimp-image-parasite-detach image "gimp-comment") )
)
(gimp-image-parasite-attach (list "gimp-comment" 3 (bytes-append string))) )
Hi and thanks for your help. Unfortunately I'm getting an execution error. It seems to be the gimp-image-parasite-attach line that's causing it. I tried a simple version and the parasite-find and detach lines seem to work.
_______________________________________________ Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user
gimp-comment in batch file
On (19:51 04/06/07), David Woodfall put forth the proposition:
On (20:46 03/06/07), saulgoode@flashingtwelve.brickfilms.com put forth the proposition:
OOPS! The 'if' statement should be "(if (null? errobj)". I had my logic backwards.
Quoting saulgoode@flashingtwelve.brickfilms.com:
;;---------------------------------------------------------- ;; 'add-comment' attaches "gimp-comment" parasite to 'image' ;; with the value of the passed 'string' ;;
(define (add-comment image string) (*catch 'errobj
(gimp-image-parasite-find image "gimp-comment") (if (not (null? errobj))
(gimp-image-parasite-detach image "gimp-comment") )
)
(gimp-image-parasite-attach (list "gimp-comment" 3 (bytes-append string))) )Hi and thanks for your help. Unfortunately I'm getting an execution error. It seems to be the gimp-image-parasite-attach line that's causing it. I tried a simple version and the parasite-find and detach lines seem to work.
Ok fixed now:
(gimp-image-parasite-attach image (list "gimp-comment"
3
(bytes-append string)))
Thanks again
_______________________________________________ Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user
gimp-comment in batch file
Hi,
On Sun, 2007-06-03 at 20:37 -0400, saulgoode@flashingtwelve.brickfilms.com wrote:
;;---------------------------------------------------------- ;; 'add-comment' attaches "gimp-comment" parasite to 'image' ;; with the value of the passed 'string' ;;
(define (add-comment image string) (*catch 'errobj
(gimp-image-parasite-find image "gimp-comment") (if (not (null? errobj))
(gimp-image-parasite-detach image "gimp-comment") )
)
(gimp-image-parasite-attach (list "gimp-comment" 3 (bytes-append string))) )
Why do you detach the parasite first? Shouldn't it be sufficient to just attach the new one? If I remember correctly, that should replace a parasite if one already exists under that name.
Sven