#!/bin/bash # # im_profile image_file # # Plot a graph the horizontal grayscale image given, and include a # copy of the input image as the X axxis of the graph. # #### # # WARNING: Input arguments are NOT tested for correctness. # This script represents a security risk if used ONLINE. # I accept no responsiblity for misuse. Use at own risk. # # Anthony Thyssen, 5 July 2008 # PROGNAME=`type $0 | awk '{print $3}'` # search for executable on path PROGDIR=`dirname $PROGNAME` # extract directory of program PROGNAME=`basename $PROGNAME` # base name of program Usage() { # output the script comments as docs echo >&2 "$PROGNAME:" "$@" sed >&2 -n '/^###/q; /^#/!q; s/^#//; s/^ //; 3s/^/Usage: /; 2,$ p' \ "$PROGDIR/$PROGNAME" exit 10; } # while [ $# -gt 0 ]; do # case "$1" in # --help|--doc*) Usage ;; # Documentation # -l) line=true ;; # -t) shift; title=$1 ;; # --) shift; break ;; # end of user options # -*) Usage "Unknown option \"$1\"" ;; # *) break ;; # end of user options # esac # shift # next option # done [ $# -eq 0 ] && Usage "Missing im_function" [ $# -eq 1 ] && Usage "Missing output filename" [ $# -gt 2 ] && Usage "Too many arguments" input=$1 output=$2 # --------------------------------------------- [ -f ./generate_options ] && source ./generate_options [ -f ../generate_options ] && source ../generate_options [ -f ../../generate_options ] && source ../../generate_options [ "$page_bg_color" ] || page_bg_color=LightSteelBlue # Gnuplot of a Level function #im_func='-sigmoidal-contrast 8x50%' #name=x: ( echo "set terminal png size 340,160" # subtract 40 for trim size echo 'unset key' echo 'set format ""' #echo 'set ytics ( 0.25, 0.5, 0.75 ) scale 4' #echo 'set xtics ( 30, 60, 90 ) scale 4' #echo -n 'plot [0:119][0:1] "-" binary format="%ushort" endian=swap' #echo ' array=120 using ($1/65535) with lines' #convert -size 1x120 gradient: -rotate 90 $im_func -depth 16 gray:- #echo 'set xtics ( 300, 600, 900 ) scale 4' echo 'plot "-" using 0:($3/65535) with lines' convert "$1" +repage -gravity center -crop 0x1+0+0 -depth 16 txt:- |\ tail -n+2 | tr -sc '0-9\n' ' ' ) | gnuplot | \ convert -background $page_bg_color -bordercolor $page_bg_color \ "$1" +repage -gravity center -crop 0x1+0+0 +resize -resize 298x8\! \ -size 1x8 xc:black \( +clone \) -insert 0 +append \ -size 300x1 xc:black -append \ \( - -trim +repage \) +swap -append \ $output [ -f $output ] && chmod 644 $output