Even more Script-fu!

So this is the perspective transformation from before, this time edited to allow the script to run through every image file with the same extension and then save it in a subdirectory called 'temp'. This script is designed to run on Windows, to fix it for Linux, find the \\ (double backslashes) and replace them with / (1 forward slash).

; Perspective transformation on a directory
; This script takes a directory, and a file extension, and does a perspective transformation
; on each image file with that extension in the directory, saving the result as a .png file
; Copyright - David Wees 2007
; Released under the GNU Public License

(define (perspective-transform infile outfile)
  (let* ((image (car (gimp-file-load 1 infile infile)))
         (drawable (car (gimp-image-active-drawable image)))
         )

  (set! newlayer (car (gimp-image-get-active-layer image)))
  (set! width  (car (gimp-drawable-width newlayer)))
  (set! height (car (gimp-drawable-height newlayer)))


  (set! x0 0)
  (set! y0 0)
  (set! x1 (/ width 2))
  (set! y1 (/ height 3))
  (set! x2 0)
  (set! y2 height)
  (set! x3 (/ width 2))
  (set! y3 (* 2 (/ height 3)))
  (gimp-drawable-transform-perspective-default drawable x0 y0 x1 y1 x2 y2 x3 y3 0 1 )
  (file-png-save 1 image drawable outfile outfile 1 0 0 0 0 0 0 )
            ; 1 Adam7 interlacing?
            ;   0 deflate compression factor (0-9)
            ;     0 Write bKGD chunk?
            ;       0 Write gAMMA chunk?
            ;         0 Write oFFs chunk?
            ;           0 Write tIME chunk?    ?? backwards in DB Browser
            ;             0 Write pHYS chunk?  ?? backwards in DB Browser
  )
)

  

(define (script-fu-perspective-transform-directory directory fileex)
  (let* ((files (file-glob (string-append directory "\\*" fileex)  0))
	 (dirlength (string-length directory))
	 (numfiles (car files))
	 (image-list '())
	 (filelist (cadr files)))
    

    
    (if (= (length filelist) 0)
	(gimp-message "No files were found. Check the folder path, and the file extention"))

    (while filelist
        ; take the image name off of the stack
	(set! imagename (car filelist))

        ; shift the stack
	(set! filelist (cdr filelist))

        ; try and find the filename
        (set! rawfilename (substring imagename dirlength (string-length imagename)))
        (set! filename (substring rawfilename 1 (- (string-length rawfilename) (string-length fileex))))
        (set! filename (string-append directory "\\temp\\" filename ".png"))

        ; do the transformation
        (perspective-transform imagename filename)
    )
  )
)

(script-fu-register "script-fu-perspective-transform-directory"
		    "Perspective Directory Transformation"
		    "This takes an image and creates a perspective transformation of the image."
		    "David Wees<dweesdesign@gmail.com>"
		    "David Wees - released under GNU Public license"
		    "2007"
		    ""
		    SF-DIRNAME     _"Directory of images"   "/path/to/where/your/files/are"
		    SF-STRING      _"File extention" ".jpg"
)

(script-fu-menu-register "script-fu-perspective-transform-directory" "<Toolbox>/Xtns/Script-Fu/Misc")

As usual, save this as perspective-transform-directory.scm in your Gimp scripts directory.