#!/bin/csh -f # Usage: ps_no_bleedthrough ps_file # # Ferret PostScript files that contain shaded or filled regions # often yield poor results upon conversion to PNG, GIF, etc. with # antialiasing, since the edges of interior rectangles are blended # with the background color. This produces "stripes" or a "grid" # of the background color "bleeding through" the shaded areas. # This script reduces this effect, by slightly altering the PostScript. # Result goes to standard output. # # Authors: Andrew Wittenberg, Rong Zhang # Version dated 17 October 2014 # get list of all arguments set args = ($*) # if not enough arguments, complain. if ($#args < 1) then echo "Usage: ps_no_bleedthrough ps_file" echo echo "Reduces bleed-through of PostScript background color when converting" echo "to an antialiased rasterized image (PNG, GIF, etc.)." echo "Result goes to standard output." echo 'If input file is "-", use standard input.' echo echo "Example: ps_no_bleedthrough myfile.ps > myfile_new.ps" echo echo "NOTE: Will change any Ferret pattern overlays to solid color!" exit 1 endif if ($1 == "-") then set ifile = "" else set ifile = $1 endif sed -e 's,^/cp {closepath} def$,/cp {closepath gsave fill grestore stroke} def,' \ -e '/\/rect {/,/} def/ s,^ cp$,% cp,' $ifile