Zoomed image is pixellized in Inkscape (good) but not in pdf

Post questions on how to use or achieve an effect in Inkscape.
Niriel
Posts: 3
Joined: Sat Feb 21, 2015 8:16 pm

Zoomed image is pixellized in Inkscape (good) but not in pdf

Postby Niriel » Sat Feb 21, 2015 8:50 pm

See attached image. On the left is what I see inside Inkscape, on the right is what I get after an export to PDF.

I have a document containing vector elements, text and one bitmap. The bitmap has a very low resolution: 27x27 pixels. I scale it so that it's 10 cm wide, so it pixelizes like hell but that's what I want: this is astronomical data.
  • Inside Inkscape, the bitmap retains its pixelized look which is good (I guess it uses a nearest-neighbor interpolation).
  • However, when I export to PDF, the image is blurred (looks like bilinear filtering to me), which is bad.
  • Opening the SVG with the standard image viewer of my Ubuntu also shows a blurred bitmap. That's consistent with the PDF at least.

Question: how can I ask Inskape to use a neirest-neighbor interpolation instead of whatever default it uses?

The funny thing is that the bitmap was actually contained inside a PDF, I imported it and removed the ugly text and axes. So I know that the bitmap can look crisp in a PDF, I just don't find a way of doing it myself.

  • I think it really is a bitmap, because right-clicking on it opens the contextual menu with "Image properties" in it.
  • I tried to set "Inkscape preferences/Bitmap/Oversample bitmap" to None, to 2, and to 16. I couldn't see any difference.
  • I tried tracing the bitmap, but I don't manage. I have never done that before, so it is likely that I did not understand how to use that tool. I select "Multiple scans" and "color", but it creates blobs. Changing the number of scans from 2, 8, 64, 128 isn't helping. It's probably not even the right tool at all.
Any idea?

EDIT
As a temporary workaround I used Filters/Raster/Resample and made is as big as I could. It results in a very heavy and slow PDF but at least it doesn't look horrible. Still not ideal.
Attachments
inkscape_crisp_blurry.png
Left: inside inkscape. Right: when exported to PDF.
inkscape_crisp_blurry.png (175.73 KiB) Viewed 1814 times
Last edited by Niriel on Sat Feb 21, 2015 9:17 pm, edited 1 time in total.

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: Zoomed image is pixellized in Inkscape (good) but not in

Postby Lazur » Sat Feb 21, 2015 8:57 pm

Hi.

You can change the pdf-s rendering from interpolated to non-interpolated by manually editing the codes of the pdf.
http://www.inkscapeforum.com/viewtopic.php?f=5&t=16223


Inkscape's renderer had been just changed, 0.48 shows rasters pixelated, 0.91 shows them interpolated as far as I know.
By upgrading, you will have the desired look.

(To be honest I like the pixelated rendering of rasters more.)

hulf2012
Posts: 716
Joined: Sat Nov 24, 2012 12:37 pm

Re: Zoomed image is pixellized in Inkscape (good) but not in

Postby hulf2012 » Sun Feb 22, 2015 1:18 am

Hello,

An idea:

"Create Bitmap Copy" (Alt + B)

from your bitmap, when escaled.Probably it will be some blurring between colors, but it also can be controled in the preferences of inkscape, in the Bitmaps section. I haven't tried but reduce the ppp from 90 to something less and see what happen.

Try that, and then export to pdf your design with the bitmap copy.
If you have problems:
1.- Post a sample (or samples) of your file please.
2.- Please check here:
http://tavmjong.free.fr/INKSCAPE/MANUAL/html/index.html
3.- If you manage to solve your problem, please post here your solution.

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: Zoomed image is pixellized in Inkscape (good) but not in

Postby brynn » Sun Feb 22, 2015 8:24 am

I don't completely understand what you're asking (because I'm not very tech-savvy) but there's a Pixelize filter (Filters menu > Pixel Tools > Pixelize. Maybe that would help?

Niriel
Posts: 3
Joined: Sat Feb 21, 2015 8:16 pm

Re: Zoomed image is pixellized in Inkscape (good) but not in

Postby Niriel » Mon Feb 23, 2015 7:42 pm

Lazur URH wrote:You can change the pdf-s rendering from interpolated to non-interpolated by manually editing the codes of the pdf.
http://www.inkscapeforum.com/viewtopic.php?f=5&t=16223

Thank you. I did find the "Interpolated = true" line in the pdf and replaced it with "false", but since the PDF is mostly binary something gets corrupted when I save it. I will try to write a quick-and-dirty python script to try to do this, see if it works better.

Edit: I managed! The dirty python script that I wrote:

Code: Select all

filename_i = "12co10.pdf"
filename_o = "12co10_crisp.pdf"

data = None
with open(filename_i, "rb") as f:
    data = f.read()

def crisper(s):
    pieces = s.split("Interpolate true", 1)
    if len(pieces) != 2:
        return s
    before, after = pieces
    middle = "Interpolate false"
    new_s = "".join([before, middle, after])
    return crisper(new_s)

new_data = crisper(data)

with open(filename_o, "wb") as f:
    f.write(new_data)

Warning: works with python 2.x, definitely not python 3, since in python 3 all the strings are unicode. Here, I use strings as raw byte arrays.


Return to “Help with using Inkscape”