Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

executable file 29 lines (27 sloc) 0.699 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
#!/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 Beginning WxH: $HEIGHT $WIDTH
TARGETHEIGHT=0
TARGETWIDTH=0
RATIO=2/3
REVERSERATIO=3/2

COMPAREWIDTH=$(($HEIGHT * $RATIO))
if [ $WIDTH -gt $COMPAREWIDTH ]
then
TARGETWIDTH=$WIDTH
  TARGETHEIGHT=$(($WIDTH * $REVERSERATIO))
else
TARGETHEIGHT=$HEIGHT
  TARGETWIDTH=$(($HEIGHT * $RATIO))
fi
echo $TARGETHEIGHT
echo $TARGETWIDTH
x="x"
suffix=".converted.tif"
echo $TARGETWIDTH$x$TARGETHEIGHT
convert "$FILENAME" -gravity center -crop $TARGETWIDTH$x$TARGETHEIGHT-0-0\! -background black -flatten "$FILENAME"$suffix
Something went wrong with that request. Please try again.