b***@artifex.com
2017-12-21 06:58:30 UTC
http://bugs.ghostscript.com/show_bug.cgi?id=698828
Bug ID: 698828
Summary: Solid gray pattern in cairo's pdf output is
interpreted differently by ghostscript depending on
whether an intermediate pattern is explicitly used
Product: Ghostscript
Version: 9.22
Hardware: PC
OS: Linux
Status: UNCONFIRMED
Severity: normal
Priority: P4
Component: Color
Assignee: ***@artifex.com
Reporter: ***@gmail.com
QA Contact: gs-***@ghostscript.com
Word Size: ---
Consider the following pycairo example
from cairo import *
surf = PDFSurface("/tmp/test1.pdf", 5, 5)
cr = Context(surf)
cr.rectangle(0, 0, 5, 5)
cr.set_source_rgba(.5, .5, .5, 1)
cr.fill()
pat_surf = ImageSurface(Format.ARGB32, 5, 5)
cr = Context(pat_surf)
cr.rectangle(0, 0, 5, 5)
cr.set_source_rgba(.5, .5, .5, 1)
cr.fill()
pat = SurfacePattern(pat_surf)
surf = PDFSurface("/tmp/test2.pdf", 5, 5)
cr = Context(surf)
cr.set_source(pat)
cr.paint()
In the first case, I directly write a solid 50% gray pattern to a pdf file. In
the second case, I explicitly create a SurfacePattern with the same gray
filling and transfer it to the pdf file.
Let's rasterize the resulting pdfs with ghostscript and query the results,
using (for example) matplotlib's imread (any other png binding would work):
python /tmp/test.py
for f in test1 test2; do
gs -q -sDEVICE=png16m -dNOPAUSE -dBATCH -sOutputFile=/tmp/$f.png
/tmp/$f.pdf
python -c "from pylab import *; print(imread('/tmp/$f.png'))"
done
This shows that the first image (direct write) is rasterized to a gray value of
0.498, which is reasonable (=127/255). The second image, however, is
rasterized to a gray value of 0.573 (in fact, likely 146/255).
**I believe that this is a bug in ghostscript and not in cairo because mupdf
does not show the same discrepancy.**
The pdfs are available at
https://filebin.ca/3lQRS1OTGuax/test1.pdf
and
https://filebin.ca/3lQRqNHQqcoF/test2.pdf
(not added as attachments as unless I'm mistaken I can only attach *one* file).
Relevant software versions: cairo 1.15.8, ghostscript 9.22, Arch Linux.
Bug ID: 698828
Summary: Solid gray pattern in cairo's pdf output is
interpreted differently by ghostscript depending on
whether an intermediate pattern is explicitly used
Product: Ghostscript
Version: 9.22
Hardware: PC
OS: Linux
Status: UNCONFIRMED
Severity: normal
Priority: P4
Component: Color
Assignee: ***@artifex.com
Reporter: ***@gmail.com
QA Contact: gs-***@ghostscript.com
Word Size: ---
Consider the following pycairo example
from cairo import *
surf = PDFSurface("/tmp/test1.pdf", 5, 5)
cr = Context(surf)
cr.rectangle(0, 0, 5, 5)
cr.set_source_rgba(.5, .5, .5, 1)
cr.fill()
pat_surf = ImageSurface(Format.ARGB32, 5, 5)
cr = Context(pat_surf)
cr.rectangle(0, 0, 5, 5)
cr.set_source_rgba(.5, .5, .5, 1)
cr.fill()
pat = SurfacePattern(pat_surf)
surf = PDFSurface("/tmp/test2.pdf", 5, 5)
cr = Context(surf)
cr.set_source(pat)
cr.paint()
In the first case, I directly write a solid 50% gray pattern to a pdf file. In
the second case, I explicitly create a SurfacePattern with the same gray
filling and transfer it to the pdf file.
Let's rasterize the resulting pdfs with ghostscript and query the results,
using (for example) matplotlib's imread (any other png binding would work):
python /tmp/test.py
for f in test1 test2; do
gs -q -sDEVICE=png16m -dNOPAUSE -dBATCH -sOutputFile=/tmp/$f.png
/tmp/$f.pdf
python -c "from pylab import *; print(imread('/tmp/$f.png'))"
done
This shows that the first image (direct write) is rasterized to a gray value of
0.498, which is reasonable (=127/255). The second image, however, is
rasterized to a gray value of 0.573 (in fact, likely 146/255).
**I believe that this is a bug in ghostscript and not in cairo because mupdf
does not show the same discrepancy.**
The pdfs are available at
https://filebin.ca/3lQRS1OTGuax/test1.pdf
and
https://filebin.ca/3lQRqNHQqcoF/test2.pdf
(not added as attachments as unless I'm mistaken I can only attach *one* file).
Relevant software versions: cairo 1.15.8, ghostscript 9.22, Arch Linux.
--
You are receiving this mail because:
You are the QA Contact for the bug.
You are receiving this mail because:
You are the QA Contact for the bug.