evince automatically interpolates embedded PostScript and PDF images

Bug #249400 reported by BioStatMatt
16
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Evince
Fix Released
Medium
Poppler
Fix Released
High
evince (Ubuntu)
Fix Released
Low
Ubuntu Desktop Bugs

Bug Description

Binary package hint: evince

In the following Postscript code, an image should be displayed without interpolation (smoothing). GhostScript and KGhostView, and others correctly interpret this code. However, evince interpolates the image automatically without regard to the explicit instruction ( /Interpolate false ) not to. Can anybody explain why this is the case, and if it can be fixed?

%!PS-Adobe EPSF-3.0
%%Title: evince automatically interpolates
%%Creator: BioStatMatt
%%CreationDate: Tue Jul 1 09:47:45 2008
%%Origin: 0 0
%%BoundingBox: 0 0 504 504
%%Magnification: 1.0000
%%EndComments
/DeviceRGB setcolorspace

gsave 72 72 translate 36 36 scale
<<
  /ImageType 1
  /Width 10
  /Height 10
  /ImageMatrix [1 0 0 1 0 0]
  /MultipleDataSources false
  /DataSource {currentfile 3 string readhexstring pop}
  /BitsPerComponent 8
  /Decode [0 1 0 1 0 1]
  /Interpolate false
>> image

dada00e2e200caca00272700f4f400
5c5c00e2e200f2f200818100373700
a3a300474700eded009b9b00a6a600
444400696900444400bdbd005f5f00
1d1d00b3b300b0b0004c4c00d8d800
4f4f00a3a3003c3c00b0b0005c5c00
4c4c000505003a3a00989800b5b500
b0b000f4f4009393001d1d006e6e00
4c4c00c0c000373700323200dddd00
6161001010003f3f00272700b8b800
222200444400efef00d2d200939300
c0c000a3a300b8b800fcfc00d5d500
0d0d00424200dddd004747005f5f00
0d0d007979004c4c00222200969600
3f3f00fafa00d8d800767600252500
b0b000595900a8a800717100838300
e5e500151500c8c800cdcd00e7e700
dddd000808008686008e8e00101000
5454009e9e00c8c800b3b300676700
202000444400e2e200f7f700676700

grestore
showpage
%%Trailer
%%EOF

Revision history for this message
In , Carlos Garcia Campos (carlosgc) wrote :

Another test case attached to evince bug: http://bugzilla.gnome.org/show_bug.cgi?id=484340

Revision history for this message
In , Soeren Sonnenburg (bugreports-nn7) wrote :

another test case

http://bugzilla.gnome.org/show_bug.cgi?id=509132

However I noticed that while acrobat reader and xpdf render these .pdf's correctly the macosx preview viewer also has the same problem.

Revision history for this message
BioStatMatt (shotwelm) wrote : evince automatically interpolates embedded PostScript images

Binary package hint: evince

In the following Postscript code, an image should be displayed without interpolation (smoothing). GhostScript and KGhostView, and others correctly interpret this code. However, evince interpolates the image automatically without regard to the explicit instruction ( /Interpolate false ) not to. Can anybody explain why this is the case, and if it can be fixed?

%!PS-Adobe EPSF-3.0
%%Title: evince automatically interpolates
%%Creator: BioStatMatt
%%CreationDate: Tue Jul 1 09:47:45 2008
%%Origin: 0 0
%%BoundingBox: 0 0 504 504
%%Magnification: 1.0000
%%EndComments
/DeviceRGB setcolorspace

gsave 72 72 translate 36 36 scale
<<
  /ImageType 1
  /Width 10
  /Height 10
  /ImageMatrix [1 0 0 1 0 0]
  /MultipleDataSources false
  /DataSource {currentfile 3 string readhexstring pop}
  /BitsPerComponent 8
  /Decode [0 1 0 1 0 1]
  /Interpolate false
>> image

dada00e2e200caca00272700f4f400
5c5c00e2e200f2f200818100373700
a3a300474700eded009b9b00a6a600
444400696900444400bdbd005f5f00
1d1d00b3b300b0b0004c4c00d8d800
4f4f00a3a3003c3c00b0b0005c5c00
4c4c000505003a3a00989800b5b500
b0b000f4f4009393001d1d006e6e00
4c4c00c0c000373700323200dddd00
6161001010003f3f00272700b8b800
222200444400efef00d2d200939300
c0c000a3a300b8b800fcfc00d5d500
0d0d00424200dddd004747005f5f00
0d0d007979004c4c00222200969600
3f3f00fafa00d8d800767600252500
b0b000595900a8a800717100838300
e5e500151500c8c800cdcd00e7e700
dddd000808008686008e8e00101000
5454009e9e00c8c800b3b300676700
202000444400e2e200f7f700676700

