-
Notifications
You must be signed in to change notification settings - Fork 0
/
xcf-thumbnailer.scm
74 lines (65 loc) · 1.97 KB
/
xcf-thumbnailer.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
;xcf-thumbnailer.scm
;==============================================================================
;
;
;Copyright (C) 2020 Melon (https://github.com/Mhlov)
;
; LICENSE
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 3 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
;
;==============================================================================
;Tested on GIMP 2.10.8
(define (mhl-save-thumbnail infile outfile size)
(define image (car (gimp-xcf-load 1 infile infile)))
(define w (car (gimp-image-width image)))
(define h (car (gimp-image-height image)))
(define new_w size)
(define new_h size)
(if (and (<= w size) (<= h size))
(begin
(set! new_w w)
(set! new_h h))
; else
(if (> w h)
(set! new_h (round (/ size
(/ w h))))
; else
(set! new_w (round (/ size
(/ h w))))
)
)
(define drawable (car (gimp-image-merge-visible-layers image 1)))
;(define drawable (car (gimp-image-get-active-drawable image)))
(gimp-layer-scale drawable
new_w
new_h
TRUE)
(file-png-save-defaults 1
image
drawable
outfile
outfile)
)
(script-fu-register "mhl-save-thumbnail"
"MHL-Save-Thumbnail"
"Save Thumbnail"
"MHL <mhl@localhost>"
"MHL"
"2020"
"*"
SF-FILENAME "Infile" ""
SF-FILENAME "Outfile" ""
SF-VALUE "Thumbnail size" "0"
)