title: BASH - math image size
body: <p>I am trying to find fractions of an image size using this </p>
  
  <pre><code>w=$(identify -format "%w" $1)
  h=$(identify -format "%h" $1)
  w16=$(($w/16))
  w2=$(($w/2))
  h16=$(($h/16))
  h2=$(($h/2))
  </code></pre>
  
  <p>which returns this error</p>
  
  <pre><code>identify: unable to open image `1323728291642.jpg': ��� @ error/blob.c/OpenBlob/2489.
  identify: unable to open image `1323728291642.jpg':  @ error/blob.c/OpenBlob/2489.
  identify: unable to open image `1323728291642.jpg': �8� @ error/blob.c/OpenBlob/2489.
  identify: unable to open image `1323728291642.jpg':  @ error/blob.c/OpenBlob/2489.
  bash: /16: syntax error: operand expected (error token is "/16")
  </code></pre>
  
  <p>it was being used in this context</p>
  
  <pre><code>for i in `cat ../list`; do . ~/base64ensize.sh "$i" jpg|gpaste add;read -p "Press [Enter] key to start backup..."; done
  </code></pre>
  
  <p>list was a list of image files in the current directory</p>
  
  <p>if needed here is the rest of base64ensize.sh</p>
  
  <pre><code>w=$(identify -format "%w" $1)
  h=$(identify -format "%h" $1)
  w16=$(($w/16))
  w2=$(($w/2))
  h16=$(($h/16))
  h2=$(($h/2))
  #echo $w $w2 $w15 $h $h2 $h16
  echo -n "&lt;img height='$h16' width='$w16' onclick="
  echo -n '"this.height='
  echo -n "'$h2';this.width='$w2'"
  echo -n '" ondblclick="this.height='
  echo -n "'$h16';this.width='$w16'"
  echo -n '"'
  
  echo -e "src='data:image/EXT;base64,"$(base64 $1)"'&gt;" &gt;&gt; temp
  sed s/"EXT"/$2/ temp
  rm temp
  </code></pre>