(define (script-fu-image-sizes max-width max-height list-filename title ndbo-format output-file)
(set! StoryFile (fopen output-file "w"))
(set! ListFile (fopen list-filename "r"))
(set! image-file "")
(set! theChar "X")
(set! threshold (/ 604 450 ))
(fwrite "<html>\n" StoryFile)
(fwrite "<head>\n" StoryFile)
(fwrite (string-append "<title>" title "</title>") StoryFile)
(fwrite "</head>\n" StoryFile)
(if (equal? ndbo-format #t)(begin 
   (fwrite "<body background=\"../marble.jpg\">\n" StoryFile)))
(if (equal? ndbo-format #f)(begin 
   (fwrite "<body>\n" StoryFile)))
   
(if (equal? ndbo-format #t)(begin 
   (fwrite (string-append "<center><u><h1>" title "</center></u></h1>") StoryFile)))
(while (not (equal? () theChar))
       (set! image-file "")
       (while 	(begin 	(set! theChar (fread 1 ListFile))
			      (and 	(not (equal? "\n" theChar))
				      (not (equal? () theChar))
				      )
			      )
		      (set! image-file (string-append image-file theChar))

       )
       (set! image-file-only (car(reverse(strbreakup image-file "/"))))
       (if (not (equal? image-file "")) (begin 
       (set! image (car(gimp-file-load 0  image-file image-file)))
       (set! width (car(gimp-image-width image)))
       (set! height (car(gimp-image-height image)))
       (gimp-image-delete image)
       (set! aspect-ratio (/ width height))
       (set! new_width (if (> aspect-ratio threshold) max-width (* (/ width height)max-height)))
       (set! new_height (if (> aspect-ratio threshold) (* (/ height width)max-width)max-height))
       (set! line (string-append "<img src=\"" image-file-only "\" width=\"" (number->string ( + new_width 0.5 ) 10 0) "\" height=\"" (number->string (+ new_height 0.5) 10 0) "\">\n"))
       (fwrite "<p>\n" StoryFile)
       (fwrite line StoryFile)
       (fwrite "</p>\n" StoryFile)))
) 
(fwrite "</body>\n" StoryFile)      
(fwrite "</html>\n" StoryFile)      
(fclose StoryFile)
(fclose ListFile)
)
(script-fu-register "script-fu-image-sizes"
"<Toolbox>/Xtns/Script-Fu/Utils/ImageSizes"
"File Sizes"
"NDBO Consulting"
"NDBO Consulting ndboconsulting@planet.nl"
"5/5/2003"
""
SF-ADJUSTMENT _"Max Width (pixels)" '(604 2 1000 1 1 0 1)
SF-ADJUSTMENT _"Max Height (pixels)" '(450 2 1000 1 1 0 1)
SF-FILENAME _"File List" ""
SF-STRING _"Title" "Title"
SF-TOGGLE  _"NDBO format" TRUE
SF-STRING _"Output File" ""
)