grestore
showpage
%%Trailer
%%EOF

Revision history for this message
Pedro Villavicencio (pedro) wrote :

confirming will look upstream, thanks for reporting.

Changed in evince:
assignee: nobody → desktop-bugs
importance: Undecided → Low
status: New → Triaged
Revision history for this message
Pedro Villavicencio (pedro) wrote :

Thanks for your bug report. This bug has been reported to the developers of the software. You can track it and make comments here: http://bugzilla.gnome.org/show_bug.cgi?id=543438

Changed in evince:
status: Unknown → New
Changed in evince:
status: New → Incomplete
Changed in evince:
status: Incomplete → Invalid
Revision history for this message
In , Tjd (tjd) wrote :

Smoothing of low-res graphics is not always a bug. In the PDF spec (at least in version 1.7), there is a flag (called 'Interpolate') for each image which is supposed to control smoothing. It defaults to 'false', for no interpolation.

On Fedora 8, (poppler 0.6.2.2, cairo 1.5.8, evince 2.20.2), this flag is ignored by evince, which renders all images as smoothed. Acroread (8.1.2_SU1) gets it right.

I'm attaching 3 pdf files and screenshots showing acroread and evince with the 3 files open.

-pixels.Imissing.pdf: Interpolate not specified (should be blocky)
-pixels.Itrue.pdf: Interpolate=true (should be smoothed)
-pixels.Ifalse.pdf: Interpolate=false (should be blocky)

-acroread_interp_examples.png (Acroread gets it right)
-evince_interp_examples.png (evince renders all as smoothed)

Revision history for this message
In , Tjd (tjd) wrote :

Created an attachment (id=18252)
Example PDFs and screenshots from acroread and evince

Changed in poppler:
status: Unknown → Confirmed
Revision history for this message
Tom Davidson (tjd-mit) wrote :

At bug 199916, this is also shown to be true for the 'Interpolate' flag for images in PDF files. Marked the older bug a dupe since this one had already been triaged.

