|
7 | 7 | # http://www.imagemagick.org/script/command-line-options.php#append |
8 | 8 | # https://github.com/image-media-playlist/spec/blob/master/image_media_playlist_v0_4.pdf |
9 | 9 | # https://www.tecmint.com/install-imagemagick-in-linux/ |
| 10 | +# https://stackoverflow.com/questions/39504522/create-blank-image-in-imagemagick |
| 11 | +# https://stackoverflow.com/questions/5688576/how-to-use-mod-operator-in-bash |
10 | 12 |
|
11 | | -if [ $# -lt 5 ]; then |
12 | | - echo "Usage: $0 <thumbnails-dir> <input-prefix> <output-prefix> <cols> <rows>" |
| 13 | +if [ $# -lt 6 ]; then |
| 14 | + echo "Usage: $0 <thumbnails-dir> <input-prefix> <output-prefix> <resolution> <cols> <rows>" |
13 | 15 | exit 1 |
14 | 16 | fi |
15 | 17 |
|
16 | 18 | INDIR=$1 |
17 | 19 | INPREFIX=$2 |
18 | 20 | OUTPREFIX=$3 |
19 | | -COLS=$4 |
20 | | -ROWS=$5 |
| 21 | +RESOLUTION=$4 |
| 22 | +COLS=$5 |
| 23 | +ROWS=$6 |
21 | 24 |
|
22 | 25 | # All parameters need to be specified |
23 | 26 | # The $INDIR parameter is a directory containing the thumbnails |
@@ -50,8 +53,36 @@ if [ ${ROWS} -eq 1 ] && [ ${COLS} -eq 1 ]; then |
50 | 53 | exit 0 |
51 | 54 | fi |
52 | 55 |
|
53 | | -# normal handling of tile generation |
| 56 | +# calculate thumbs need to fill N tiles, result is TILETHUMBS |
| 57 | +# and LASTTILE is the tile that may need to be padded |
54 | 58 | let "TILESIZE=$COLS * $ROWS" |
| 59 | +let "TILETHUMBS=$TILESIZE" |
| 60 | +let "LASTTILE=1" |
| 61 | +while [ $TILETHUMBS -lt $THUMBCOUNT ] |
| 62 | +do |
| 63 | + let "TILETHUMBS=$TILETHUMBS + $TILESIZE" |
| 64 | + let "LASTTILE=$LASTTILE + 1" |
| 65 | +done |
| 66 | + |
| 67 | +# generation of padding for the last tile, if padding is needed |
| 68 | +if [ $TILETHUMBS -gt $THUMBCOUNT ]; then |
| 69 | + let "ALIGNCOUNT=$TILETHUMBS - $THUMBCOUNT" |
| 70 | + echo "ALIGNCOUNT = $ALIGNCOUNT" |
| 71 | + COUNT=1 |
| 72 | + mkdir tile${LASTTILE} |
| 73 | + while [ $COUNT -le $ALIGNCOUNT ] |
| 74 | + do |
| 75 | + let "TILENUM=$THUMBCOUNT + $COUNT" |
| 76 | + let "COUNT=$COUNT + 1" |
| 77 | + convert -size ${RESOLUTION} xc:black tile${LASTTILE}/$INPREFIX-${TILENUM}.jpg |
| 78 | + done |
| 79 | + |
| 80 | + # finally, reset THUMBCOUNT to include padded tiles |
| 81 | + #let "THUMBCOUNT=$THUMBCOUNT + $ALIGNCOUNT" |
| 82 | + #echo "THUMBCOUNT = $THUMBCOUNT" |
| 83 | +fi |
| 84 | + |
| 85 | +# normal handling of tile generation |
55 | 86 | while [ $STARTTILE -lt $THUMBCOUNT ] |
56 | 87 | do |
57 | 88 | let "ENDTILE= $STARTTILE + $TILESIZE - 1" |
|
0 commit comments