-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcreate_map_sprites
More file actions
executable file
·43 lines (32 loc) · 927 Bytes
/
Copy pathcreate_map_sprites
File metadata and controls
executable file
·43 lines (32 loc) · 927 Bytes
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
#!/bin/bash
#./create_map_sprites file1 [file2 [file3..]] dest/
FILES="${@:1:$#-1}"
DEST="${@:(-1)}"
if [[ ! -d $DEST ]]; then
echo "Destination must be a directory"
echo "$DEST"
exit 1
fi
WIDTH=180
HEIGHT=180
# Scale the map preview
SCALE_WIDTH="iw*min($WIDTH/iw\,$HEIGHT/ih)"
SCALE_HEIGHT="ih*min($WIDTH/iw\,$HEIGHT/ih)"
FILTER_SCALE="scale=$SCALE_WIDTH:$SCALE_HEIGHT"
# Pad the map preview
PAD_WIDTH="$WIDTH"
PAD_HEIGHT="$HEIGHT"
PAD_X="($WIDTH-iw*min($WIDTH/iw\,$HEIGHT/ih))/2"
PAD_Y="($HEIGHT-ih*min($WIDTH/iw\,$HEIGHT/ih))/2"
FILTER_PAD="pad=$PAD_WIDTH:$PAD_HEIGHT:$PAD_X:$PAD_Y"
FILTER="$FILTER_SCALE, $FILTER_PAD"
for i in $FILES; do
if [[ ! -f "$i" ]]; then
echo "$i is not a regular file. skipping"
continue
fi
filename=`basename $i`
extension="${filename##*.}"
filename="${filename%.*}"
$FFMPEG -i "$i" -filter:v "$FILTER" "$DEST/$filename.png" -y
done