[off-topic] How can I "tumble" output of -sDEVICE=tiffg4 ?

Kurt Pfeifle kurt.pfeifle at infotec.com
Fri Jul 4 01:47:34 PDT 2008


Hi,

my apologies for abusing this list to ask for some Ghostscript help; but it looks like the Ghostscript mailing lists won't accept my subscription, and here are some participants who seem to be quite knowledgeable.

The problem at hand seems very easy, but I nevertheless already managed to waste many hours in pursuing a solution. I'm batch-converting thousands of PDF files with the help of Ghostscript, using this commandline:

	gs \
        -sDEVICE=tiffg4 \
        -dBATCH \
        -dNOPAUSE \
        -r600x600 \
        -g10592x7040 \
        -sOutputFile=${tiffdir}/p%08d.tif \
        ${pdfdir}/${pdffile:1} \
		2>&1 >> ${tiff_err_file}.$$

(where the variables are serving an obvious purpose). The input PDF files are A3 oversized (1270 x 842 pts).

Ghostscript (I'm using 8.62 on Solaris 10, Ultra-45 SPARC) does its job just fine, with correct orientation also in all image viewer applications.

However, here's my problem:

    =======================================================================
     Since some of the TIFFs later are printed on paper, and the printer's
	 finishing devices are not adjustable, I'd need to create some of the
	 TIFF images tumbled "upside down".
    =======================================================================

There's another limitation: the solution needs to work *fast* (or rather, fast enough). Overall, it is not allowed to require more than 1 second per A3+ page to create the final TIFF. My above commandline meets this requirement (on a Ultra-45 SPARC, 1 GByte RAM), but unfortunately, I'd need the TIFF output "upside down". Even if I added an automatic pdftk step to tumble the PDFs prior to let Ghostscript create TIFFs from them, the overall time would go above 1 second/page.

My variations of the above Ghostscript command that included "-dORIENT1=true" or "-dORIENT1=false" didn't change anything.

I already tried different variations of inserting "-c [some-valid-PostScript-code-here]" to the Ghostscript commandline, but it did not change anything. (I don't know if that kind of PostScript code snippet insertion is supposed to work at all if the Ghostscirpt input files are PDF. Example:

	gs  \
        -sDEVICE=tiffg4 \
        -dBATCH \
        -dNOPAUSE \
        -r600x600 \
        -g10592x7040 \
        -sOutputFile=${tiffdir}/p%08d.tif \
        -c "<< /Orientation 2 >> setpagedevice" -f \
        ${pdfdir}/${pdffile:1} \
        2>&1 >> ${tiff_err_file}.$$

I tried all "/Orientation 0", "/Orientation 1" and "/Orientation 3" as well. Other switches I tried (I googled a lot) included:

    -c "<</Duplex false /Tumble true>> setpagedevice" -f
    -c "<</EndPage {exch pop 2 ne { [{ThisPage} <> /PUT pdfmark true} {false}ifelse}>> setpagedevice" -f

but none would change anything in the output.

Now my questions:

	* Is there a simple switch I could add to the above gs commandline that
	  tumbles the output? (If I use "-g7040x10592", the image of course is
	  rotated 90 degrees inside its bounding box, and hence clipped.)

	* If there is none, I obviously could tumble (rotate by 180 degrees) the
	  input PDF files instead... But how do I do that with Ghostscript? (I
	  don't want to use pdftk...)


Thanks for your help,
Cheers,
Kurt

P.S.:  Here is some additional info. Ghostscript is supposed to take over
       from a proprietary solution that is creating the TIFFs now.

	   If I use "tiffinfo" I get this output (for proprietary and for GS
	   TIFFs):

	   bash-3.00# tiffinfo proprietary.tif
		TIFF Directory at offset 0x8 (8)
		  Subfile Type: multi-page document (2 = 0x2)
		  Image Width: 10592 Image Length: 7040
		  Resolution: 600, 600 pixels/inch
		  Bits/Sample: 1
		  Compression Scheme: CCITT Group 4
		  Photometric Interpretation: min-is-white
		  FillOrder: msb-to-lsb
		  Orientation: row 0 top, col 0 lhs
		  Samples/Pixel: 1
		  Rows/Strip: 7040
		  Planar Configuration: single image plane
		  Page Number: 0-0
		  Software: GPL Ghostscript 8.62
		  DateTime: 2008:07:03 18:53:32
		  Group 4 Options: (0 = 0x0)

	   bash-3.00# tiffinfo ghostscript.tif
		TIFF Directory at offset 0x8 (8)
		  Subfile Type: (0 = 0x0)
		  Image Width: 7040 Image Length: 10592
		  Resolution: 600, 600 pixels/inch
		  Bits/Sample: 1
		  Compression Scheme: CCITT Group 4
		  Photometric Interpretation: min-is-white
		  FillOrder: msb-to-lsb
		  Orientation: row 0 lhs, col 0 bottom
		  Samples/Pixel: 1
		  Rows/Strip: 10592
		  Planar Configuration: single image plane





More information about the cups mailing list