3 # depolar_resample_IMAGEMAGICK.sh - build a pixel map for JMPrope
5 # Copyright (C) 2014 Antonio Ospite <ao2@ao2.it>
7 # This program is free software. It comes without any warranty, to
8 # the extent permitted by applicable law. You can redistribute it
9 # and/or modify it under the terms of the Do What The Fuck You Want
10 # To Public License, Version 2, as published by Sam Hocevar. See
11 # http://sam.zoy.org/wtfpl/COPYING for more details.
20 [ -f "$1" -a "x$2" != "x" ] || { echo "usage: $(basename $0) <input file> <output file> [imagemagick options]" 1>&2; exit 1; }
28 [ -e $OUTPUT_FILENAME ] && { echo "Error: $OUTPUT_FILENAME already exists, remove it first" 1>&2; exit 1; }
30 WIDTH=$(identify -format "%[fx:w]" "$INPUT_FILENAME")
31 HEIGHT=$(identify -format "%[fx:w]" "$INPUT_FILENAME")
33 if [ $WIDTH -ne $INPUT_WIDTH -o $HEIGHT -ne $INPUT_HEIGHT ];
35 echo "Error: image must be ${INPUT_WIDTH}x${INPUT_HEIGHT}" 1>&2
39 CX=$(identify -format "%[fx:h/2]" "$INPUT_FILENAME")
40 CY=$(identify -format "%[fx:h/2]" "$INPUT_FILENAME")
42 OPTIONS="-interpolate NearestNeighbor -filter point -background black -flatten"
44 convert "$INPUT_FILENAME" $OPTIONS \
45 -set option:distort:scale $SCALE +distort DePolar "0 0 $CX,$CY 0,360" \
46 -flop -crop +0+$INTERNAL_RADIUS $@ +repage "$OUTPUT_FILENAME"