-
Notifications
You must be signed in to change notification settings - Fork 12
/
smooth-drop-shadow.sh
executable file
·55 lines (46 loc) · 1.48 KB
/
smooth-drop-shadow.sh
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
#!/bin/bash
# smooth-drop-shadow.sh
# Copies images, adding a smooth drop shadow, with enlargement to accommodate. Requires GIMP.
# Author: Paul Taylor @bao7uo
# Wildcard filenames MUST be specified in double quotes
SCRIPT_NAME="report-drop-shadow"
GIMP_VERSION=$(echo $(gimp-console --version) | grep -oP "(?<=version )\d+\.\d+")
GIMP_SCRIPT="$HOME/.gimp-$GIMP_VERSION/scripts/$SCRIPT_NAME.scm"
function gimp-script-create {
cat <<-EOF > "$GIMP_SCRIPT"
;
; $SCRIPT_NAME.scm
; Copies an image with a drop shadow
; Author: Paul Taylor @bao7uo
;
; $GIMP_SCRIPT
;
(define ($SCRIPT_NAME infile outfile offsetx offsety radius opacity allowresizing)
(let*
(
(image (car (gimp-file-load RUN-NONINTERACTIVE infile infile)))
(drawable (car (gimp-image-get-active-layer image)))
)
(script-fu-drop-shadow image drawable offsetx offsety radius '(0 0 0) opacity allowresizing)
(set! drawable (car (gimp-image-merge-visible-layers image TRUE)))
(gimp-file-save RUN-NONINTERACTIVE image drawable outfile outfile)
(gimp-image-delete image)
)
)
EOF
}
function gimp_run_script {
gimp-console -b "($SCRIPT_NAME \"$1\" \"$2\" 0 0 30 60 TRUE)" -b "(gimp-quit 0)";
}
function gimp_script_rename_wrapper {
TEMP_SUFFIX="-ds-temp-name.png"
TEMP_NAME="$1$TEMP_SUFFIX"
gimp_run_script "$1" "$TEMP_NAME"
rename -- ".png$TEMP_SUFFIX" "-ds.png" "$TEMP_NAME"
}
if [ ! -f "$GIMP_SCRIPT" ]; then
gimp-script-create
fi
for i in $1; do
gimp_script_rename_wrapper "$i"
done