Problem importing PDF with bitmaps

Post questions on how to use or achieve an effect in Inkscape.
2wicked
Posts: 21
Joined: Wed Jun 18, 2014 6:59 pm

Problem importing PDF with bitmaps

Postby 2wicked » Thu Jul 23, 2015 11:31 pm

Hi all,

I have a problem importing PDF files that contain bitmap images into Inkscape. When I open the file the bitmap parts get a horizontal and vertical lines in them. This also happens when the Open using Poppler option is selected.

Original:
Image

After importing to Inkscape:
Image


Original PDF

Is there a way to prevent this from happening? or to fix it?
Thanks in advance

(Using Inkscape 0.91 r13725 on Windows 7 Professional)

~suv
Posts: 2272
Joined: Sun May 10, 2009 2:07 am

Re: Problem importing PDF with bitmaps

Postby ~suv » Fri Jul 24, 2015 1:57 am

As far as I understand, the problem has (at least) three underlying technical aspects:
  1. Antialiasing artifacts
    The bitmap images imported in Inkscape are scaled, and the edges of the scaled bitmap images do not align to the pixel grid lines of the output device (e.g. Inkscape's canvas on screen). Such adjacent edges which do not fall onto pixel grid lines of the output device do render with visible antialiasing artifacts (not only in Inkscape - it's a generic problem for renderers of vector-based applications). A workaround to suppress such gaps in Inkscape's new renderer is to disable antialiasing for the whole document in 'File > Document Properties'.
  2. Image rendering mode in SVG
    The default mode to render scaled bitmap images in the new renderer of Inkscape 0.91 is 'smooth' (interpolated to "optimize for quality"), which - as side-effect - introduces additional semi-transparent regions along the edges of such bitmap images. They may be noticeably rendered e.g. when bitmap images are arranged in rows and columns, tightly aligned at the edges. These thin semi-transparent areas along the edges of each bitmap image - where the lighter background color is showing through - do not disappear when disabling the antialiasing rendering mode for the whole document.
    The SVG specification describes an alternative rendering mode for bitmap images ('blocky', aka "optimized for speed") which is supported by Inkscape's new renderer (>= 0.91). This rendering mode for images doesn't apply any interpolation to the bitmap image and thus adds no transparency along the edges of the scaled bitmap image.
  3. Image rendering mode in PDF
    Bitmap images embedded in PDF documents may have an image interpolation flag defined (in the PDF file) - Inkscape 0.91 currently does not check for this flag and always imports the bitmap images with default rendering mode (smooth).
    This was recently changed in the development version (Inkscape 0.91+devel rev >= 14171), so that bitmap images which are not flagged in the PDF file to be rendered with an interpolation algorithm for smoother appearance are imported with a comparable SVG-rendering mode in Inkscape ('blocky', aka "optimized for speed").

A more pragmatic answer to users of Inkscape 0.91 could be (for example) a workaround in two steps:
  1. Change all bitmap images imported from the PDF file to 'blocky' rendering mode. [1]
  2. Disable antialiasing in 'Document Properties'. [2]
I have uploaded the result of the described "workaround" method to Dropbox (zipped SVG file):
[1] Since there are too many bitmap images to change the rendering mode manually via 'Object properties', you could considering using the extension attached in this report - the next major Inkscape release have a similar extension already included.
[2] Caveat: disabling antialiasing will also effect any vector-based content (noticeable e.g. for the arcs of the rounded corners).
[3] The "not-antialiased" rendering mode in Inkscape is not yet finalized in its implementation and still has some rough edges (for example it doesn't enable itself initially when loading the file - hiding and unhiding the current layer again does trigger a refresh using the rendering mode from document properties, as does toggling the setting there back on and off again).

2wicked
Posts: 21
Joined: Wed Jun 18, 2014 6:59 pm

Re: Problem importing PDF with bitmaps

Postby 2wicked » Fri Jul 24, 2015 8:20 pm

Thanks ~suv.
I will look into it.


Return to “Help with using Inkscape”