-
Notifications
You must be signed in to change notification settings - Fork 0
/
gimpFunctions.scm
46 lines (45 loc) · 1.7 KB
/
gimpFunctions.scm
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
(define (extract-cover inFile outFile res lostSpace)
(let*
(
(image (car (gimp-file-load RUN-NONINTERACTIVE inFile inFile) ) )
(drawable (car (gimp-image-get-active-drawable image) ) )
(width (car (gimp-image-width image) ) )
(height (car (gimp-image-height image) ) )
(xsize (/ (* 148 res) 25.4) )
(xpos (- (- width xsize) (/ (* lostSpace res) 25.4) ) )
(ysize (/ (* 210 res) 25.4) )
(ypos (- (- height ysize) (/ (* lostSpace res) 25.4) ) )
)
(gimp-image-crop image xsize ysize xpos ypos)
(file-png-save-defaults RUN-NONINTERACTIVE image drawable outFile outFile)
)
)
(define (convert-ebook inFile outFile type)
(let*
(
(image (car (gimp-file-load RUN-NONINTERACTIVE inFile inFile) ) )
(drawable (car (gimp-image-get-active-drawable image) ) )
(width (car (gimp-image-width image) ) )
(height (car (gimp-image-height image) ) )
(scale (max (/ width (min width 600) ) (/ height (min height 800) ) ) )
)
(gimp-image-scale image (/ width scale) (/ height scale) )
(if (equal? type "png")
(file-png-save-defaults RUN-NONINTERACTIVE image drawable outFile outFile)
(file-jpeg-save RUN-NONINTERACTIVE image drawable outFile outFile .9 0 1 1 "" 2 0 0 0)
)
)
)
(define (convert-print inFile outFile type)
(let*
(
(image (car (gimp-file-load RUN-NONINTERACTIVE inFile inFile) ) )
(drawable (car (gimp-image-get-active-drawable image) ) )
)
(gimp-image-convert-grayscale image)
(if (equal? type "png")
(file-png-save-defaults RUN-NONINTERACTIVE image drawable outFile outFile)
(file-jpeg-save RUN-NONINTERACTIVE image drawable outFile outFile .9 0 1 1 "" 2 0 0 0)
)
)
)