summaryrefslogtreecommitdiffstats
path: root/gimp/scripts/gimp-normalize-to-bootsplash.scm
blob: 6f961d8570428a88ce438358ccf6619e097c7e88 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
; dmmScalePNG.scm - GIMP Script-Fu to Scale a PNG Image to a New Width
;    This Script-Fu must be put in The GIMP's script directory
;    (e.g., $HOME/.gimp-1.2/scripts).
;    For interactive invocation, run The GIMP and go to
;    Xtns -> Script-Fu -> dmm
;    New width is in pixels
;

(define (gimp-normalize-to-bootsplash-dirs quality dirpattern pattern)
   (let* ((dirs (file-glob dirpattern 1))
	  (count (car dirs))
	  (dirlist (cadr dirs))
	  (i 0))
     (while (< i count)
	    (let* ((dirname (aref dirlist i))
		   (filepattern (strcat dirname "/" pattern)))
	      (gimp-message (strcat "Browsing " filepattern))
	      (gimp-normalize-to-bootsplash-files quality filepattern))
	    (set! i (+ i 1)))))

(define (gimp-normalize-to-bootsplash-files quality pattern)
   (let* ((files (file-glob pattern 1))
	  (count (car files))
	  (filelist (cadr files))
	  (i 0))
     (while (< i count)
	    (let* ((infile (aref filelist i))
		   (outfile (strcat (car (strbreakup infile ".")) ".jpg")))
	      (gimp-message (strcat "Processing " infile))
	      (gimp-normalize-to-bootsplash quality infile outfile))
	    (set! i (+ i 1)))))

(define (gimp-normalize-to-bootsplash quality infile outfile)
   (let* ((image (car (file-png-load 1 infile infile)))
         )
	
	(gimp-image-flatten image)
	(gimp-image-convert-rgb image)

     	(let* ((drawable (car (gimp-image-get-active-drawable image))))

		(file-jpeg-save 1 image drawable outfile outfile quality 0 0 0 "Mandriva Theme" 0 1 0 0 )
		(gimp-image-delete image)
	 )
	
   )
)

(script-fu-register                                 ; I always forget these ...
   "gimp-normalize-to-bootsplash"                                    ; script name to register
   "<Toolbox>/Xtns/Script-Fu/Mandriva/Save the jpeg image to the right format for bootsplash"       ; where it goes
   "Transform a png image to a jpg compatible image for bootsplash"   ; script description
   "Warly/blino"                             ; author
   "Copyright 2006 by Mandriva; GNU GPL"  ; copyright
   "2006-09-01"                                     ; date
   ""	; type of image
   SF-VALUE "Quality" "0.9"                        ; default quality
   SF-FILENAME "Infile" "infile.png"
   SF-FILENAME "Infile" "outfile.jpg"
)