Gimptalk - Premier Gimp Community: gap and script-fu problem - Gimptalk - Premier Gimp Community

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

gap and script-fu problem

#1 User is offline   stm 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 2
  • Joined: 23-April 12

Posted 23 April 2012 - 09:57 AM

Hi,

I'm trying to use gap in a script-fu. This is going well so far, but when I try to use plug-in-gap-move-path-ext2 it doesn't seem to find the control point file. I get this error:
Execution Error: could not load MovePath controlpoints from file: ORBIT_SOCKETDIR=/tmp/orbit-stm

plug-in-gap-move-path-ext (the variant with arrays) works just fine, but I want to read my control points from a file. This is what I use:

(plug-in-gap-move-path-ext2 RUN-NONINTERACTIVE img_cone 0
; from to layerstack ...
1 111 0 the_layer gap_loop_none gap_handle_center 4444 1 0 0 0.0 1.0 0 100.0 100.0
; tracelayer-enable tr-init tr-desc bluebox (no selmode!)
0 100.0 0.0 0
"/tmp/bl_points"
)

I'm using gimp on Ubuntu linux. What am I doing wrong? Any help appreciated
0

#2 User is offline   stm 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 2
  • Joined: 23-April 12

Posted 25 April 2012 - 10:27 PM

I still don't know what I was doing wrong, but I have a workaround. I'm posting it here, in case someone else has a similar problem, but I'm a very inexperienced scheme programmer, so this is probably not very elegant or even correct. You've been warned!

; read one line from open port p
; return the line as string or an empty string if at eof
(define (read-line p)
  (let loop((ls1 '()) (c (read-char p)))
    (if (eof-object? c) (if (null? ls1) "" (list->string (reverse ls1)))
	(if (equal? c #\newline)
	    (list->string (reverse ls1))
	    (loop (cons c ls1) (read-char p))))))
; read next line from open port p, skip lines starting with '#'
; return the line or empty string if at eof
(define (read-line-skip-comments p)
  (let ((line (read-line p)))
    (if (> (string-length line) 0) (if (equal? (substring line 0 1) "#") (read-line-skip-comments p) line) line)))
; read a string str of numbers
; return as (possibly empty) list
(define (read-string str)
  (let ((p (open-input-string str)))
    (let loop ((ls1 '()) (s (read p)))
      (if (eof-object? s) 
	  (if (null? ls1) ls1 (reverse ls1))
	  (loop (cons s ls1) (read p))))))
; read a control point file
; the file format is rather underspecified in the gap documentation so this might not work for every possible file, especially if it contains keyframse
; ignore lines starting with '#' and first line without '#'
; return list of columns, where columns are a list of numbers where the first number is the number of entries
(define (read-cpfile file-name)
  (let ( (p (open-input-file file-name)) )
    (begin (read-line-skip-comments p) ; skip "pos num-lines"
	   (let loop ( (ls1 '()) (line (read-string (read-line-skip-comments p))) )
	     (if (null? line)
		 (begin (close-input-port p) (transpose (reverse ls1)))
		 (loop (cons (cons (length line) line) ls1) (read-string (read-line-skip-comments p))))))))
; read a list of lists with equal length
; return the transposed list of lists, i.e., the first list is the list of first entries, the second list is the list of second entries a.s.f
(define (transpose m) (apply map list m))
; return vector part of argument list for plug-in-gap-move-path-ext
; returns something like ( 2 #(1 2) 2 #(3 4) 2 #(80 80)...)
(define (read-control-points file_name)
  (let* ( (ll (read-cpfile file_name))
	  (len (length (car ll))) 
	  (long (= (caar ll) 17)) )
    (list len (list->vector (cadr ll)) ; x
	  len (list->vector (caddr ll)) ; y
	  len (list->vector (cadr (cddddr ll))) ; opacity
	  len (list->vector (cadddr ll)) ; width
	  len (list->vector (car (cddddr ll))) ; height
	  len (list->vector (caddr (cddddr ll))) ; rotation
	  len (make-vector len 0) ; no keyframe
	  len (if long (list->vector (car (cdr (cddddr (cddddr ll))))) (make-vector len 1)) ; transx1
	  len (if long (list->vector (cadr (cdr (cddddr (cddddr ll))))) (make-vector len 1)) ; transy1
	  len (if long (list->vector (caddr (cdr (cddddr (cddddr ll))))) (make-vector len 1)) ; transx2
	  len (if long (list->vector (cadddr (cdr (cddddr (cddddr ll))))) (make-vector len 1)) ; transy2
	  len (if long (list->vector (car (cddddr (cdr (cddddr (cddddr ll)))))) (make-vector len 1)) ; transx3
	  len (if long (list->vector (cadr (cddddr (cdr (cddddr (cddddr ll)))))) (make-vector len 1)) ; transy3
	  len (if long (list->vector (caddr (cddddr (cdr (cddddr (cddddr ll)))))) (make-vector len 1)) ; transx4
	  len (if long (list->vector (cadddr (cddddr (cdr (cddddr (cddddr ll)))))) (make-vector len 1)) ; transy4
	  len (list->vector (cadddr (cddddr ll))) ; feather_radius
;	  len (list->vector (car (cddddr (cddddr ll)))) ; num of optional arguments ignored
	  )
    ))

;
; replaces plug-in-gap-move-path-ext2
;
(define (my-move-path run-mode dst-image drawable range-from range-to nr src-layer-id src-stepmode src-handle src-paintmode src-force-visible clip-to-img rotation-follow startangle step-speed-factor tween-steps tween-opacity-initial tween-opacity-desc tracelayer-enable trace-opacity-initial trace-opacity-desc apply-bluebox src-selmode control-file-name)
  (let ( (control_points (read-control-points control-file-name)) )
    (apply plug-in-gap-move-path-ext run-mode dst-image drawable range-from range-to nr src-layer-id src-stepmode src-handle src-paintmode src-force-visible clip-to-img rotation-follow startangle step-speed-factor tween-steps tween-opacity-initial tween-opacity-desc tracelayer-enable trace-opacity-initial trace-opacity-desc apply-bluebox src-selmode
	   control_points)) )

0

#3 User is offline   ccbarr 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 1,705
  • Joined: 23-February 06

Posted 02 May 2012 - 12:21 PM

stm:

I don't know if you ever got an answer to your questions, but I would recommend trying to PM saulgoode. I don't know how often he logs in here any longer, but I believe he is more active over at gimptalk.com It's easy to join over there.

He is very well versed with Gimp scripts and I believe also with Gimp GAP. I'm not 100% certain he can help you, but if he can't, he might be able to refer you elsewhere for help.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic