Bug 691669 - Hairlines too fine in PDF->TIFF conversion
Summary: Hairlines too fine in PDF->TIFF conversion
Status: NOTIFIED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: Graphics Library (show other bugs)
Version: master
Hardware: PC All
: P2 normal
Assignee: Robin Watts
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-08 16:03 UTC by Marcos H. Woehrmann
Modified: 2011-10-02 02:34 UTC (History)
3 users (show)

See Also:
Customer: 850
Word Size: ---


Attachments
hairline_acrobat.tif (1.90 MB, image/tiff)
2010-10-08 16:06 UTC, Marcos H. Woehrmann
Details
patch (1.10 KB, patch)
2011-01-01 19:49 UTC, Alex Cherepanov
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Marcos H. Woehrmann 2010-10-08 16:03:18 UTC
From the customers email:

GS 9.00 renders hair lines and other fine objects from the pdf in the attached PDF much finer than the
Acrobat as can be seen in the tif files. It seems that Acrobat's minimal object size is at least 2*2 pixel. We often get complaints from our customers for this behavior of GS.

gswin32c.exe -sDEVICE=tiffg4 -r600 -o hairline_ghostscript.tif hairline.pdf

Adobe Acrobat 9 Pro 9.0.4: Save As -> TIFF (Colorspace: Monochrome, Resolution: 600 dpi)
Comment 4 Alex Cherepanov 2011-01-01 19:49:41 UTC
Created attachment 7077 [details]
patch

Change all "/foo /bar load def" into "/foo {bar} bind 0 get def"
in PDF interpreter to enable operator redefinition with -dDELAYBIND.

The file uses "0.12 w", which at 600 dpi corresponds to 1 pixel line thickness.
The following command forces minimal line thickness to 0.15 (in the user
coordinate system) and renders closer to Acrobat.

gswin32c -r600 -sDEVICE=tiffg4 -o out.tif -dDELAYBIND 
  -c "/setlinewidth {.15 .max setlinewidth} .bind def .bindnow" -f foo.pdf
Comment 5 Henry Stiles 2011-01-04 00:37:24 UTC
Robin should probably review this one.
Comment 6 Alex Cherepanov 2011-01-04 04:46:45 UTC
The patch enables PS operator redefinition in PDF interpreter for a few
common PS operators. By itself it doesn't affect rendering.

The command line is a work-around that works for a particular file or a
class of files but is likely to produce undesirable results in a general
case.
Comment 7 Robin Watts 2011-01-05 13:11:01 UTC
My postscript skills aren't up to Alexes high standard. I understand the intent of what he's doing (from his description), and the patch therefore looks plausible. I therefore think it would be a good idea to commit it.
Comment 8 Robin Watts 2011-01-05 13:11:53 UTC
I meant to ask: Alex, might there be any potential speed issues causes by the late binding of these operators?
Comment 9 Alex Cherepanov 2011-01-05 15:16:09 UTC
Without -dDELAYBIND the patch has no external effects.
PDF operators /m , /l, etc. get defined to the corresponding PS operators
(not executable names or arrays).

With -dDELAYBIND the redefined operators remain executable names and get
looked up on the dictionary stack. This is the desired effect that enables
various hacks and tricks.
Comment 10 Robin Watts 2011-01-11 21:26:10 UTC
Looks like Alex committed this as revision 11986, so closing. Credit to Alex.