Skip to content

Commit

Permalink
Added scripts for tiling
Browse files Browse the repository at this point in the history
  • Loading branch information
Deepwinter committed Jun 28, 2012
1 parent 5dc9d04 commit 662fc12
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 6 deletions.
3 changes: 3 additions & 0 deletions computeSizes.sh
@@ -0,0 +1,3 @@
#!/bin/sh
#identify -format "<key>%f/key> <dict> <key>width</key> <string>%w</string> <key>height</key> <string>%h</string> </dict>" [0-9]*-[0-9]*.jpg
identify -format "<key>%f</key> <dict> <key>width</key> <string>%w</string> <key>height</key> <string>%h</string> <key>name</key> <string>%f</string> </dict>" $1
15 changes: 10 additions & 5 deletions pad.sh
@@ -1,19 +1,24 @@
#!/bin/bash
#Args
# $1 = the filename to pad
# $2 = the ration - NOT IMPLEMENTED
FILENAME=$1
HEIGHT=`identify -format "%h" "$FILENAME"`
WIDTH=`identify -format "%w" "$FILENAME"`
echo $HEIGHT
echo $WIDTH
echo Beginning WxH: $HEIGHT $WIDTH
TARGETHEIGHT=0
TARGETWIDTH=0
COMPAREWIDTH=$(($HEIGHT * 2 / 3))
RATIO=2/3
REVERSERATIO=3/2

COMPAREWIDTH=$(($HEIGHT * $RATIO))
if [ $WIDTH -gt $COMPAREWIDTH ]
then
TARGETWIDTH=$WIDTH
TARGETHEIGHT=$(($WIDTH * 3 / 2))
TARGETHEIGHT=$(($WIDTH * $REVERSERATIO))
else
TARGETHEIGHT=$HEIGHT
TARGETWIDTH=$(($HEIGHT * 2 / 3))
TARGETWIDTH=$(($HEIGHT * $RATIO))
fi
echo $TARGETHEIGHT
echo $TARGETWIDTH
Expand Down
3 changes: 2 additions & 1 deletion resize.sh
Expand Up @@ -6,4 +6,5 @@ then
fi
TARGETFILENAME=`expr "$1" : '\(.*[0-9]*-[0-9]*\)'`
echo "$2""$TARGETFILENAME"".jpg"
convert "$1" -resize 1526x2048^ "$2""$TARGETFILENAME"".jpg"
#convert "$1" -resize 1526x2048^ "$2""$TARGETFILENAME"".jpg"
convert "$1" -resize 3052x40928^ "$2""$TARGETFILENAME"".jpg"
15 changes: 15 additions & 0 deletions tile.sh
@@ -0,0 +1,15 @@
#!/bin/bash
#This script was created by Mike Lin
#See http://www.mikelin.ca/blog/2010/06/iphone-splitting-image-into-tiles-for-faster-loading-with-imagemagick/
file=$1
function tile() {
convert $file -scale ${s}%x -crop 256x256 \
-set filename:tile "%[fx:page.x/256]_%[fx:page.y/256]" \
+repage +adjoin "../../tiles/${file%.*}_${s}_%[filename:tile].${file#*.}"
}
s=100
tile
s=50
tile
s=20
tile
11 changes: 11 additions & 0 deletions tileAtScale.sh
@@ -0,0 +1,11 @@
#!/bin/bash
#This script was created by Mike Lin
#See http://www.mikelin.ca/blog/2010/06/iphone-splitting-image-into-tiles-for-faster-loading-with-imagemagick/
file=$1
function tile() {
convert $file -scale ${s}%x -crop 256x256 \
-set filename:tile "%[fx:page.x/256]_%[fx:page.y/256]" \
+repage +adjoin "../../tiles/${file%.*}_${s}_%[filename:tile].${file#*.}"
}
s=$2
tile
2 changes: 2 additions & 0 deletions tileEm.sh
@@ -0,0 +1,2 @@
#!/bin/bash
find . *[0-9]-[0-9]* -exec ~/image-scripts/tile.sh {} \;

0 comments on commit 662fc12

Please sign in to comment.