-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathimageDirPngsToSpritesheet.sh
More file actions
executable file
·37 lines (30 loc) · 1.15 KB
/
imageDirPngsToSpritesheet.sh
File metadata and controls
executable file
·37 lines (30 loc) · 1.15 KB
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
#!/bin/bash
source @includes.sh
echo '###################################################'
echo '# Description: Creates a single-column spritesheet out of a directory of png files'
echo '# Usage: $ ./imageDirPngsToSpritesheet.sh /path/to/images'
echo '# Param 1: Image directory'
echo '# Param 2: Number of rows'
echo '# Requires: Imagemagick'
echo '###################################################'
echoNewline
################################################################################
################################################################################
# check parameters
if [[ $1 == "" ]] ; then
echoError "1st arg must be an image directory"
exit 1
fi
if [[ $2 == "" ]] ; then
echoError "2nd arg must be number of spritesheet rows"
exit 1
fi
################################################################################
################################################################################
# get filename
imgDir=$1
outputFile="$imgDir/_tiles.png"
# do conversion
montage $imgDir/*.png -tile 1x$2 -geometry +0+0 -background none $outputFile
echoSuccess "Spritesheet created: $outputFile"
# say Spritesheet created