Bug #696

PostScript Level 1 limitation on fill patterns

Added by Paul over 2 years ago. Updated about 2 years ago.

Status:ClosedStart date:2015-04-12
Priority:NormalDue date:
Assignee:Remko% Done:

100%

Category:-
Target version:Candidate for next minor release
Affected version:all Platform:

Description

The option to use pattern fill (-Gp<dpi>/<patternfile>) imposes unreasonable limits on the size of the pattern image. Attached are two patterns:
  • tile.jpg: a 64x64 JPG image
  • fancy.jpg: a 90x90 pixel JPG image.

The attached script tiling.sh fills a simple polygon with these fills, but the fancy.jpg case fails and yields something odd (large pixels of a tiny subset of the image?). Perhaps there are ways around this problem so we could allow larger images without a major rewrite of how it is done (i.e., avoid using the pismire replication method). At the very least we should give error or warning when the image fill method will fail.

fancy.jpg (4.45 KB) Paul, 2015-04-12 12:35

tile.jpg (14.7 KB) Paul, 2015-04-12 12:35

tiling.sh Magnifier (341 Bytes) Paul, 2015-04-12 12:36

tiling_72.ps (72 KB) Remko, 2015-08-05 02:51

tiling_300.ps (72 KB) Remko, 2015-08-05 02:51

Associated revisions

Revision 14707
Added by Remko about 2 years ago

Added -dDownsampleColorImages=false -dDownsampleGrayImages=false -dDownsampleMonoImages=false to gs parameters in ps2raster to avoid image reduction in PDF mode.
This fixes issue #696.

Revision 14708
Added by Remko about 2 years ago

Added -dDownsampleColorImages=false -dDownsampleGrayImages=false -dDownsampleMonoImages=false to gs parameters in ps2raster to avoid image reduction in PDF mode.
This fixes issue #696.

Revision 14709
Added by Remko about 2 years ago

Added tiling test based on issue #696

History

#1 Updated by Remko about 2 years ago

This is not a GMT bug. In fact, it works beautifully when you look at the PostScript file itself with ghostscript (gv), even with Preview.
It also looks good when converting the PNG (e.g. with psconvert -Tg -E300)
The problem must be in ghostscript's conversion to PDF.
To be investigated further.

Attached are PS versions with 72 and 300 DPI (tiling_72.ps and tiling_300.ps).

#2 Updated by Remko about 2 years ago

A bit more on this. I have figured out that is the result of the /prepress settings for the pdfwriter module in ghostscript. It, by default, limits the resolution of images. Even though that should be limited to 300 dpi, I venture that in these cases of tiles images, it gets confused.

I found a way to print the settings that are activated when either using -dPDFSETTINGS=/default, /screen, or /prepress:

$ gs -q -dNODISPLAY -c ".distillersettings /default get {exch only ( ) print =} forall quit" | sort

/AutoRotatePages /PageByPage
/CannotEmbedFontPolicy /Warning
/ColorACSImageDict << /QFactor 0.9 /Blend 1 /HSamples [2 1 1 2] /VSamples [2 1 1 2] >>
/ColorConversionStrategy /LeaveColorUnchanged
/CreateJobTicket false
/DoThumbnails false
/DownsampleColorImages false
/DownsampleGrayImages false
/DownsampleMonoImages false
/EmbedAllFonts true
/GrayACSImageDict << /QFactor 0.9 /Blend 1 /HSamples [2 1 1 2] /VSamples [2 1 1 2] >>
/NeverEmbed [/Courier /Courier-Bold /Courier-Oblique /Courier-BoldOblique /Helvetica /Helvetica-Bold /Helvetica-Oblique /Helvetica-BoldOblique /Times-Roman /Times-Bold /Times-Italic /Times-BoldItalic /Symbol /ZapfDingbats]
/Optimize false
/PreserveEPSInfo true
/PreserveOPIComments true
/PreserveOverprintSettings true
/UCRandBGInfo /Preserve

$ gs -q -dNODISPLAY -c ".distillersettings /screen get {exch only ( ) print =} forall quit" | sort*

/AutoRotatePages /PageByPage
/CannotEmbedFontPolicy /Warning
/ColorACSImageDict << /QFactor 0.76 /Blend 1 /HSamples [2 1 1 2] /VSamples [2 1 1 2] /ColorTransform 1 >>
/ColorConversionStrategy /sRGB
/ColorImageDownsampleType /Average
/ColorImageResolution 72
/CompatibilityLevel 1.5
/CreateJobTicket false
/DoThumbnails false
/EmbedAllFonts true
/GrayACSImageDict << /QFactor 0.76 /Blend 1 /HSamples [2 1 1 2] /VSamples [2 1 1 2] /ColorTransform 1 >>
/GrayImageDownsampleType /Average
/GrayImageResolution 72
/MonoImageDownsampleType /Average
/MonoImageResolution 300
/NeverEmbed [/Courier /Courier-Bold /Courier-Oblique /Courier-BoldOblique /Helvetica /Helvetica-Bold /Helvetica-Oblique /Helvetica-BoldOblique /Times-Roman /Times-Bold /Times-Italic /Times-BoldItalic /Symbol /ZapfDingbats]
/PreserveEPSInfo false
/PreserveOPIComments false
/PreserveOverprintSettings false
/UCRandBGInfo /Remove

$ gs -q -dNODISPLAY -c ".distillersettings /prepress get {exch only ( ) print =} forall quit" | sort

/AutoRotatePages /None
/CannotEmbedFontPolicy /Error
/ColorACSImageDict << /QFactor 0.15 /Blend 1 /HSamples [1 1 1 1] /VSamples [1 1 1 1] /ColorTransform 1 >>
/ColorConversionStrategy /LeaveColorUnchanged
/ColorImageDownsampleType /Bicubic
/ColorImageResolution 300
/CompatibilityLevel 1.5
/CreateJobTicket true
/DoThumbnails true
/EmbedAllFonts true
/GrayACSImageDict << /QFactor 0.15 /Blend 1 /HSamples [1 1 1 1] /VSamples [1 1 1 1] /ColorTransform 1 >>
/GrayImageDownsampleType /Bicubic
/GrayImageResolution 300
/MonoImageDownsampleType /Bicubic
/MonoImageResolution 1200
/NeverEmbed []
/PreserveEPSInfo true
/PreserveOPIComments true
/PreserveOverprintSettings true
/UCRandBGInfo /Preserve

This makes clear that /prepress (which is often required by publishers to use with Acrobat Distiller) does do a lossy image reduction. We should avoid that from happening in psconvert by adding the following command line options to the gs command:
-dDownsampleColorImages=false -dDownsampleGrayImages=false -dDownsampleMonoImages=false

#3 Updated by Remko about 2 years ago

  • Status changed from In Progress to Resolved

This was fixed in ps2raster (GMT 5.1) by r14707.
This was fixed in psconvert (GMT 5.2) by r14708.

#4 Updated by Paul about 2 years ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100

Fantastic, works great. I am closing this issue.

#5 Updated by Joaquim about 2 years ago

Remko, are those patterns coming from pictures you took in Castelo Branco?

#6 Updated by Remko about 2 years ago

Paul provided the tiles, but they could have come from Aveiro or Guimarães.

#7 Updated by Remko about 2 years ago

  • Affected version changed from 5.2-svn to all

#8 Updated by Paul about 2 years ago

Sorry, cannot recall; it was a random web grab.

Also available in: Atom PDF