-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCrayonPixelArt1_02.scm
124 lines (109 loc) · 5.17 KB
/
CrayonPixelArt1_02.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
; GPLv3
; 04/09/2020 to work on GIMP-2.10.20
;==============================================================
;
; Installation:
; This script should be placed in the user or system-wide script folder.
;
; Windows Vista/7/8)
; C:\Program Files\GIMP 2\share\gimp\2.0\scripts
; or
; C:\Users\YOUR-NAME\.gimp-2.8\scripts
;
; Windows XP
; C:\Program Files\GIMP 2\share\gimp\2.0\scripts
; or
; C:\Documents and Settings\yourname\.gimp-2.8\scripts
;
; Linux
; /home/yourname/.gimp-2.8/scripts
; or
; Linux system-wide
; /usr/share/gimp/2.0/scripts
;
;==============================================================
;
; 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/>.
;
;==============================================================
; Original information
(define (script-fu-crayon-pixel-art theImage drawable dithertype scale_factor scale_back interpolation chosen_palette autolevels)
(let* (
; calls to PDB functions always return a list. We have
; to pick the first element with "car" explicitely, even
; when the function called returns just one value.
(width (car (gimp-drawable-width drawable)))
(height (car (gimp-drawable-height drawable)))
(new_width (* width scale_factor))
(new_height (* height scale_factor))
(InputImageMode 0);mode of the input image. needed so we can prevent errors when getting an RGB image as input.
)
;create undo group
(gimp-image-undo-group-start theImage)
; (gimp-image-scale-full theImage (* (gimp-image-width theImage) scale_factor) (* (gimp-image-height theImage) scale_factor) 0);can't do this :(
(set! InputImageMode ( car (gimp-image-base-type theImage )))
(if (not (= InputImageMode 0))
(gimp-convert-rgb theImage)
);convert to RGB if the image isn't already an RGB image
; check if the image is going to be scaled before scaling.
(if (not (= new_width 0))
(gimp-image-scale theImage new_width new_height)
)
;apply autoleveling if desired
;this is pretty useless if the image is a gif as typically pure white and pure black are two of the colors in the palette so this does nothing in those cases.
(if (= autolevels TRUE)
(gimp-drawable-levels-stretch drawable)
);FML I kept getting an error here bc it can run on an IMAGE yet it really wants a DRAWABLE;theImage))
;apply dither
(if (= dithertype 1)
(gimp-drawable-set-name drawable "FloydSteinbergDither")
)
(if (= dithertype 2)
(gimp-drawable-set-name drawable "FloydSteinbergLowBleedDither")
)
(if (= dithertype 3)
(gimp-drawable-set-name drawable "FixedDither")
)
(gimp-image-convert-indexed theImage dithertype 4 0 FALSE FALSE chosen_palette)
(if (= scale_back TRUE)
(gimp-image-scale theImage width height)
)
;create undo group
(gimp-image-undo-group-end theImage)
(gimp-displays-flush)
) ; end let
) ;; end of define
;I was receiving a "eval unbound variable error" because I had mistyped my variable
;I was receiving an "illegal token" error because I had deleted the "let" statement and didn't realize that it had a matching parens way at the end of the script before we register the script ...this also might manifest as a "mismatched or unmatched parens" error
(script-fu-register "script-fu-crayon-pixel-art"
"Crayon Pixel Art"
"Processes an image creating a pixelized image given a palette. Creates pixilized image. \nfile:CrayonPixelArt1_02.scm"
"InkyDinky"
"InkyDinky"
"2011 11 28"
"*"
SF-IMAGE "Image" 0
SF-DRAWABLE "Drawable" 0
;SF-ENUM "Dither" '("DitherType" "GIMP_FS_DITHER") google gimp enum types
SF-OPTION "Dither" '("None" "Floyd-Steinberg" "Floyd-Steinberg Low Bleed" "Fixed")
SF-ADJUSTMENT "Scale Factor" '(3 1 5 1 2 0 SF-SLIDER)
SF-TOGGLE "Scale back to orig size" TRUE
SF-OPTION "Interpolation" '("None" "Linear" "Cubic" "Sinc (Lanczos3)") ;. http://developer.gimp.org/api/2.0/libgimpbase/libgimpbase-gimpbaseenums.html
SF-PALETTE "Palette" "Ega"
SF-TOGGLE "Auto-level image?" TRUE
)
(script-fu-menu-register "script-fu-crayon-pixel-art" "<Image>/Script-Fu/Photo/Graphic/")
; end of file