SHARE
TWEET

brandizzi

a guest Nov 18th, 2008 171 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. # Breaking/splitting a image into pieces
  3. if [ $# != 5 ] ; then
  4.         echo "split.sh <file> <original x pixels> <original y pixels> <slice x pixels> <slice y pixels>"
  5.         exit
  6. fi
  7. file=$1
  8. originalx=$2
  9. originaly=$3
  10. slicex=$4
  11. slicey=$5
  12. numberx=$((originalx/slicex))
  13. numbery=$((originaly/slicey))
  14.  
  15. topdf=''
  16. for i in `seq 0 $numberx`; do
  17.   for j in `seq 0 $numbery`; do
  18.     convert -crop ${slicex}x${slicey}+$((i*slicex))+$((j*slicey)) $file $file-$j-$i.png
  19.     topdf="$topdf $file-$j-$i.png"
  20.   done
  21. done
  22. convert $topdf $file.pdf
RAW Paste Data
Top