Posted by brandizzi on Wed 19 Nov 05:53 (modification of post by Anonymous view diff)
report abuse | download | new post
- #!/bin/bash
- # Breaking/splitting a image into pieces
- if [ $# != 5 ] ; then
- echo "split.sh <file> <original x pixels> <original y pixels> <slice x pixels> <slice y pixels>"
- exit
- fi
- file=$1
- originalx=$2
- originaly=$3
- slicex=$4
- slicey=$5
- numberx=$((originalx/slicex))
- numbery=$((originaly/slicey))
- topdf=''
- for i in `seq 0 $numberx`; do
- for j in `seq 0 $numbery`; do
- convert -crop ${slicex}x${slicey}+$((i*slicex))+$((j*slicey)) $file $file-$j-$i.png
- topdf="$topdf $file-$j-$i.png"
- done
- done
- convert $topdf $file.pdf
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.