Also added upstream bug. This has been reported to evince since Feb 2006, ( http://bugzilla.gnome.org/show_bug.cgi?id=331781 ) and to Poppler since Feb 2007. It's really a show-stopper for PDFs containing scientific figures, which often use very large pixels to represent discrete values in 2D plots.

Changed in evince:
status: Invalid → Unknown
Changed in evince:
status: Unknown → Fix Released
Revision history for this message
In , Carlos Garcia Campos (carlosgc) wrote :

Created an attachment (id=26358)
Use Interpolate flag to decide whether applying image interpolation during rendering

 poppler/CairoOutputDev.cc | 92 ++++++++++++++++++++++++++------------------
 poppler/CairoOutputDev.h | 46 ++++++++++++---------
 poppler/Gfx.cc | 47 +++++++++++++++++++---
 poppler/OutputDev.cc | 16 +++++---
 poppler/OutputDev.h | 12 +++--
 poppler/SplashOutputDev.cc | 15 +++++--
 poppler/SplashOutputDev.h | 11 +++--
 utils/HtmlOutputDev.cc | 16 ++++----
 utils/HtmlOutputDev.h | 6 +-
 utils/ImageOutputDev.cc | 20 +++++-----
 utils/ImageOutputDev.h | 11 +++--
 11 files changed, 183 insertions(+), 109 deletions(-)

Revision history for this message
In , Carlos Garcia Campos (carlosgc) wrote :

Created an attachment (id=26390)
Use Interpolate flag to decide whether applying image interpolation during rendering (Updated)

 poppler/CairoOutputDev.cc | 92 ++++++++++++++++++++++++++------------------
 poppler/CairoOutputDev.h | 46 ++++++++++++---------
 poppler/Gfx.cc | 47 +++++++++++++++++++---
 poppler/OutputDev.cc | 16 +++++---
 poppler/OutputDev.h | 12 +++--
 poppler/SplashOutputDev.cc | 15 +++++--
 poppler/SplashOutputDev.h | 11 +++--
 utils/HtmlOutputDev.cc | 16 ++++----
 utils/HtmlOutputDev.h | 6 +-
 utils/ImageOutputDev.cc | 20 +++++-----
 utils/ImageOutputDev.h | 11 +++--
 11 files changed, 183 insertions(+), 109 deletions(-)

Updated after rebasing from current master.

Revision history for this message
In , Albert Astals Cid (aacid) wrote :

Some indentation is broken, eg in

+ if (obj1.isNull()) {
+ obj1.free();
+ maskDict->lookup("I", &obj1);
+ }

of @@ -3954,6 +3979,16 @@ void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) {

You forgot to change PreScanOutputDev, PSOutputDev and ArthurOutputDev functions

Adding -Woverloaded-virtual to your CXXFLAGS will help spotting this kind of errors, maybe we should add it to the default

Revision history for this message
In , Carlos Garcia Campos (carlosgc) wrote :

(In reply to comment #7)
> Adding -Woverloaded-virtual to your CXXFLAGS will help spotting this kind of
> errors, maybe we should add it to the default

Definitely

Revision history for this message
In , Carlos Garcia Campos (carlosgc) wrote :

Created an attachment (id=26711)
Use Interpolate flag to decide whether applying image interpolation during rendering

 poppler/ArthurOutputDev.cc | 4 +-
 poppler/ArthurOutputDev.h | 4 +-
 poppler/CairoOutputDev.cc | 92 +++++++++++++++++++++++++------------------
 poppler/CairoOutputDev.h | 46 ++++++++++++---------
 poppler/Gfx.cc | 47 +++++++++++++++++++---
 poppler/OutputDev.cc | 16 +++++---
 poppler/OutputDev.h | 12 +++--
 poppler/PSOutputDev.cc | 5 +-
 poppler/PSOutputDev.h | 5 +-
 poppler/PreScanOutputDev.cc | 11 +++--
 poppler/PreScanOutputDev.h | 11 +++--
 poppler/SplashOutputDev.cc | 15 +++++--
 poppler/SplashOutputDev.h | 11 +++--
 utils/HtmlOutputDev.cc | 16 ++++----
 utils/HtmlOutputDev.h | 6 +-
 utils/ImageOutputDev.cc | 20 +++++-----
 utils/ImageOutputDev.h | 11 +++--
 17 files changed, 207 insertions(+), 125 deletions(-)

Revision history for this message
In , Albert Astals Cid (aacid) wrote :

drawMaskedImage in PSOutputDev still has the wrong signature

And you failed to update/set your copyright in all the touched files.

Fixing that you can commit

Revision history for this message
In , Carlos Garcia Campos (carlosgc) wrote :

Pushed to git master.

Changed in poppler:
status: Confirmed → Fix Released
Revision history for this message
Sebastien Bacher (seb128) wrote :

the issue should be fixed since intrepid closing the bug

Changed in evince (Ubuntu):
status: Triaged → Fix Released
Revision history for this message
Pascal (getreuer) wrote :

It seems there is still a problem with evince or poppler. The recent fix to poppler has fixed the problem for PS but not for PDF.

In Bug #199916, dominik suggests downloading
   http://png2pdf.sourceforge.net/png2pdf.pdf
and looking at "Figure 7: Image without interpolation". With evince (version 2.26.1 with poppler 0.10.5), the image is nevertheless interpolated. (Use Acrobat Reader for example to see the correct display of the figure.)

As a second example, the following is very similar to BioStatMatt's previous example for PS:
The PDF code below specifies an image that should be displayed without interpolation. Copy and paste this code into a text editor and save as "test.pdf," then open it with evince. In spite of the "/Interpolate false" instruction against doing so, evince (version 2.26.1 with poppler 0.10.5) will display with interpolation.

%PDF-1.4
1 0 obj
<<
/Producer (bmeps)
>>
endobj
2 0 obj
<<
/Type /Catalog
/Pages 3 0 R
>>
endobj
3 0 obj
<<
/Type /Pages
/Count 1
/Kids [
4 0 R
]
>>
endobj
4 0 obj
<<
/Type /Page
/Parent 3 0 R
/MediaBox [ 0 0 8 8 ]
/Resources <<
/ProcSet [ /PDF /ImageC ]
/XObject 6 0 R
>>
/Contents 5 0 R
>>
endobj
5 0 obj
<< /Length 30 >>
stream
q
8 0 0 8 0 0 cm
/X7 Do
Q
endstream
endobj
6 0 obj
<<
/X7 7 0 R
>>
endobj
7 0 obj
<<
/Type /XObject
/Subtype /Image
/Width 8
/Height 8
/ColorSpace /DeviceRGB
/BitsPerComponent 8
/Interpolate false
/Length 71
/Filter [ /ASCII85Decode /FlateDecode ]
>>
stream
GhQY8@/,e6JD`YZ65'K"s8Sib_--f#Ul]`Y(C(!JLAqkps,kQW$_g1c$GrV>*'$.C
~>
endstream
endobj
xref 0 8
0000000000 65535 f
0000000010 00000 n
0000000054 00000 n
0000000109 00000 n
0000000177 00000 n
0000000332 00000 n
0000000416 00000 n
0000000452 00000 n
trailer
<< /Size 8 /Info 1 0 R /Root 2 0 R >>
startxref
739
%%EOF

Revision history for this message
Dimitrios Symeonidis (azimout) wrote :

On Karmic, png2pdf.pdf renders exactly the same in Evince and Acroread, see attached screenshots...

Revision history for this message
Dimitrios Symeonidis (azimout) wrote :
Revision history for this message
Dimitrios Symeonidis (azimout) wrote :
Download full text (11.8 KiB)

Also, be aware that Evince spits out a lot of errors to stderr when opening this file:

Error (88374): Unknown operator 'j!ZZ,'
Error (88384): Unknown operator 'K!^?u+N;dYJo:f7PEaeEm1J'nG?LL*h;-nkq8JA:*tE181"b7n41ntq0F*t1p'
Error (88390): Unknown operator 'UVg4'
Error (88390): Unknown operator ']'
Error (88393): Unknown operator 'j6XdF'
Error (88395): Illegal character <72> in hex string
Error (88396): Illegal character <69> in hex string
Error (88397): Illegal character <2a> in hex string
Error (88398): Illegal character <52> in hex string
Error (88400): Illegal character <56> in hex string
Error (88401): Illegal character <5f> in hex string
Error (88402): Illegal character <58> in hex string
Error (88403): Illegal character <68> in hex string
Error (88404): Illegal character <3c> in hex string
Error (88405): Illegal character <48> in hex string
Error (88406): Illegal character <54> in hex string
Error (88407): Illegal character <5a> in hex string
Error (88408): Illegal character <68> in hex string
Error (88512): Unknown operator 'BW;uiAEl'
Error (88532): Unknown operator '^p9'
Error (88547): Unknown operator 'lL'\7Vs!lp#FQgSYc$'
Error (88559): Illegal character <53> in hex string
Error (88560): Illegal character <5e> in hex string
Error (88564): Illegal character <22> in hex string
Error (88565): Illegal character <2b> in hex string
Error (88567): Illegal character <40> in hex string
Error (88568): Illegal character <40> in hex string
Error (88569): Illegal character <2c> in hex string
Error (88570): Illegal character <3f> in hex string
Error (88571): Illegal character <51> in hex string
Error (88572): Illegal character <50> in hex string
Error (88574): Illegal character <51> in hex string
Error (88575): Illegal character <2a> in hex string
Error (88576): Illegal character <4e> in hex string
Error (88577): Illegal character <5c> in hex string
Error (88578): Illegal character <48> in hex string
Error (88581): Illegal character <4b> in hex string
Error (88582): Illegal character <6e> in hex string
Error (88584): Illegal character <6b> in hex string
Error (88585): Illegal character <60> in hex string
Error (88586): Illegal character <51> in hex string
Error (88588): Illegal character <6b> in hex string
Error (88590): Illegal character <52> in hex string
Error (88591): Illegal character <52> in hex string
Error (88592): Illegal character <52> in hex string
Error (88593): Illegal character <3d> in hex string
Error (88594): Illegal character <4b> in hex string
Error (88595): Illegal character <54> in hex string
Error (88597): Illegal character <49> in hex string
Error (88599): Illegal character <73> in hex string
Error (88602): Illegal character <4f> in hex string
Error (88605): Illegal character <6b> in hex string
Error (88607): Illegal character <6e> in hex string
Error (88608): Illegal character <48> in hex string
Error (88609): Illegal character <58> in hex string
Error (88610): Illegal character <6e> in hex string
Error (88611): Illegal character <4c> in hex string
Error (88612): Illegal character <53> in hex string
Error (88613): Illegal character <71> in hex string
Error (88614): Illegal character <54> in hex string
Error (88615): Illegal ...

Changed in poppler:
importance: Unknown → High
Changed in evince:
importance: Unknown → Medium
Changed in poppler:
importance: High → Unknown
Changed in poppler:
importance: Unknown → High
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.