Branch: Tag:

2006-11-14

2006-11-14 16:25:23 by Tor Edvardsson <tor.edvardsson@gmail.com>

Added support to force use of Ghostscript and some options.

Rev: lib/modules/_Image_PS.pmod:1.11

2:      //! @appears Image.PS   //! Codec for the Adobe page description language PostScript. - //! Uses Ghostscript for decoding. + //! Uses Ghostscript for decoding or built-in support.      static string find_in_path( string file )   {
26:   //! Path to the Ghostscript binary to be used. If missing   //! the environment paths will be searched for a file "gs"   //! to be used instead. + //! @member int(0..1) "force_gs" + //! Forces use of Ghostscript for EPS files instead + //! of Pikes native support. + //! @member int(0..1) "eps_crop" + //! Use -dEPSCrop option to Ghostscript to crop the + //! BoundingBox for a EPS file. + //! @member int(0..1) "cie_color" + //! Use -dUseCIEColor option to Ghostscript for + //! mapping color values through a CIE color space.   //! @endmapping   object decode( string data, mapping|void options )   {
44:    }    if(data[0..3] != "%!PS")    error("This is not a postscript file!\n"); +  +  if(!options) options = ([]); +  if(!options->force_gs) +  {   #if 1    if (has_prefix(data, "%!PS-Adobe-3.0 EPSF-3.0")) {    int width, height, bits, ncols;
101:    }    // return 0;   #endif +  }    -  if(!options) options = ([]); +     int llx, lly;    int urx, ury;   
112:    Stdio.File fd3 = Stdio.File();    object fd4 = fd3->pipe();    -  if(sscanf(data, "%*s%%%%BoundingBox: %s%*[\r\n]", string bbox) == 3) +  if(sscanf(data, "%*s%%%%BoundingBox: %s%*[\r\n]", string bbox) == 3 && !options->eps_crop)    {    int x0,x1,y0,y1;    sscanf(bbox, "%d %d %d %d", x0,y0,x1,y1 );
128:    "-sDEVICE="+(options->device||"ppmraw"),    // "-sPAPERSIZE=a8",    "-r"+(options->dpi||100), -  "-dNOPAUSE", +  "-dNOPAUSE"}); +  +  if(options->eps_crop) +  command += ({"-dEPSCrop"}); +  +  if(options->cie_color) +  command += ({"-dUseCIEColor"}); +  +  command += ({    "-sOutputFile=-",    "-", -  "-c quit 2>/dev/null" -  }); +  "-c quit 2>/dev/null"});       Process.Process pid = Process.create_process( command, ([    "stdin":fd,