[OS X TeX] GhostScript assistance needed!

Siep Kroonenberg siepo at cybercomm.nl
Thu Apr 27 16:41:10 EDT 2006


On Wed, Apr 26, 2006 at 01:49:32PM +0200, Peder Axensten wrote:
> On 24 apr 2006, at 15.45, Piet van Oostrum wrote:
>
> >>>>>>Peder Axensten <peder at axensten.se> (PA) wrote:
> >
> >>PA> I need to use Ghost Script (without any perl scripts or  
> >>similar) to
> >>PA> convert an .eps file to .pdf. Normally I do this with  
> >>epstopdf, but  now I
> >>PA> need a more independent way of doing it using only GS. How   
> >>would the
> >>PA> command look like? (Why is epstopdf needed anyway? Must be  an  
> >>awfully
> >>PA> complicated GS command...)
> >
> >epstopdf extracts the bounding box from the EPS file and prefixes  
> >the file
> >with some additional Postscript code to shift the lower left corner to
> >(0,0) and to set the pagesize to the size of the EPS. After that  
> >the gs
> >command is quite simple:
> >
> >gs -q -sDEVICE=pdfwrite -dAutoRotatePages=/None - 
> >sOutputFile='$OutputFilename' '$InputFilename' -c quit
> 
> This can all be done without epstopdf with the option -dEPSCrop, I've  
> just found out:
> 
> gs  -q -dNOPAUSE -dBATCH -dEPSCrop -sOutputFile='OutputFilename.pdf'  
> 'InputFilename.eps'
> 
> 
> Is there a way to change the color space of the pdf to cmyk, rgb, or  
> gray-scale?
> -dProcessColorModel=... and -sProcessColorModel=... don't seem to work?
> 
> Is there a way to output cmyk png and jpeg files?
> 
> Any help appreciated.
> 
> /Peder

You can feed gs first a color-redefining header file, say
makegray.pro and then the actual source:

gs  -q -dNOPAUSE -dBATCH -dEPSCrop -sOutputFile='OutputFilename.pdf' \
 makegray.pro 'InputFilename.eps'

Success is not guaranteed: it won't work for bitmapped data, and
there are a lot of color models to redefine. The following header
file tries to convert cmyk and rgb to gray:

%!
%%%%<< /ProcessColorModel /DeviceGray >> setpagedevice
userdict begin
% .11*B + .59*G + .3*R
/setrgbcolor {
  0.11 mul exch 0.59 mul add exch 0.3 mul add
  systemdict begin setgray end
} def
% 1.0 - min(1.0, .3*C + .59*M + .11*Y + B)
/setcmykcolor {
  exch 0.11 mul add
  exch 0.59 mul add
  exch 0.3 mul add
  dup 1 gt {pop 1} if
  1 exch sub
  systemdict begin setgray end
} def
end

If you want to output bitmapped data: if you type `gs -h' then
ghostscript will list all available output devices and -file
formats. The ESP version of ghostscript appears to support a
truckload of additional formats.

-- 
Siep Kroonenberg
------------------------- Info --------------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
          & FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Archive: http://tug.org/pipermail/macostex-archives/




More information about the MacOSX-TeX mailing list