# ImageMagick delegates for Unix.  The format is as follows.  Each
# delegate begins with a tag and/or format separated by a operator tag
# (<=, <=>, =>).  This line must be followed by one or more commands
# preceded with a tab (\t) character.  If a command exceeds the length of
# a line, use the backslash continuation character.  End the command with
# an ampersand (&) to execute the command in the background.
# 
# Optionally you can include the image filename, type, width, height, or
# other image attributes by embedding special format characters:
# 
#   %b   file size
#   %d   directory
#   %e   filename extention
#   %f   filename
#   %h   height
#   %i   input filename
#   %l   label
#   %m   magick
#   %n   number of scenes
#   %o   output filename
#   %p   page number
#   %q   quantum depth
#   %s   scene number
#   %t   top of filename
#   %u   unique temporary filename
#   %w   width
#   %x   x resolution
#   %y   y resolution
#   %z   data written to this file is discarded
# 
# There are three types of delegates: decode, encode, and bypass.  Decode
# delegates begin with a image format (tag) specified (e.g. mpeg) followed
# with a equal-greater sign (=>).  The delegate is invoked whenever ImageMagick
# attempts to read an image whose format specifier or filename extension
# matches the tag (e.g.  image.mpg for tag mpg=>).  The delegate must
# write an image to the file designated by %o in an image format that
# ImageMagick understands (e.g. pnm).
# 
# An encode delegate begins with an image format, a less-equal sign (<=),
# and a tag.  The delegate is invoked whenever ImageMagick attempts to
# write an image whose format specifier or filename extension matches the
# tag (e.g. image.mpg for tag <=mpg).  ImageMagick writes to a temporary
# file in the format you specify.  The delegate can then read this file
# and convert it to a format it supports and presumably ImageMagick does
# not.
# 
# If you use a less-equal-greater sign (<=>) the delegate bypasses
# ImageMagick and directly converts the image file if it is untainted
# (no image manipulations such as resize or rotation).
# 
# Lines that begin with a pound sign (#) are comments and are ignored.
# 
# There are a number of delegates used by ImageMagick for special
# circumstances.  For example, the print or Ghostscript delegate.  Don't
# remove these or ImageMagick may behave strangely.
# 
# ImageMagick looks for the delegate configurarion file in this order:
# 
#     /usr/local/share/ImageMagick/delegates.mgk
#     MAGICK_DELEGATE_PATH/delegates.mgk
#     HOME/.magick/delegates.mgk
#     ./delegates.mgk
# 
# where MAGICK_DELEGATE_PATH and HOME are environment variables.
# 
# Like entries in the later two directory overrides the specification in
# the system-wide delegates file.
#
#

<=bzip
	|bzip2 -f > %o

<=compress
	|compress -c > %o

<=show
	display -immutable -window_group %g -title "%l of %f" tmp:%o &

<=zip
	|gzip -cf > %o

browse=>
	netscape http://www.simplesystems.org/ImageMagick/ &

bzip=>
	|bzip2 -cd "%i"

cgm=>
	ralcgm -d ps "%i" %o %u
	convert -concatenate %o*.ps %o

compress=>
	|uncompress -c "%i"

dot=>
	dot -Tps "%i" -o %o 

dvi=>
	dvips -q -o %o "%i"

edit=>
	xterm -title "Edit Image Comment" -e vi %o

emf=>
	wmftopng "%i" %o

eps<=>pdf
	gs -dMaxBitmap=300000000 -sDEVICE=pdfwrite -q -dNOPAUSE -dSAFER \
	  -sOutputFile="%o" -- "%i" -c quit

eps<=>ps
	gs -dMaxBitmap=300000000 -sDEVICE=pswrite -q -dNOPAUSE -dSAFER \
	  -sOutputFile="%o" -- "%i" -c quit

fig=>
	fig2dev -L ps "%i" %o

# Gnuplot format (rendered as Postscript)
# Add additional gnuplot commands to the input file to adjust output.
gplt=>
	echo "set size 1.25,0.62; set terminal postscript portrait color solid; set output '%o'; load '%i'" > %u
	gnuplot %u

gs-color=>
	gs -dMaxBitmap=300000000 -sDEVICE=pnmraw -q -dNOPAUSE -dSAFER \
	  -dTextAlphaBits=%u -dGraphicsAlphaBits=%u -g%s -r%s %s \
	  -sOutputFile="%s" -- "%s" -c quit

gs-mono=>
	gs -dMaxBitmap=300000000 -sDEVICE=pbmraw -q -dNOPAUSE -dSAFER \
	  -dTextAlphaBits=%u -dGraphicsAlphaBits=%u -g%s -r%s %s \
	  -sOutputFile="%s" -- "%s" -c quit

hpgl=>
	hp2xx -q -m eps -f `basename %o` "%i"
	mv `basename %o` %o

htm=>
	html2ps -U -o %o "%i"

html=>
	html2ps -U -o %o "%i"

ilbm=>
	ilbmtoppm "%i" > %o 

man=>
	groff -man -Tps "%i" > %o

mpeg=>
	mpeg2decode -q -b "%i" -f -r -o3 %o%%05d
	convert -concatenate %o*.ppm %o

mpg=>
	mpeg2decode -q -b "%i" -f -r -o3 %o%%05d
	convert -concatenate %o*.ppm %o

m2v=>
	mpeg2decode -q -b "%i" -f -r -o3 %o%%05d
	convert -concatenate %o*.ppm %o

pdf<=>eps
	gs -dMaxBitmap=300000000 -sDEVICE=epswrite -q -dNOPAUSE -dSAFER \
	  -sOutputFile="%o" -- "%i" -c quit

pdf<=>ps
	gs -dMaxBitmap=300000000 -sDEVICE=pswrite -q -dNOPAUSE -dSAFER \
	  -sOutputFile="%o" -- "%i" -c quit

pgp=>
	pgpv -fq "%i"

pnm<=ilbm
	ppmtoilbm -24if "%i" > %o

pnm<=launch
	gimp "%i"

pnm<=win
	display -immutable "%i"

pov=>
	povray "+i%i" +o%o +fn%q +w%w +h%h +a -q9 -kfi%s -kff%n
	convert -concatenate %o*.png %o

ps<=>eps
	gs -dMaxBitmap=300000000 -sDEVICE=epswrite -q -dNOPAUSE -dSAFER \
	  -sOutputFile="%o" -- "%i" -c quit

ps<=>pdf
	gs -dMaxBitmap=300000000 -sDEVICE=pdfwrite -q -dNOPAUSE -dSAFER \
	  -sOutputFile="%o" -- "%i" -c quit

ps<=print
	/usr/bin/lpr "%i"

rad=>
	ra_ppm -g 1.0 "%i" %o

rgba<=rle
	mogrify -flip -size %wx%h "rgba:%i"
	rawtorle -w %w -h %h -n 4 -o %o "%i"

scan=>
	scanimage -d "%i" > %o

shtml=>
	html2ps -U -o %o "%i"

txt<=>ps
	enscript -o %o "%i"

wmf=>
	wmftopng "%i" %o

xcf=>
	xcftopnm "%i" > %o 

yuv<=m2v
	mpeg2encode %u %o
	convert -concatenate "%i*.yuv" %u

yuv<=mpeg
	mpeg2encode %u %o
	convert -concatenate "%i*.yuv" %u

yuv<=mpg
	mpeg2encode %u %o
	convert -concatenate "%i*.yuv" %u

zip=>
	|gzip -cdfq "%i"
