ps2eps/0000755000570200017500000000000011766326360011307 5ustar blessblessps2eps/doc/0000755000570200017500000000000011766326360012054 5ustar blessblessps2eps/doc/src/0000755000570200017500000000000011766326360012643 5ustar blessblessps2eps/doc/src/ps2eps.sgml0000644000570200017500000006342011766326360014750 0ustar blessbless Roland"> Bless"> May 7, 2010"> 1"> roland at bless.de"> ps2eps"> ps2eps"> Debian"> GNU"> GPL"> ]>
&dhemail;
&dhfirstname; &dhsurname; 2009 &dhusername; &dhdate;
&dhucpackage; &dhsection; &dhpackage; convert PostScript to EPS (Encapsulated PostScript) files &ps2eps; psfile1 psfile2 ... DESCRIPTION This manual page documents &ps2eps; version &ps2epsver;. &ps2eps; is a tool (written in Perl) to produce Encapsulated PostScript Files (EPS/EPSF) from usual one-paged Postscript documents. It calculates correct Bounding Boxes for those EPS files and filters some special postscript command sequences that can produce erroneous results on printers. EPS files are often needed for including (scalable) graphics of high quality into TeX/LaTeX (or even Word) documents. Without any argument, ps2eps reads from standard input and writes to standard output. If filenames are given as arguments they are processed one by one and output files are written to filenames with extension .eps. If input filenames have the extension .ps or .prn, this extension is replaced with .eps. In all other cases .eps is appended to the input filename. Please note that PostScript files for input should contain only one single page (you can possibly use the psselect from the psutils package to extract a single page from a document that contains multiple pages). If BoundingBox in output seems to be wrong, please try options or . See also section TROUBLESHOOTING. OPTIONS &ps2eps; follows the usual &gnu; command line syntax, with long options starting with two dashes (`-'). A summary of options is included below. , Show summary of options. , Show version of program. , Force overwriting existing files. &ps2eps; will not overwrite files by default to avoid deleting original EPS files accidently. , quiet operation (no output while processing files, except errors). , do not insert any postscript code. Normally a few postscript instructions are added around the original postscript code by &ps2eps; which can be turned off by this option. , do not filter %%Orientation: header comment. , do not try to fix postscript code by filtering some instructions. , remove preview image (smaller file, but no preview anymore). , fix postscript code unconditionally. Otherwise, filtering is usually triggered by detection of certain drivers only. , preserve document structure comments. , insert postscript code for clipping. Unless is specified, the HiResBoundingBox (enlarged by 0.1 points) is used for clipping. , use black/white bitmap as base for calculation (default: off). , =pagedim where pagedim is a pre-defined standard page size (e.g., a4,a0,b0,letter,...) or explicitly specified in a format pagedim:=XxY[cm|in], where X and Y are numbers (floating points are accepted) followed by units centimeter (cm) or inch (in), (default: cm). Use to list pre-defined pagesizes. See also environment variable PS2EPS_SIZE. , specify an x,y offset (may be negative) in postscript points (1/72 dpi) for drawing. This option may be required if your drawing has negative coordinates which usually lets &gs; cut the negative part of your picture, because it starts to render at positive coordinates. The resulting output will also be shifted. , specify a resolution in dpi (dots per inch) for drawing under ghostscript. Default resolution is 144 dpi which is the double of the typical 72 dpi. This option may help if there is a hardware dependent resolution encoded in the postscript, e.g., 600dpi. Example: ps2eps -l -r 600 test.ps , This option rotates the resulting EPS output. The parameter direction determines the direction of rotation: + means +90 degrees (clockwise),- means -90 degrees (counter-clockwise), and ^ means 180 degrees (up-side down). , expand the original tight bounding box by one point in each direction. , do not use existing bounding box as page size for rendering. , do not use %%EOF as hint for end of file. Otherwise, &ps2eps; assumes that postscript code ends after the last %%EOF comment, because some drivers add trailing binary garbage code which gets deleted by &ps2eps; by default. , use internal bbox device of &gs; instead of the external C program bbox. The internal bbox device of &gs; generates different values (sometimes even incorrect), so using the provided bbox should be more robust. See also environment variable PS2EPS_GSBBOX. , do not generate a %%HiResBoundingBox comment for output. , increase the accuracy by turning subsample antialiasing on (may be slower) , show licensing information. , show &gs; call. This may be helpful for solving problems that occur during a &gs; call. , show warnings about sanity of generated EPS file. Certain postscript commands should not be contained in an EPS file. With this option set &ps2eps; will issue a warning if it detects at least one of them. TROUBLESHOOTING Based on the given postscript source code (in most cases generated by some postscript printer driver) there are many potential obstacles or problems that may occur when trying to create proper EPS files. Please read this section carefully to be aware of common pitfalls. Incomplete/Clipped Images or how to determine the right size for &gs;. If you have documents that are larger than your &gs; default (usually A4 or US letter), you have to specify the page dimensions explicitly using the option. Otherwise your EPS might be cut off during rasterizing by &gs; resulting in a wrongly calculated bounding box. You can pass all pre-defined page sizes to that &gs; understands. These are currently: 11x17, ledger, legal, letter, lettersmall, archA, archB, archC, archD, archE a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, isob0, isob1, isob2, isob3, isob4, isob5, isob6, b0, b1, b2, b3, b4, b5, c0, c1, c2, c3, c4, c5, c6, jisb0, jisb1, jisb2, jisb3, jisb4, jisb5, jisb6, flsa, flse, halfletter. Unfortunately, all sizes are currently only available in portrait orientation (not landscape). By default, &ps2eps; uses an already given %%BoundingBox from the source file, which often corresponds to the size of the physical page format for which the document was printed. However, you should be aware that this already specified bounding box may be not correct, thus resulting in a wrongly cropped (or even no usable) .eps-file. &ps2eps; can only do as good as &gs; does in rendering the original postscript file (though &ps2eps; even works with negative and fractional values are contained in the original bounding box by using automatic translation). Therefore, if the given bounding box is to small or incorrect anyway, you can ignore the existing bounding box with the option, which will cause &gs; to use its internal default size (or use ). However, if the BoundingBox has negative coordinates, which is not allowed by the specification, &ps2eps; will shift the output to positive values. Hint: to avoid rotating the picture if you have the original drawing in landscape format, you may use the Encapsulated Postscript option in the printer driver which should generate an EPS file (but with a bounding box of the sheet size!). But some Windows printer drivers are drawing the image with an offset from the bottom of the portrait page, so that a part of it is drawn outside the landscape oriented page. In this case, you'll have to specify a square size of the page using the maximum length, e.g., 29.7cm x 29.7cm for an A4 page. Clipping or why gets some of my text deleted above the included .eps file? Some postscript drivers draw a white rectangle from the top left corner of the page to the right lower corner of the object. This may erase some or even all text above your imported/included EPS file, which is very annoying. In order to prevent this, most programs have a clipping option for imported .eps files (within LaTeX you can use \includegraphics*{}) for this purpose. If this is unfortunately not the case, you can use the option of &ps2eps; which will (hopefully) do it for you. Unfortunately, PScript.dll 5.2 (Windows XP) introduced new very badly behaving Postscript code (initclip) which will even override the outer clipping! Thus, a new filter had to be installed in &ps2eps; which will fix it. However, because most programs clip directly on the bounding box, you still may loose some pixels of your image, because the bounding box is described in the coarse resolution of postscript points, i.e. 72 dpi. In order to prevent this, you can use the option or option (for the latter, clipping by the importing program should be disabled then) to allow for a 1 point larger bounding box. clips around a 1 point enlarged bounding box and enlarges the bounding box values by 1 point (you can also combine both options). Included Filters Some postscript sequences, e.g., for using specific printer features (featurebegin ...), are not working well within an .eps file, so &ps2eps; tries to filter them out. But please note that filters for postscript code may not work properly for your printer driver (&ps2eps; was mainly tested with HP and Adobe printer drivers, although it may work for all printers using the PScript.dll). In this case you can try to turn of filtering by using option , or try to find the bad sequence in the postscript code and adapt the filter rule in the &ps2eps; script (variables $linefilter, $rangefilter_begin, $rangefilter_end; linefilter is an expression for filtering single lines, rangefilter_... are expressions that filter all lines between a pattern matching $rangefilter_begin and $rangefilter_end; drop me an e-mail with your modifications). However, things may change as the printer drivers (e.g., PScript.dll) or postscript language evolve. Some applications or drivers generate postscript code with leading or trailing binary code, which often confuses older postscript interpreters. &ps2eps; tries to remove such code, but it may sometimes make a wrong guess about start and end of the real postscript code (drop me an e-mail with a zipped postscript source, see section BUGS). Comment lines or even blank lines are removed (which is the default to make .eps files smaller), which may corrupt your output. Please check the next section how to fix this. &ps2eps; removes blank lines and also <CR> (carriage ceturn \r) at the end of lines. However, nicely formatted postscript code gives a hint by using %%BeginBinary %%EndBinary comments. When &ps2eps; detects these comments it will refrain from any filtering action within the marked binary sections. &ps2eps; filters also %%Orientation: comments by default (you can use option to turn off filtering), because &gs; may automagically rotate images when generating PDF images, which is not desired in most cases. Hint: you can turn off that feature in &gs; unconditionally by specifying -dAutoRotatePages=/None. Corrupted Output Some postscript code may get corrupted when comment lines or even blank lines are removed (which is the default to make .eps files smaller), because those files may contain encoded images which also have a % as first character in a line or use a special comment as end of image delimiter. If this is the case, use the option to prevent filtering comments. Color and memory &ps2eps; supports colored postscript, consequently letting &gs; consume more resources for drawing its bitmap (roughly 6MBytes for an A4 page). bbox is reading the bitmap line by line so it consumes only minimal memory. If you experience problems with memory consumption of &gs;, you may use the option for using a monochrome image. But this will probably result in wrongly determined bounding boxes with colored images, because &gs; has to do black/white dithering and may thus suppress objects drawn in light colors. Another option in case of memory problems and too long run times is to use the much more memory efficient internal &gs bbox by using the option. ENVIRONMENT VARIABLES Please note that a command line option always takes precedence over the related environment variable. The environment variable PS2EPS_SIZE can be used to specify a default page size and take any argument that accepts. Examples: export PS2EPS_SIZE=a0 (bash-like syntax) or setenv PS2EPS_SIZE letter (csh syntax). If the environment variable PS2EPS_GSBBOX is set the internal bbox device of &gs; will be used instead of the external command bbox. Examples: export PS2EPS_GSBBOX=true (bash-like syntax) or setenv PS2EPS_GSBBOX 1 (csh syntax). EXAMPLES The usual call is simply: ps2eps -l file A relatively failsafe call would be (if your postscript is smaller than iso b0 [100cm x 141.4cm] and you have a fast computer with enough memory): ps2eps -l -B -s b0 -c -n file If output is not correct try: ps2eps -l -B -s b0 -F file AUTHOR &ps2eps; was written by &dhusername;. WHY? Other programs like ps2epsi do not calculate the bounding box always correctly (because the values are put on the postscript stack which may get corrupted by bad postscript code) or rounded it off so that clipping the EPS cut off some part of the image. &ps2eps; uses a double precision resolution of 144 dpi and appropriate rounding to get a proper bounding box. The internal bbox device of &gs; generates different values (sometimes even incorrect), so using the provided bbox should be more robust. However, because normal clipping has only a resolution of 1/72dpi (postscript point), the clipping process may still erase parts of your EPS image. In this case please use the option to add an additional point of white space around the tight bounding box. ACKNOWLEDGMENTS Some people contributed code or suggestions to improve &ps2eps;. Here are at least some names (sorry if I forgot your name): Christophe Druet, Hans Ecke, Berend Hasselman, Erik Joergensen, Koji Nakamaru, Hans Fredrik Nordhaug, Michael Sharpe. Special thanks goes to Michael Sharpe from UCSD who suggested a lot of useful features for ps2eps and who fixed bbox to become more precise and robust. An earlier version of this manual page was originally written by Rafael Laboissiere rafael at debian.org for the &debian; system. Thank you Rafael! Permission is granted to copy, distribute and/or modify this document under the terms of the &gnu; Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. BUGS If you experience problems, please check carefully all hints in the section TROUBLESHOOTING first. Otherwise, check for an updated version at or send a gzipped file of relevant postscript source code with your error description and &ps2eps; version number to &dhemail; (please allow some time to reply). SEE ALSO bbox (1), gs (1), ps2epsi (1)
ps2eps/doc/src/bbox.sgml0000644000570200017500000001157611766326360014473 0ustar blessbless Roland"> Bless"> January 22, 2004"> 1"> roland@bless.de"> bbox"> bbox"> Debian"> GNU"> GPL"> ]>
&dhemail;
&dhfirstname; &dhsurname; 2003 &dhusername; &dhdate;
&dhucpackage; &dhsection; &dhpackage; prints out the bounding box of a rawppm or rawpbm image &bbox; rawpbmfile DESCRIPTION &bbox; reads a rawppm or rawpbm file and prints out the bounding box of the image (as postscript comment and in postscript points, i.e. 1/72dpi) as well as the high resolution bounding box. Input is read from standard input if no filename is specified. Example output: %%BoundingBox: 12 253 829 837 %%HiResBoundingBox: 12.500000 253.000000 828.500000 837.00000 &bbox; has only very limited memory requirements as it reads the input line by line and thus needs to store only one picture line in memory. OPTIONS Show summary of options. Show version of program. resolution of picture in dpi loose bounding box (integer bounding box is expanded by 1 point, hires bounding box is expanded by 0.5 points) SEE ALSO ps2eps (1) AUTHOR &bbox; was written by &dhusername;. ACKNOWLEDGMENTS Special thanks goes to Michael Sharpe from UCSD who suggested a lot of improvements for bbox to become more precise and robust, especially for small drawings. An earlier version of this manual page was originally written by Rafael Laboissiere rafael@debian.org for the &debian; system. Thank you Rafael! Permission is granted to copy, distribute and/or modify this document under the terms of the &gnu; Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. BUGS Though the code is quite small and the probability for bugs is now small, there may be some left somewhere between the lines. In case you find one, please send a short description with &bbox; version number to &dhemail; (please allow some time to reply).
ps2eps/doc/src/Makefile0000644000570200017500000000261711766326360014311 0ustar blessbless# -----------------------------------*- mode: Makefile; -*-- # Makefile for ps2eps documentation # ---------------------------------------------------------- # $Id: Makefile 139 2012-06-14 08:40:32Z bless $ # $Source: /home/bless/src/ps2eps/cvs-repository/ps2eps/doc/Makefile,v $ # ---------------------------------------------------------- # `$@' The file name of the target of the rule. # `$%' The target member name, when the target is an archive member. # `$<' The name of the first prerequisite. # `$?' The names of all the prerequisites that are newer than the target, with spaces between them. # `$^' The names of all the prerequisites, with spaces between them. .PHONY: manpages pdf html DOCBOOK_FLAGS=-c /usr/share/sgml/docbook/dtd/catalog DOCBOOK_TO_MAN=docbook2man DOCBOOK_TO_HTML=docbook2html DOCBOOK_TO_PDF=docbook2pdf #needs pdfjadetex MANPAGES=ps2eps.1 bbox.1 PDF=ps2eps.pdf bbox.pdf HTML=ps2eps.html bbox.html all: manpages pdf html manpages: $(MANPAGES) pdf: $(PDF) html: $(HTML) %.pdf : %.1 groff -m mandoc $< | ps2pdf - $@ # when having .1 # $(DOCBOOK_TO_PDF) $(DOCBOOK_FLAGS) $< %.html : %.sgml # groff -m mandoc -Thtml $< >$@ # when having .1 $(DOCBOOK_TO_HTML) $(DOCBOOK_FLAGS) $< mv index.html $@ %.1 : %.sgml $(RM) $@ $(DOCBOOK_TO_MAN) $(DOCBOOK_FLAGS) $< clean: rm $(MANPAGES) $(PDF) $(HTML) manpage.refs manpage.links # -------------------------------------------------------- ps2eps/Latest_is_1.680000644000570200017500000000000011766326360013623 0ustar blessblessps2eps/src/0000755000570200017500000000000011766326360012076 5ustar blessblessps2eps/src/C/0000755000570200017500000000000011766326360012260 5ustar blessblessps2eps/src/C/bbox.c0000644000570200017500000003640411766326360013365 0ustar blessbless/********************************************************************/ /** bbox -- calculates Bounding Box of a pbmraw/ppmraw-picture **/ /** Created: Nov. 1997, revised Feb. 1998, Dec. 1999, June 2009 **/ /** Author: Roland Bless **/ /** Copyright (C) 1998-2009 Roland Bless **/ /** To compile simply use: **/ /** "cc bbox.c -o bbox" or "make bbox" **/ /********************************************************************/ /* * $Id: bbox.c 139 2012-06-14 08:40:32Z bless $ */ /** * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * **/ /* Quoting EPSF Spec: http://partners.adobe.com/public/developer/en/ps/5002.EPSF_Spec.pdf %!PS-Adobe-3.0 EPSF-3.0 %%BoundingBox: llx lly urx ury The four arguments of the bounding box comment correspond to the lower-left (llx, lly) and upper-right (urx, ury) corners of the bounding box. They are expressed in the default PostScript coordinate system. For an EPS file, the bounding box is the smallest rectangle that encloses all the marks painted on the single page of the EPS file. */ #include #include #include #if defined(_WIN32) && !defined(__CYGWIN__) #include /* needed for _setmode() */ #include #endif /********************** * global variables * **********************/ const char *const version= "$Rev: 139 $"; const char *const prgname= "bbox"; const double round_precision= 1e-6; unsigned char bitval[8]= { 1 << 7, 1 << 6, 1 << 5, 1 << 4, 1 << 3, 1 << 2, 1 << 1, 1 }; unsigned int minus_one(const unsigned x) { return (x == 0) ? x : x-1; } unsigned int plus_one(const unsigned x) { return (x == (unsigned int) ~0U) ? x : x+1; } /***************************** readppm_and_calcbb *********************** * input: name, resolution, tight * * output: - (stdout) * * * * Reads a RAWPPM or RAWPBM picture file (name or STDIN) and * * calculates its Bounding Box on-the-fly (line-by-line). * * * * Parameters: * * name: name of the PBMRAW file or NULL (input from stdin) * * resolution: Pixel per Inch (DPI) * * tight: boolean value, if false 1 Postscript Point is added to * each Bounding Box parameter, otherwise the BB is tight * * The Bounding Box is given in Postscript Points (72 dots/inch) * * and printed to stdout * ************************************************************************/ /* calculate the bounding box in postscript points, given a resolution in dpi */ void readppm_and_calcbb(const char *name, const unsigned int resolution, const unsigned char tight) { FILE *inputfile; char inputline[1024]; unsigned char magic_found= 0; int x,y,byte_x,i; const double pt_dpi_dbl= 72.0; unsigned int x_min, x_max, y_min, y_max; unsigned int llx, lly, urx, ury; /* bounding box */ double hllx, hlly, hurx, hury; /* hires bounding box */ unsigned char *image_row, /* ImageRow */ *tmpcolumnbytep; unsigned int width,height; /* Image Size */ unsigned int byte_width; unsigned char stepsize; unsigned char colormax= 0; /* max color value */ unsigned int ui_colormax= 0; /* max color value */ if ( name == NULL ) { inputfile = stdin; name = "- STDIN -"; } else { inputfile = fopen(name,"r"); if ( inputfile == NULL ) { fprintf(stderr,"%s: ERROR -- could not open file %s\n", prgname, name); return; } } /** check for magic number **/ do { fgets(inputline, 1024, inputfile); #ifdef DEBUG fprintf(stderr,"read:[%s]\n",inputline); #endif if ( strcmp(inputline,"P4\n") == 0 ) { stepsize= 1; magic_found= 4; } else if ( strcmp(inputline,"P6\n") == 0 ) { stepsize= 3; magic_found= 6; } } while ( !feof(inputfile) && !magic_found ); if ( !magic_found ) { fprintf(stderr,"%s: ERROR -- %s is not in ppmraw or pbmraw format\n", prgname, name); return; } /** skip comments **/ do { fgets(inputline, 1024, inputfile); #ifdef DEBUG fprintf(stderr,"read:[%s]\n",inputline); #endif if (*inputline == '#') continue; else break; } while ( !feof(inputfile) ); /** read picture size: width, height **/ sscanf(inputline,"%u %u",&width,&height); if ( magic_found == 6 ) /* PPM file has maximum color-component value */ { fgets(inputline, 1024, inputfile); sscanf(inputline,"%u",&ui_colormax); colormax = (unsigned char) ui_colormax; /* this is safer */ } #ifdef DEBUG fprintf(stderr,"\nreading picture: %s size X: %u Y: %u\n",name,width,height); #endif x_min= width>0 ? width-1 : 0; x_max= 0; y_min= height>0 ? height-1 : 0; y_max= 0; if ( magic_found == 4 ) /* PBMRAW = Bitmap */ { /** read raw pbmfile **/ byte_width= width / 8; if (width % 8 != 0) byte_width++; } else /** assume ppm raw **/ { byte_width= width * 3; /* we have RGB, i.e. three bytes for each pixel */ } /* * Now read a raster of Width * Height pixels, proceeding through the image in normal English reading order, * i.e., starting from top left then moving right */ /* we allocate only one line */ image_row= malloc(byte_width); if ( image_row ) { #if defined(_WIN32) && !defined(__CYGWIN__) /* this is really braindead stuff for MSVC */ i= _setmode( _fileno(stdin), _O_BINARY); if (i == -1) fprintf(stderr,"%s: ERROR - Cannot set binary mode for STDIN\n"); #endif for (y= 0; y= width ) break; #ifdef DEBUG printf("(row %04d, %04d): \n",y,x); #endif } } /* end for */ } /* end if magic_found 4 */ else { /* assume PPM */ x= byte_x/3; /* we have 3 bytes per pixel */ #ifdef DEBUG printf("(row %04d, col %04d) byte %04d: \n",y,x,byte_x,colormax); #endif } /* update bounding box */ if ( x < x_min ) x_min= x; if ( x > x_max ) x_max= x; if ( y < y_min ) y_min= y; if ( y > y_max ) y_max= y; #ifdef DEBUG printf("ymin,height:(%04d,%04d) xmin,width:(%04d,%04d)\n", y_min,y_max,x_min,x_max); #endif break; } /* if there are pixels not white */ } /* end for byte_x */ if ( byte_x != byte_width ) { /* there was a pixel with no background color */ tmpcolumnbytep= image_row+byte_width-1; /* inspect this line from the right */ for (byte_x= byte_width-1; byte_x >= 0; byte_x--,tmpcolumnbytep--) { if ( *tmpcolumnbytep != colormax ) /* there are pixels not white */ { if ( magic_found == 4 ) { for (i= 0; i<8 ; i++) { if ( *tmpcolumnbytep & bitval[i] ) { x= byte_x*8+i; if (x >= width) break; #ifdef DEBUG printf("(%04d,%04d): \n",y,x); #endif } } /* end for */ } /* end if magic_found 4 */ else { /* assume PPM */ x= byte_x/3; /* we have 3 bytes per pixel */ } /* update bounding box */ if ( x < x_min ) x_min= x; if ( x > x_max ) x_max= x; if ( y < y_min ) y_min= y; if ( y > y_max ) y_max= y; #ifdef DEBUG printf("ymin,height:(%04d,%04d) xmin,width:(%04d,%04d)\n", y_min,y_max,x_min,x_max); #endif break; } /* if there are pixels not white */ } /* end for byte_x */ } /* if line contained not only background color */ } /* end for y */ #ifdef DEBUG_BOX fprintf(stderr,"(%04d,%04d), (%04d,%04d)\n", x_min,height-y_max,x_max,height-y_min); #endif /* distance from the left edge to the leftmost point */ hllx= (x_min*pt_dpi_dbl)/resolution; /* distance from the bottom edge to the bottommost point */ hlly= ((minus_one(height)-y_max)*pt_dpi_dbl)/resolution; /* distance from the left edge to the righmost point */ hurx= (plus_one(x_max)*pt_dpi_dbl)/resolution; /* distance from the bottom edge to the uppermost point */ hury= ((height-y_min)*pt_dpi_dbl)/resolution; if ( !tight ) { /* distance from the left edge to the leftmost point */ llx= minus_one((unsigned int) ((unsigned long) x_min*72UL)/resolution); /* distance from the bottom edge to the bottommost point */ lly= minus_one((unsigned int) ((unsigned long) (minus_one(height)-y_max)*72UL)/resolution); /* distance from the left edge to the righmost point */ urx= plus_one((unsigned int) ((unsigned long) plus_one(x_max)*72UL)/resolution); /* distance from the bottom edge to the uppermost point */ ury= plus_one((unsigned int) ((unsigned long) (height-y_min)*72UL)/resolution); /* also loosen hires BBox by default precision */ if (hllx-round_precision >= 0.0) hllx-= round_precision; if (hlly-round_precision >= 0.0) hlly-= round_precision; hurx+= round_precision; hury+= round_precision; } else /* tight bounding box */ { /* distance from the left edge to the leftmost point */ llx= (unsigned int) ((unsigned long) x_min*72UL)/resolution; /* distance from the bottom edge to the bottommost point */ lly= (unsigned int) ((unsigned long) (minus_one(height)-y_max)*72UL)/resolution; /* distance from the left edge to the righmost point */ urx= (unsigned int) ((unsigned long) plus_one(x_max)*72UL)/resolution; /* round up if we got a remainder */ if ( (((unsigned long) plus_one(x_max)*72UL) % resolution) != 0 ) urx= plus_one(urx); /* distance from the bottom edge to the uppermost point */ ury= (unsigned int) ((unsigned long) (height-y_min)*72UL)/resolution; if ( (((unsigned long) (height-y_min)*72UL) % resolution) != 0 ) ury= plus_one(ury); } /* skip the rest of the file if any data is still present */ while ( !feof(inputfile) ) { fgets(inputline, 1024, inputfile); } /* give out Bounding Box */ printf("%%%%BoundingBox: %d %d %d %d\n", llx, lly, urx, ury); printf("%%%%HiResBoundingBox: %f %f %f %f\n", hllx, hlly, hurx, hury); } else fprintf(stderr,"%s: ERROR -- not enough memory to read in one row of the picture\n",prgname); fclose(inputfile); free(image_row); } int main(int argc, char **argv) { int i; char *filename= NULL; unsigned int resolution= 72; /* use 72 dpi as default resolution */ unsigned char tight= 1; for (i= 1; i bless.de # ------------------------------------------------------------------- # Additional filtering is performed when Windows generated PostScript files # are processed. Some instructions will otherwise lead to bad output # if EPS-file gets embedded into other PostScript files. # # Requirements: # + perl # + gs (ghostscript supporting pbm output) # + bbox (a little C program [ANSI-C - should work on every platform] # for calculation of the actual BoundingBox) use POSIX; #use warnings; #use Getopt package use Getopt::Long; Getopt::Long::Configure("no_ignore_case"); $prgname= "ps2eps"; if (! -d "/usr/bin") { # we assume that we are running under native windows $ghostscriptname = "gswin32c"; $NULLDEV = "nul"; } else { # Unix or cygwin $ghostscriptname = "gs"; $NULLDEV = "/dev/null 2>&1"; } $bboxver=`bbox >$NULLDEV -V`; $bboxname= ($?== -1) ? "" : "bbox"; $version= '$Id: ps2eps,v 1.68 2010-05-07 19:42:35 bless Exp $'; #' $insertPScode= 1; # Insert surrounding Postscript code $infhandle = STDIN; # Standard input is the default input file $outfhandle = STDOUT; # Standard output is default output if STDIN is input $infname= '-'; $outfname= '-'; $forceoverwrite=0; # do not overwrite existing files $ignoreBB= 0; # ignore existing Bounding Box comment $removeDSC= 1; # remove Adobe document structure comments $removeADO= 1; # remove Adobe printer Driver console Output [Page: ...] $ignoreEOFDSC= 0; # ignore %%EOF DSC hint $removePreview= 0; # remove preview $quiet= 0; # write progress to stdout $resolution= 144; # resolution for bounding box calculation is 2x72 dpi $trytofixps= 1; # try to fix postscript code $forcefixps= 0; # fix postscript code unconditionally if eq 1 $filterorientation= 1;# filter Orientation line $looseBB=''; # default: tight bounding box $clip=0; # do not clip $warnings=0; # do not print warnings concerning postscript sanity $debuggs=0; # no debugging of ghostscript call, turn this on if you want to see the gs call $inch=2.54; # one inch is 2.54cm $fullcolors= 1; # use ppm format (24-bit full color) $trailerseen= 0; # Trailer comment seen? $PSversion="2.0"; # default Postscript Version $PSDSCversion="2.0"; # default Postscript DSC Version $translate_x= 0; # translate by x postscript points $translate_y= 0; # translate by y postscript points $allbinary= 0; # treat postscript as binary do not filter or change stuff $alphaopt=""; # rendering option for ghostscript "-dTextAlphaBits=4 -dGraphicsAlphaBits=4" $hiresprecision=0.5; # amount that is changed of HiresBB in case that looseBB was requested $defaultext = '(ps|prn)'; # default extension $defaultoutext = '.eps'; # default output extension $envname_size = 'PS2EPS_SIZE'; $envname_gsbbox = 'PS2EPS_GSBBOX'; $gpar=""; $known_papersizes="11x17|ledger|legal|letter(small)?|arch[A-E]|a([0-9]|10)|isob[0-6]|b[0-5]|c[0-6]|jisb[0-6]|fls(a|e)|halfletter"; $papersize_help="11x17,ledger,legal,letter,lettersmall,archA,archB,archC,archD,archE\ a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,isob0,isob1,isob2,isob3,isob4,isob5,isob6,\ b0,b1,b2,b3,b4,b5,c0,c1,c2,c3,c4,c5,c6,\ jisb0,jisb1,jisb2,jisb3,jisb4,jisb5,jisb6,flsa,flse,halfletter\n"; $trigger= 0; $notsane= 0; $dummy=""; @ver= split(/ /,$version); # filename for temporary files if ($^O =~ /MSWin32/i or $^O =~ /cygwin/i) { # it is less trouble to use the current directory if working on # cygwin and nevertheless using gswin32c. $tmpfname= "$prgname.$$"; $win=1; } elsif (defined($ENV{'TMP'})) { $tmpdir= $ENV{'TMP'}; $filesep= ($tmpdir =~ /^?\:\\/) ? '\\' : '/'; if ($tmpdir =~ /$filesep$/) { $tmpfname= $tmpdir . "$prgname.$$"; } else { $tmpfname= $tmpdir . "$filesep$prgname.$$"; } $win=1; } else #assume we're on a UNIXBOX { $tmpfname= "/tmp/" . "$prgname.$$"; $win=0; } $licensetxt= "\ This program is free software; you can redistribute it and/or modify\ it under the terms of the GNU General Public License as published by\ the Free Software Foundation; either version 2 of the License, or\ (at your option) any later version.\ \ This program is distributed in the hope that it will be useful,\ but WITHOUT ANY WARRANTY; without even the implied warranty of\ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\ GNU General Public License for more details.\ \ You should have received a copy of the GNU General Public License\ along with this program; if not, write to the Free Software\ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n"; @prgidtxt= ( "$prgname - convert PostScript to EPS (Encapsulated PostScript) files\n", "(C)opyright 1998-2009 Roland Bless\n\n" ); @helptxt= ("Version: $ver[2]\n", "Operation:\n", " Without any argument, $prgname reads from standard input\n", " and writes to standard output.\n", " If filenames are given as arguments they are processed\n", " one by one and output files are written to filenames\n", " with extension '$defaultoutext'. If input filenames have the extension\n", " '.ps' or '.prn', this extension is replaced with '$defaultoutext'.\n", " In all other cases '$defaultoutext' is appended to the input filename.\n", " Please note that PostScript files for input should contain\n", " only one single page.\n\n", " If BoundingBox in output seems to be wrong, please try options --size or --ignoreBB.\n\n" ); @usagetxt= ("Syntax:\n", " $prgname [-f] [-q] [-N] [-O] [-n] [-P] [-c] [-b] [-C] [-m] [-B] [-E] [-s ] [-R +|-|^] [-t ] [-l] [-g] [-d] [-H] [-h|--help] [-g] [-a] [-W] [-L] [-V|--version] [--] [psfile1] [psfile2] [...]\n", "Options:\n", " -f, --force force overwriting existing files\n", " -q, --quiet quiet operation (no output while processing files)\n", " -N, --noinsert do not insert any postscript code\n", " -O, --preserveorientation do not filter Orientation: header comment\n", " -n, --nofix do not try to fix postscript code\n", " -P, --removepreview remove preview image (smaller file, but no preview)\n", " -F, --fixps fix postscript code unconditionally\n", " -c, --comments preserve document structure comments\n", " -b, --binary treat postscript as binary, do not modify characters\n", " -C, --clip insert postscript code for clipping\n", " -m, --mono use black/white bitmap as base for calculation\n", " -s, --size= page size (a0-a10,letter,...) or in format XxY[cm|in] (default:cm), where X and Y are numbers\n", " use --size=list to list pre-defined page sizes\n", " -R, --rotate= rotate resulting EPS. : +=+90 (clockw.),-=-90 (counter-clockw.) ^=180 degrees\n", " -t, --translate specify x,y offset (may be negative) in postscript points (1/72 dpi)\n", " -r, --resolution specify dpi resolution to render with ghostscript (default 144)\n", " -l, --loose expand the original bounding box by one point in each direction\n", " -B, --ignoreBB do not use existing bounding box as page size for rendering\n", " -E, --ignoreEOF do not use %%EOF as hint for end of file\n", " -g, --gsbbox use internal bbox device of ghostscript\n", " -H, --no-hires do not use a HiResBoundingBox\n", " -h, --help help information\n", " -L, --license show licensing information\n", " -V, --version show version information\n", " -d, --debuggs show ghostscript call\n", " -a, --accuracy improve accuracy during rendering (maybe slower)\n", " -W, --warnings show warnings about sanity of generated eps file\n", " -- all following arguments are treated as files\n", " (allows filenames starting with -)\n", "\n", "Arguments:\n", " One or more names of PostScript files for input\n"); ## %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ## -- argument checking -- ## %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% #environment variable for papersize if (defined($ENV{"$envname_size"})) { $opt_s= $ENV{"$envname_size"}; } else { $opt_s = ''; # for s-option } if (defined($ENV{"$envname_gsbbox"})) { $bboxname=""; } $opt_t = ''; # for t-option $opt_R = ''; # for R-option $opt_r = ''; # for r-option $stopnow = 0; die "Wrong option(s), please check usage with $prgname --help\n" unless GetOptions('f|force' => \$forceoverwrite, 'q|quiet' => \$quiet, 'm|mono' => sub { $fullcolors = 0 }, 'n|nofix' => sub { $trytofixps = 0 }, 'F|fixps' => \$forcefixps, 'N|noinsert' => sub { $insertPScode = 0 }, 'O|preserveorientation' => sub { $filterorientation= 0 }, 'P|removepreview' => \$removePreview, 'c|comments' => sub { $removeDSC = 0 }, 'b|binary' => sub { $allbinary = 1 }, 'C|clip' => \$clip, 'l|loose' => sub { $looseBB = '-l' }, 'B|ignoreBB' => \$ignoreBB, 'E|ignoreEOF'=> \$ignoreEOFDSC, 's|size=s' => \$opt_s, 't|translate=s' => \$opt_t, 'r|resolution=s' => \$opt_r, 'R|rotate=s' => \$opt_R, 'g|gsbbox' => sub { $bboxname=""; }, 'H|nohires' => \$nohires, 'h|help' => sub { $stopnow = 1; print @prgidtxt,@helptxt,@usagetxt,"\nAuthor: Roland Bless (roland\@bless.de)\n\n"; }, 'L|license' => sub { $stopnow = 1; print @prgidtxt,$licensetxt,"\nAuthor: Roland Bless (roland\@bless.de)\n\n"; }, 'a|accuracy' => sub { $alphaopt = '-dTextAlphaBits=4 -dGraphicsAlphaBits=4' }, 'd|debuggs' => \$debuggs, 'W|warnings' => \$warnings, 'V|version' => sub { $stopnow = 1; print @prgidtxt,"Version: $ver[2]\n"; });exit if ($stopnow); ## %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ## -- wildcard processing -- ## %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ## internal wildcard processing for current directory, ## only used for non UNIX-based OSs (which may lack shell wildcard expansion) @filenames = (); foreach $object (@ARGV) { if ($win && $object =~ m/\*/o) # asterisk is present in filename { $wildcard = $object; $wildcard =~ s/\./\\\./g; # replace . in pattern with \. $wildcard =~ s/\*/\(\.\*\)/g; # replace * in pattern with (.*) opendir(DIR,'.') || die 'Unable to open current directory, stopped'; # open current directory print STDERR $wildcard; @fid = grep { /$wildcard(\.$defaultext)?/i } readdir(DIR); foreach (@fid) { push @filenames, $_; } closedir DIR; } else { push @filenames, $object; } } # end foreach $filenames[0]= '-' if (scalar(@filenames) == 0); # no file arguments, use STDIN as input print STDERR "Input files: @filenames\n" if (!$quiet); if ($opt_r ne '') { $resolution=$opt_r; } # papersize stuff if ($opt_s ne '') { # if explicit size is given, ignore existing BoundingBox always $ignoreBB = 1; $pagedimension = $opt_s; if ($opt_s eq "list") { print STDERR "Available paper sizes: $papersize_help"; exit 0; } #explicit format XxY[cm|in] if ($pagedimension =~ /(\d*\.?\d+)x(\d*\.?\d+)/) { ($x_dim, $dummy, $y_dim, $unit)= split(/(x|cm|in)/,$pagedimension); if ( $x_dim !~ /^\d*\.?\d+$/ ) { die "$x_dim in $arg is not a valid number, stopped"; } if ( $y_dim !~ /^\d*\.?\d+$/ ) { die "$y_dim in $arg is not a valid number, stopped"; } #print STDERR "xdim: $x_dim ydim: $y_dim unit:$unit\n" ; if (!defined($unit) ) { $unit='cm'; $opt_s=$opt_s . $unit; } if ( $unit ne 'in' ) # assume centimeters { # calculate dimension in pixels (remember: resolution is in dpi) $xpixels= int(($x_dim * $resolution) / $inch)+1; $ypixels= int(($y_dim * $resolution) / $inch)+1; $gpar= "-g${xpixels}x${ypixels}"; } else { $xpixels= int($x_dim * $resolution)+1; $ypixels= int($y_dim * $resolution)+1; $gpar= "-g${xpixels}x${ypixels}"; } } #endif XxY in opt_s else { if ($opt_s =~ /$known_papersizes/) { $gpar="-sPAPERSIZE=$opt_s"; } else { print STDERR "Error: Unknown paper size: $opt_s\n Acceptable papersizes are:$papersize_help\n"; exit 1; } } } #translate option if ($opt_t ne '') { ($translate_x,$translate_y)= split(/\,/,$opt_t); } #rotate $rotright='-90 rotate'; $rotleft='90 rotate'; $rotupsidedown='180 rotate'; $rotate=''; if ($opt_R ne '') { if ($opt_R eq '+') { $rotate=$rotright; } elsif ($opt_R eq '-') { $rotate=$rotleft; } elsif ($opt_R eq '^') { $rotate=$rotupsidedown; } else { die "Wrong parameter for option -R: Valid are only +,-,^\n"; }; } $device= $fullcolors ? "ppmraw" : "pbmraw"; ## %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ## -- iterate over different input files -- ## %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PROCESSFILE: while ($infname= (shift @filenames)) { # reset filter definitions for each file undef $linefilter; undef $rangefilter_begin; undef $rangefilter_end; $fixthisps= $trytofixps; $fixmsgprinted= 0; if (!$quiet) { print STDERR "Processing: $infname\n"; } unless (open($infhandle,"<$infname")) { # skip over this file print STDERR "$prgname: Can't open $infname: $!\n"; next PROCESSFILE; } # buffer input from stdin into temporary file, because it has to be read twice # one time for ghostscript processing, the second time for generating output if ($infname eq '-') # input is stdin { $tmpfhandle=''; open($tmpfhandle,">$tmpfname") or die "Cannot open temporary file $tmpfname for writing: $!\n"; } else # input is not stdin { undef $tmpfhandle; #if filename ends with $defaultext usually .ps or .prn, replace the extension with $defaultoutext if ($infname =~ /\.$defaultext$/i) { $outfname= $infname; $outfname =~ s/\.$defaultext$/$defaultoutext/i; } else # otherwise simply append the extension $defaultoutext { $outfname= $infname . "$defaultoutext"; } } #end else input is not stdin ## %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ## -- process input file -- ## %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% $linefilter= '^$'; #'# filter empty lines by default while (<$infhandle>) { # get postscript and DSC version if (/%!PS-Adobe-(\S+).*EPSF-(\S+)/) { $PSversion=$1; $PSDSCversion=$2; if (! ($PSversion =~ /\d+\.\d+/)) { $PSDSCversion="2.0"; } if (! ($PSDSCversion =~ /\d+\.\d+/)) { $PSDSCversion="2.0"; } } # check for existing BoundingBox parameters if ( /^%%\s*BoundingBox:\s*(.*)/ && !defined($eBBllx) ) { $BBarg= $1; # accept even negative and fractional BBs if ( $BBarg =~ /(\-?\d+\.?\d*\s+){3,}\d+/ ) # ignore %% BoundingBox: (atend) comments { ($eBBllx,$eBBlly,$eBBurx,$eBBury,$dummy)= split /\s/,$BBarg; #print STDERR "Existing BB: $eBBllx,$eBBlly,$eBBurx,$eBBury\n"; if (int($eBBllx) < 0) { $translate_x= - int($eBBllx-0.5); } if (int($eBBlly) < 0) { $translate_y= - int($eBBlly-0.5); } $xpixels= int((($eBBurx-$eBBllx) * $resolution)/72 + 0.5); $ypixels= int((($eBBury-$eBBlly) * $resolution)/72 + 0.5); if (!$ignoreBB) { $gpar= "-g${xpixels}x${ypixels}"; # check for meaningful values if (($xpixels <= 1) || ($ypixels <= 1)) { $gpar=""; undef $eBBllx; undef $eBBlly; } else { if (!$quiet) { print STDERR "Rendering with existing $_"; if (int($eBBllx) < 0 || int($eBBlly) < 0) { print STDERR "WARNING: existing Bounding Box shows negative values - shifting\n"; } } } } #endif !$ignoreBB } #endif $BBarg =~ } if ($fixthisps) # try to fix bad postscript code { # check for Windows 3.x output if ( /^Win.*Dict/ ) { if (!$quiet && !$fixmsgprinted) { print STDERR "Windows 3.5 generated Postscript file detected, fixing\n"; } $linefilter= '^(EJ|RS)'; $rangefilter_begin= '^statusdict'; $rangefilter_end= 'cvx\ settransfer$'; #' $fixmsgprinted= 1; # stop printing message } else { if ( /^%%Creator:\s*Wind.U\s*Xprinter/ ) { if (!$quiet && !$fixmsgprinted) { print STDERR "Star/OpenOffice generated Postscript file detected, fixing\n"; } $linefilter= '^rs'; $fixmsgprinted= 1; # stop printing message } else { if ( $forcefixps || /^\/NTPS/ || /Creator:\s*(AdobePS|Pscript|.*Windows)/i ) #check for NT generated output { if (!$quiet && !$fixmsgprinted) { if ($forcefixps) { print STDERR "Postscript filtering requested, fixing\n"; } else { print STDERR "Windows generated Postscript file detected, fixing\n"; } } $rangefilter_begin= '^((\[\{)|(featurebegin\{))$'; #' $rangefilter_end= '^(\} stopped cleartomark|\}featurecleanup)'; $exclude_rangefilter_begin= '^(?i)%%BeginNonPPDFeature'; #' $exclude_rangefilter_end= '^(?i)%%EndNonPPDFeature'; #$triggered_rangefilter_begin= ''; #' #$triggered_rangefilter_end= ''; #' $fixsearchpat='(^|\s)(initmatrix|initclip|initgraphics)(\s|$)'; $fixreplacepat=' '; $fixmsgprinted= 1; # stop printing message } # end if NTPS } #end else } } #end if trytofixps if (defined($tmpfhandle)) { print $tmpfhandle $_ or die "$prgname: Failure during writing to temporary file $tmpfname"; } if (/^%%EOF\s*$/) { $totalEOFDSC++ } } #end while <$infhandle> if (defined($tmpfhandle)) { close($tmpfhandle); } else { $tmpfhandle= $infhandle; $tmpfname= $infname; } ## %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ## -- calculate the bounding box -- ## %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% if ($translate_x!=0 || $translate_y!=0) { $translation="$translate_x $translate_y translate"; $translatecmd="-c \'$translation\'"; } else { $translation=""; $translatecmd=""; } if (!$quiet) { print STDERR "Calculating Bounding Box..."; if ($opt_s) { print STDERR "using page size $opt_s..."; } } $rotatecmd=''; if ($rotate ne '') { $rotatecmd="-c \"$rotate\"" } if ($bboxname ne '') { $cmdline="$ghostscriptname -dSAFER -dNOPAUSE $alphaopt -q $gpar -r$resolution -sDEVICE=$device -sOutputFile=- $translatecmd -f \"$tmpfname\" -c showpage -c quit | $bboxname -r $resolution"; } else { if (!$quiet) { print STDERR "...using bbox device of $ghostscriptname..."; } $cmdline = "$ghostscriptname -dSAFER -dBATCH -dNOPAUSE -q $gpar -r$resolution -sDEVICE=bbox -sOutputFile=- -c \"/setpagedevice {pop} def\" $translatecmd -f \"$tmpfname\" -c quit 2>&1"; } if ($debuggs) { print STDERR "\nCalling: $cmdline\n"; } # actual ghostscript call $boundingbox=`$cmdline`; if ($debuggs) { print STDERR "Call result: $boundingbox"; } # check result of gs call if ($boundingbox !~ /^%%BoundingBox/m) { die "Error: Could not determine bounding box!\n", "I suppose $ghostscriptname had some trouble interpreting the postscript-file $infname. Exiting now.\n"; } $boundingbox =~ /^%%HiResBoundingBox:\s*(.*)/m; if (defined($1)) # HiResBoundingBox given { ($hcBBllx,$hcBBlly,$hcBBurx,$hcBBury,$dummy)= split(/\s/,$1); $hiresboundingbox="%%HiResBoundingBox: $hcBBllx $hcBBlly $hcBBurx $hcBBury\n"; $cBBllx = floor($hcBBllx); $cBBlly = floor($hcBBlly); $cBBurx = ceil($hcBBurx); $cBBury = ceil($hcBBury); } else { #use normal BoundingBox $boundingbox =~ /^%%.*BoundingBox:\s*(.*)/; ($cBBllx,$cBBlly,$cBBurx,$cBBury,$dummy)= split(/\s/,$1); } # if loose BB is requested # apply changes to resulting bounding box if needed if ($looseBB ne '') { if ($cBBllx > 0) { $cBBllx--; } if ($cBBlly > 0) { $cBBlly--; } $cBBurx++; $cBBury++; if ($hcBBllx-$hiresprecision >= 0.0) { $hcBBllx-= $hiresprecision; } if ($hcBBlly-$hiresprecision >= 0.0) { $hcBBlly-= $hiresprecision; } $hcBBurx+= $hiresprecision; $hcBBury+= $hiresprecision; $hiresboundingbox="%%HiResBoundingBox: $hcBBllx $hcBBlly $hcBBurx $hcBBury\n"; } if ($cBBllx < 0 || $cBBlly < 0) { if (!$quiet) { print STDERR "WARNING! Your drawing had a negative Bounding Box which is deprecated and may cause problems!. I'll shift it.\n"; } $translate_x= -int($cBBllx); $translate_y= -int($cBBlly); $cBBllx=0; $cBBurx= $cBBurx + $translate_x; $cBBlly=0; $cBBury= $cBBury + $translate_y; $hcBBurx= $hcBBurx + $hcBBllx; $hcBBury= $hcBBury + $hcBBlly; $hcBBllx= 0; $hcBBlly= 0; $hiresboundingbox="%%HiResBoundingBox: $hcBBllx $hcBBlly $hcBBurx $hcBBury\n"; $translation="$translate_x $translate_y translate"; $translatecmd="-c \'$translation\'"; } $boundingbox = "%%BoundingBox: $cBBllx $cBBlly $cBBurx $cBBury\n"; if (!$quiet) { print STDERR "ready. $boundingbox" }; $before_startps= 1; $inserted_prolog= 0; $prolog_passed= 0; ## %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ## -- Create output file -- ## %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% if (!$quiet) { print STDERR "Creating output file $outfname ... "; } if (!$forceoverwrite and -s "$outfname") { die "$prgname: Sorry, file named $outfname already exists,", " will not overwrite it.\n", " You will have to use the -f option, delete it or rename it", " before running $prgname again.\n"; } else { open($outfhandle,">$outfname") or die "Can't open file $outfname for writing: $!\n"; } open($tmpfhandle,"<$tmpfname") or die "Cannot open file $tmpfname for reading"; CREATEOUTPUT: while (<$tmpfhandle>) { # check whether we are in a binary section $binarysection=$allbinary || (/^(%%Begin(Binary|Data))|(beginimage)\r?\n?$/ ... /^(%%End(Binary|Data))|^(endimage)/) || (/^(doNimage)|(doclutimage)\r?\n?$/ ... /(^|~> )Z\r?\n?$/) || # Pscript_Win_Dib_L2 5.0 0 (/^beginjpeg / ... /~> endjpeg\r?\n?$/) || # Pscript_Win_Dib_L2 5.0 0 (/^pdfIm/ ... /^%-EOD-/); if ( !$binarysection ) { s/\r?\n?$//; # remove CR and/or LF at end of line if not in binary section } # check where magic Postscript header starts - skip leading binary stuff, e.g., HP PCL/PJL code if ($before_startps) { if ( /%!/ ) # This is usually the smallest magic sequence { # Note: Adobe Photoshop generated a binary heading, so ^ is not applicable # %! may be part of a binary sequence, but then control characters follow # so skip %! if non alphanumeric characters follow if ( ! /%!.*[^\w]{2,}/ ) { # some heading without two control characters found $before_startps= 0; if (! /%!PS-Adobe.*/i) # some strange programs use other magics { print STDERR "** Warning **: Weird heading line -- ",$_," -- "; } } } next CREATEOUTPUT; } else # we are hopefully in regular postscript code now { # count %%EOFs as we want to know when we got the last EOF if ( /^%%EOF\s*$/ ) { $seenEOF++; } # We should insert our own prologue including the newly calculated BoundingBox if (! $inserted_prolog) { print $outfhandle "%!PS-Adobe-$PSversion EPSF-$PSDSCversion\n"; # check if we need to rotate $transrotcmd=''; if ($rotatecmd) { if ($rotate eq $rotright) { $transrotcmd="-$cBBlly $cBBurx translate"; $boundingbox='%%BoundingBox: 0 0 ' . ($cBBury-$cBBlly) . ' ' . ($cBBurx-$cBBllx) . "\n"; if ($hiresboundingbox ne "") { $hiresboundingbox='%%HiResBoundingBox: 0 0 ' . ($hcBBury-$hcBBlly) . ' ' . ($hcBBurx-$hcBBllx) . "\n"; } } elsif ($rotate eq $rotleft) { $transrotcmd="$cBBury -$cBBllx translate"; $boundingbox='%%BoundingBox: 0 0 ' . ($cBBury-$cBBlly) . ' ' . ($cBBurx-$cBBllx) . "\n"; if ($hiresboundingbox ne "") { $hiresboundingbox= '%%HiResBoundingBox: 0 0 ' . ($hcBBury-$hcBBlly) . ' ' . ($hcBBurx-$hcBBllx) . "\n"; } } elsif ($rotate eq $rotupsidedown) { $transrotcmd="$cBBurx $cBBury translate"; $boundingbox='%%BoundingBox: 0 0 ' . ($cBBurx-$cBBllx) . ' ' . ($cBBury-$cBBlly) . "\n"; if ($hiresboundingbox ne "") { $hiresboundingbox='%%HiResBoundingBox: 0 0 ' . ($hcBBurx-$hcBBllx) . ' ' . ($hcBBury-$hcBBlly) . "\n"; } } } print $outfhandle $boundingbox; if (!defined($hiresboundingbox)) { $nohires=1; } if (defined($hiresboundingbox) && !defined($nohires)) { print $outfhandle $hiresboundingbox; } $inserted_prolog= 1; redo CREATEOUTPUT; } else # already inserted_prolog { if (! $prolog_passed) { #ignore the following lines in the prologue if ( /^%%(HiRes)?BoundingBox/ || /^%%Pages/ || /^%%BeginProlog/ || /^%%EndProlog/ || ($filterorientation && /^%%Orientation/) || ($removeDSC && /^%%.*: \(atend\)/) || ($removePreview && (/^%%BeginPreview/ ... /^%%EndPreview/)) ) { next CREATEOUTPUT; } else { if ( /^[^%].*/ || /^%%EndComments/ ) # line is not a comment { #output postscript code for proper EPS file if ($insertPScode) { print $outfhandle "%%EndComments\n", "% EPSF created by ps2eps $ver[2]\n", "%%BeginProlog\n"; } # Insert own postscript code for clipping if ($clip) { if (!defined($nohires)) { printf $outfhandle "newpath %f %f moveto %f %f lineto %f %f lineto %f %f lineto closepath clip\n",$hcBBllx,$hcBBlly,$hcBBurx,$hcBBlly,$hcBBurx,$hcBBury,$hcBBllx,$hcBBury; } else { printf $outfhandle "newpath %d %d moveto %d %d lineto %d %d lineto %d %d lineto closepath clip\n",$cBBllx,$cBBlly,$cBBurx,$cBBlly,$cBBurx,$cBBury,$cBBllx,$cBBury; } } #endif clip if ($rotate ne '') { print $outfhandle "$transrotcmd\n"; print $outfhandle "$rotate\n"; } if ($translation ne '') { print $outfhandle "$translation\n"; } #insert surrounding postscript code if ($insertPScode) { print $outfhandle "save\n", "countdictstack\n", "mark\n", "newpath\n", "/showpage {} def\n", "/setpagedevice {pop} def\n", "%%EndProlog\n", "%%Page 1 1\n"; } $prolog_passed= 1; if (/^%%EndComments/) { next CREATEOUTPUT; } } #endif line is not a comment } #end else } #endif (we are in the prologue section) else #we are in the main part of postscript file { #end of postscript file reached? #Usually the DSC %%EOF signifies the end if ( eof($tmpfhandle) || ($ignoreEOFDSC == 0 && /^%%EOF\s*$/ && $seenEOF == $totalEOFDSC) || ( $trailerseen && /^II\*\000.*/ ) ) { #do not forget to print last line if not terminated by LF if ( eof($tmpfhandle) && !/^$/ && !/^%%EOF\s*$/ ) # do not insert %%EOF twice { print $outfhandle $_,"\n"; } #add appropriate trailer if ($insertPScode) { print $outfhandle "%%Trailer\n", "cleartomark\n", "countdictstack\n", "exch sub { end } repeat\n", "restore\n", "%%EOF\n"; } last CREATEOUTPUT; } # stop output # Trailer comment seen? if ( /^%%Trailer\s*$/ ) { $trailerseen=1; } else { if (!/^\s*$/) #non empty lines follow { $trailerseen=0; } } # check for trigger if (defined($triggerstring) && /^$triggerstring$/) { $trigger= 1; }; # remove complete lines if one of the expression matches if ( !$binarysection # only when not in binary section && ( ($removePreview && (/^%%BeginPreview/ ... /^%%EndPreview/)) || # no preview (defined($rangefilter_begin) && (/$rangefilter_begin/ ... /$rangefilter_end/) && (!(/$exclude_rangefilter_begin/ ... /$exclude_rangefilter_end/)) ) || (defined($triggered_rangefilter_begin) && defined($triggered_rangefilter_end) && $trigger && (/$triggered_rangefilter_begin/ ... /$triggered_rangefilter_end/) ) || /$linefilter/ # lines by linefilter || ($removeDSC && (/^%( |!)(\w )+/ || /^%%([A-Za-z]+\s)/)) # any type of structured comment || ($removeADO && (/^statusdict begin.*ProductName.*print product print.*flush end\r?\n?$/ || /^\(%%\[\s*(Page:.*|LastPage)\s*\]%%\)\s*=\s*\w*\s*\r?\n?/ )) || /^$/ # empty lines ) ) { next CREATEOUTPUT; } # replacement if ( defined($fixsearchpat) ) { #if (/$fixsearchpat/) { print STDERR "**filter** before:",$_,"\n"; } #if (s/$fixsearchpat/$fixreplacepat/) { print STDERR "**filter** after:",$_,"\n";} s/$fixsearchpat/$fixreplacepat/; } # sanity check for potential dangerous commands if ( /(^|\s)(clear|erasepage|initmatrix|initclip|initgraphics|startjob|cleardictstack|setmatrix|setpagedevice|copypage|grestoreall|exitserver|quit)(\s|$)/ ) { $notsane= 1; #print STDERR "Warning: dangerous command in line: ",$_,"\n"; } } # end else (this is main part) # Output the postscript line to result file print $outfhandle $_; if (!$binarysection) { print $outfhandle "\n"; # terminate line with LF } } # end else prolog_passed } # end else inserted_prolog } # end while CREATEOUTPUT close($tmpfhandle); if ($tmpfname ne $infname) { unlink "$tmpfname"; } #remove temporary file close ($outfhandle); # print warning if magic sequence not found if ( $before_startps ) { print STDERR "\n ** Error!! **: could not identify begin of postscript code in file $infname, please check header line!\n First line should start with %!. No output generated.\n"; } if (!$quiet) { print STDERR "ready.\n"; } if ($warnings and $notsane and !$quiet) { print STDERR "** Warning **: EPS-output for $infname is not sane, at least one\n", "of the following commands was still present:\n", "clear erasepage initmatrix initclip initgraphics startjob\n", "cleardictstack setmatrix setpagedevice copypage grestoreall\n", "exitserver quit\n"; } } #end while PROCESSFILE # ---- end of perl-script ------- ps2eps/README.txt0000644000570200017500000000304311766326360013005 0ustar blessblessDOCUMENTATION ============= Please see documentation in the manpage or doc/ sub directory. Note that the manpage may have an older version number in it, which is nothing to worry about since there may have been minor changes incorporated into ps2eps not requiring any update of the documentation. INSTALLATION ============ Please see instructions in separate text file INSTALL.txt UPDATES ======= Possibly you can find the newest version at the following URL: http://tm.kit.edu/~bless Contact information: Roland Bless, roland bless.de If you have problems, please send a gzipped file of relevant postscript code with your error description and ps2eps version number. License: This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --------------------------------------------------------------------------- End of README.txt --------------------------------------------------------------------------- ps2eps/INSTALL.txt0000644000570200017500000000460011766326360013156 0ustar blessblessINSTALLATION ------------ * Prerequisites you need: - perl (an interpreter for the perl language, see http://www.perl.com) - ghostscript (an interpreter/raster image processor for the PostScript language, see http://pages.cs.wisc.edu/~ghost/) - maybe an ANSI-C compiler if the provided binaries for bbox do not work for you. Sorry for the inconvenience, but I tried to write a bbox equivalent in perl and it was terribly slow. Therefore I stick to C, because of much better performance. ALTERNATIVELY you can use ps2eps option -g, then no bbox binary is required. * How to install Please check that you have working perl and ghostscript packages. Linux/UNIX-based platform ========================= 1.) install bbox If a bbox binary is included for your platform you simply move it into any directory of the system search path. Otherwise, you have to compile bbox.c first by invoking cc -o bbox bbox.c. (sometimes "make bbox" also works). Please make sure that bbox is executable (chmod a+x bbox). If you already have a working perl and a working ghostscript, you're finished here, else you have to install them first. 2.) install ps2eps On Unix platforms you simply move the perl script ps2eps into a directory which is included in the system or personal search path (e.g., /usr/local/bin, $home/bin). Please make sure that ps2eps is executable (chmod a+x ps2eps). Windows-based platform ====================== Use the command line interpreter: Copy bbox.exe from bin/win32/ directory into a directory that is in your's or the system's search path for executables. Please try to invoke bbox -h afterwards. The best possibility is to use associated file types under Windows NT/2000/XP: 1.) rename ps2eps to ps2eps.pl and 2.) SET PATHEXT=.pl;%PATHEXT% or use the settings -> control panel -> system -> "advanced" tab -> environment variables and edit the PATHEXT entry accordingly. 3.) then simply typing ps2eps should invoke ps2eps correctly Another option is to call perl directly: perl ps2eps ... The script assumes that you have "gswin32c" as postscript interpreter in your path. Under Windows ps2eps can perform wildcard expansion now on its own. UPDATES ------- Possibly you can find the newest version at the following URL: http://tm.uka.de/~bless/ps2eps ps2eps/Changes.txt0000644000570200017500000002757611766326360013441 0ustar blessbless---------------------------- Detailed Change Log: ---------------------------- revision 1.68 date: 2010-05-07 21:42:35 +0200; author: bless; state: Exp; lines: +3 -3; - quoted translate command string ---------------------------- revision 1.67 date: 2009-12-05 23:44:19 +0100; author: bless; state: Exp; lines: +39 -33; - quote of tmpfname for coping with spaces in filenames - added -a option - changed handling of hiresBB (now rounded to hiresprecision, by default 0.5pt) ---------------------------- revision 1.66 date: 2007-10-30 12:04:24 +0100; author: bless; state: Exp; lines: +9 -5; - added %%BeginData %%EndData as indicators for Binary Section - added new option -b (treat as binary) to prevent filtering CR/LF stuff ---------------------------- revision 1.65 date: 2007-01-24 14:19:42 +0100; author: bless; state: Exp; lines: +3 -3; - fixed help/usage formatting output ---------------------------- revision 1.64 date: 2007-01-24 13:32:59 +0100; author: bless; state: Exp; lines: +4 -4; - Year (C) update ---------------------------- revision 1.63 date: 2007-01-24 13:29:37 +0100; author: bless; state: Exp; lines: +3 -3; - Tried to make DSCfilter command more robust ---------------------------- revision 1.62 (not released) date: 2007-01-06 23:27:47 +0100; author: bless; state: Exp; lines: +11 -5; - better detection for files that have a binary heading stuff containing even %! as character sequence ---------------------------- revision 1.61 date: 2006-12-28 17:34:06 +0100; author: bless; state: Exp; lines: +5 -5; - changed year in comment and info printout only ---------------------------- revision 1.60 (not released) date: 2006-12-28 17:31:39 +0100; author: bless; state: Exp; lines: +9 -13; - incorporated changes for Windows/Cygwin detection by Karl Berry ---------------------------- revision 1.59 (not released) date: 2006-04-04 11:04:47 +0200; author: bless; state: Exp; lines: +4 -4; - removed surrounding ticks '' for -c $translation in $translatecmd (hint by Thomas Riedle) - removed useless/unsupported 2>&1 in $bboxver for Windows ---------------------------- revision 1.58 date: 2005/01/19 08:23:12; author: bless; state: Exp; lines: +8 -5 - fix for two negative offsets in translation (reported by Hans Ecke) ---------------------------- revision 1.57 date: 2005/01/19 07:59:52; author: bless; state: Exp; lines: +10 -3 - more Windows friendly checking for bbox existence ---------------------------- revision 1.56 date: 2005/01/17 12:32:54; author: bless; state: Exp; lines: +11 -3 - added -r option to specify a resolution ---------------------------- revision 1.55 date: 2005/01/14 15:28:09; author: bless; state: Exp; lines: +6 -4 - minor fixes to the -g option (thanks to Koji Nakamaru): * suppress info output if quiet option is active * more robust parsing of gs call result ---------------------------- revision 1.54 date: 2004/04/23 07:56:54; author: bless; state: Exp; lines: +4 -3 - added ^pdfIm ^%-EOD- as indicator for binary section ---------------------------- revision 1.53 date: 2004/04/01 19:28:02; author: bless; state: Exp; lines: +6 -2 - Clipping code used always hiresBB, which gave wrong results when bbox returned no hiresBB ---------------------------- revision 1.52 date: 2004/02/19 20:20:57; author: bless; state: Exp; lines: +90 -10 - added rotate option -R - changed translate in order to avoid negative BB coordinates ---------------------------- revision 1.51 date: 2004/01/25 22:02:04; author: bless; state: Exp; lines: +18 -9 - removed ^ in parsing for %! heading, because Adobe Photoshop generated a binary heading where ^%! did not work - added clipping along %%HiResBoundingBox +0.1 points - added option --nohires ---------------------------- revision 1.50 date: 2004/01/25 10:04:56; author: bless; state: Exp; lines: +158 -41 - ps2eps can now use the bbox device of ghostscript (either by option, environment variable or command line) - new environment variable PS2EPS_GSBBOX for specifying a default behavior - uses implicitly the ghostscript bbox device if external bbox command cannot be found - Added %%HiResBoundingBox output - now uses gswin32c as default for MSWin32 or cygwin platforms - added handling/passing of predefined paper sizes of ghostscript (including validity check and help) - added new environment variable PS2EPS_SIZE for default paper size - improved format checking for numerically given size - shows used page size if given while processing - shows whether it uses the bbox device of ghostscript - added use POSIX and check for OS - moved ps2eps header comment now after %%EndComments - removed looseBB option from call of bbox ---------------------------- revision 1.49 date: 2003/11/19 15:08:52; author: bless; state: Exp; lines: +83 -47 - Added -t|--translate option which allows to specify an offset for drawings - Existing Bounding Box will now be detected even if negative and fractional values are contained - Translation will happen automatically if a Bounding Box comment exists with negative offsets - Warning(s) are printed if Bounding Boxes with negative coordinates are detected - Built-in wildcard processing is only effective for non-Unix platforms ---------------------------- revision 1.48 date: 2003/11/09 17:47:47; author: bless; state: Exp; lines: +5 -5 - print help, license and version to stdout instead of stderr (incorporated patch from Rafael Laboissiere ) ---------------------------- revision 1.47 date: 2003/07/09 - different informational message for -F flag ---------------------------- revision 1.46 date: 2003/07/09 - now using Getopt::Long::Configure(), because the other way caused problems with module exports - fixsearchpat/fixreplacepat now filters initmatrix initclip initgraphics which is more generic and will hopefully fix more bad postscript code - binary section detection had missing CRLFs - binary section detection now includes PScript 4 doNimage end marker - improved pattern for ADO detection ---------------------------- revision 1.45 date: 2003/07/04 - improved processing of images for Pscript_Win_Dib_L2: comment filtering will not occur within doNimage,doclutimage,beginjpeg etc. ---------------------------- revision 1.44 date: 2003/07/03 - looseBB was not initialized - disabled use warnings since it may confuse users ---------------------------- revision 1.43 (not released) date: 2003/07/02 - deactivated triggered filter and replaced it with search/replace filter - new $filtersearchpat,$filterreplacepat combo to filter "initclip" for PScript5.dll Version 5.2 - sanity check never worked, fixed it - new option -W --warnings to allow optional sanity check - added various comments and reformatted source a little bit - changed output within option processing, --help, --version, etc. - added use warnings; - refined filter expression in $rangefilter_begin - added $exclude_rangefilter_begin and $..._end pair to preserve non PPD feature code (although DSCs are possibly removed) (this feature was integrated from my filterfeatures script) ---------------------------- revision 1.42 (not released) date: 2003/04/14 - provided more robustness if Postscript headerline is malformed ---------------------------- revision 1.41 (not released) date: 2003/03/21 - converted option processing to Getopt::Long package (based on code from Christophe Druet) - rudimentary internal wildcard support (based on code from Christophe Druet) (currently only within current directory) ---------------------------- revision 1.40 (not released) date: 2003/01/30 - added filter for Orientation: comment in header, see new option -O ---------------------------- revision 1.39 date: 2002/07/10 - changed new XP filter to triggered filter - improved processing of binary files with beginimage endimage ---------------------------- revision 1.38 (not released) date: 2002/07/09 - changed comment filtering in order to prevent image distortion - new filter for Windows XP PScript5.dll Version 5.2: Bad lines are: 0 GpPBeg NP 129 400 m 4629 400 l 4629 6400 l 129 6400 l CP eoclip 1 1 1 SC NP 128 400 m 4629 400 l 4629 6400 l 128 6400 l CP AF GSE To avoid the white rectangle deleting all the text above, it is sufficient to delete "1 1 1 SC" to "AF", however, I used eoclip as indicator for the whole sequence. ---------------------------- revision 1.37 (not released) date: 2001/10/10 - added "/setpagedevice {pop} def" to prolog in order to fix problems with pdf creation, pstricks and nested dvips output (thanks to Hans Fredrik Nordhaug for suggesting this addition) ---------------------------- revision 1.36 (not released) date: 2001/08/30 Added filter for Staroffice 5.2 Linux revision 1.35 ------------- date: 2001/08/20 13:32:36 - Improved removeADO (tolerates more spaces) ---------------------------- revision 1.34 (not released) ------------- date: 2001/08/20 12:38:22 - Improved processing of files with leading or trailing binary code - Improved processing of files with embedded binary coded images - Removes gabby diagnostic output from Adobe Printer Driver (see variable removeADO) ---------------------------- revision 1.33 (not released) ------------- date: 2001/04/25 22:42:10 - Corrected %%EOF handling (regex) once again, because of braindead Win-files with _CR_LF - Corrected handling of existing %%BoundingBox comments. Now it takes the last one seen. Should esp. work with %%BoundingBox: (atend) usage... ---------------------------- revision 1.32 (not released) ------------- date: 2001/04/06 22:31:27 - Fixed case sensitiveness when checking for suffix replacement (thanks to Erik Jørgensen) ---------------------------- revision 1.31 ------------- date: 2001/02/27 19:45:19 - Heuristic added for finding end of file by counting %%EOF comments. Now correctly treats already embedded EPS, too. Usually only trailing garbage (e.g., PCL control sequences) follows last %%EOF. However, sometimes the last %%EOF may be missing. Therefore, the behavior is switchable by new -E option. ---------------------------- revision 1.30 (not released) ------------- date: 2001/02/09 16:55:32 Just forgot the new options in usage line, corrected year in copyright ---------------------------- revision 1.29 ------------- date: 2001/02/09 15:43:28 - New first line of code for getting rid of the #! comment - EOF handling corrected, allowing better handling of already embedded eps files - New -P option to allow selective removal of embedded preview images (was previously default) - Preview images were not filtered in the prolog section (now corrected with -P) - New -N option to prevent inclusion of any surrounding postscript code ---------------------------- revision 1.28 ------------- date: 2000/10/13 09:51:55 \n was missing at altered clipping bounding box ---------------------------- revision 1.27 (not released) date: 2000/10/13 09:39:07 Clip option should now also print the enlarged BoundingBox in the Postscript header, so it is not cut off if it gets clipped again. ---------------------------- revision 1.26 - just fixed the E-Mail address, because it will not change so often in the future ---------------------------- revision 1.25 (not released) - new -C option clipping added - fixed page bounding box search message - bbox 1.10 now fixed scanf() which might cause crashes ---------------------------- revision 1.24 date: 2000/07/24 18:52:36; - just forgot the new options in usage txt, now fixed ---------------------------- revision 1.23 date: 2000/07/24 18:34:52; - ps2eps now uses existing Bounding Box for GS rendering (can be switched off with -B option) - Original Postscript version from first header line should now be retained in output file - provide --help and --version with usual meaning for GNU programs ---------------------------- revision 1.22 date: 2000/02/23 14:15:31; author: bless; state: Exp; lines: +12 -6 ps2eps now draws in color (ppm) by default. Monochrome option added. Fixing message was not printed for each file. ---------------------------- not released before... ps2eps/Makefile0000644000570200017500000000407011766326360012750 0ustar blessbless# $Id: Makefile 139 2012-06-14 08:40:32Z bless $ # $HeadURL: svn+ssh://vorta.ipv6.tm.uka.de/home/bless/src/ps2eps/svn-repository/trunk/ps2eps/Makefile $ PKGDIR=/usr/src/packages RPMSRCDIR=$(PKGDIR)/SOURCES RPMDIR=$(PKGDIR)/RPMS/i586 SRPMDIR=$(PKGDIR)/SRPMS RPMBUILD=rpmbuild DISTRIBDIR=ps2eps DISTRIBTAR=ps2eps.tar.gz DISTRIBSRCTAR=ps2eps-src.tar.gz DISTRIBZIP=ps2eps.zip doc: cd doc; make distrib: doc ver=`grep '^# \$$Id' src/perl/ps2eps | awk '{print $$4}'`; \ make -C doc; \ rm -rf $(DISTRIBDIR); \ mkdir -p $(DISTRIBDIR)/src/C; \ tar --exclude .svn -cf - bin | tar -C $(DISTRIBDIR) -xvf -; \ cd $(DISTRIBDIR); \ touch Latest_is_$$ver; \ mkdir -p doc/man/man1; mkdir -p doc/pdf; mkdir -p doc/html; \ cd ..; \ cp doc/*.html $(DISTRIBDIR)/doc/html ; \ cp doc/*.pdf $(DISTRIBDIR)/doc/pdf ; \ cp doc/*.1 $(DISTRIBDIR)/doc/man/man1 ; \ cp doc/*.txt $(DISTRIBDIR) ; \ cp src/perl/ps2eps $(DISTRIBDIR)/bin ; \ cp src/C/bbox.c $(DISTRIBDIR)/src/C ; \ cp src/C/Makefile $(DISTRIBDIR)/src/C ; \ rm $(DISTRIBTAR) $(DISTRIBZIP) ; \ tar --exclude "*~" -chzvf $(DISTRIBTAR) $(DISTRIBDIR); \ zip -r -9 $(DISTRIBZIP) $(DISTRIBDIR)/ -x \*~; \ cd doc; make clean; cd ..; rm -rf $(DISTRIBDIR)/doc; \ mkdir -p $(DISTRIBDIR)/doc/src; cp doc/*.sgml $(DISTRIBDIR)/doc/src; cp doc/Makefile $(DISTRIBDIR)/doc/src; \ mkdir $(DISTRIBDIR)/src/perl; cp src/perl/ps2eps $(DISTRIBDIR)/src/perl; cp Makefile $(DISTRIBDIR) tar --exclude "*~" --exclude $(DISTRIBDIR)/bin -chzvf $(DISTRIBSRCTAR) $(DISTRIBDIR); \ gpg -b $(DISTRIBTAR); \ gpg -b $(DISTRIBZIP); \ gpg -b $(DISTRIBSRCTAR) rpm: rpmsrctar ver=`grep '^# \$$Id' src/perl/ps2eps | awk '{print $$4}'`; \ sudo $(RPMBUILD) -bb spec/ps2eps.spec $(RPMBUILD) -bs --sign spec/ps2eps.spec rpm -q -i -p $(RPMDIR)/ps2eps-$$ver*.rpm rpm --addsign $(RPMDIR)/ps2eps-$$ver*.rpm cp $(RPMDIR)/ps2eps-$$ver*.rpm $(SRPMDIR)/ps2eps-$$ver*.src.rpm . rpmsrctar: ver=`grep '^# \$$Id' src/perl/ps2eps | awk '{print $$4}'`; \ tar --exclude CVS -C .. -czvf ps2eps_$$ver.tar.gz ps2eps/doc ps2eps/src; \ sudo cp ps2eps_$$ver.tar.gz $(RPMSRCDIR) # end of Makefileps2eps/LICENSE.txt0000644000570200017500000004312711766326360013141 0ustar blessbless GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License.