On 2/10/11 00:14, Florian Berger wrote:
> I have an issue with unwanted / inferior looking interpolation in
> scaled Inkscape PNG exports.
> In the case at hand I have a pixel art image that has been converted to
> SVG using 40px x 40px vector squares for each pixel (whether or not
> Inkscape is the right tool for playing with pixel art is *not* the
> question here ;-) ).
> When such an image is scaled down a little and exported as PNG, it
Please clarify: do you actually scale the vector objects and then export
at 90 dpi (Inkscape's internal resolution), or do you refer to exporting
to bitmap with various bitmap sizes, while keeping the SVG at the
original size (rectangular paths with integer pixel values for all nodes
/ rectangle coords and dimensions)?
> shows some poor interpolation artefacts. These artefacts are less
> obvious or not present in the actual Inkscape display, but very visible
> after export.
> Here is an illustriation of the problem:
I don't see any interpolation artifacts - I do see antialiasing where
the "vector pixels" (40x40px) do not fall on pixel grid lines in the
Comments below are based on the assumption that you "scaled" the drawing
when exporting to bitmap (not the vector squares themselves on-canvas):
Recreating the drawing based on the screenshot, and testing with 0.48.2
and a current build from trunk gives the same (expected) results if
exported at arbitrary bitmap sizes (or resolutions) without considering
the pixel grid in the exported bitmap.
It would be interesting though to have a closer look at the SVG file
used for your screenshots/export: I'm surprised that the screenshot
doesn't show the same antialiasing artifacts where the vector squares
touch: did you draw them slightly overlapping (e.g. with an additional
stroke (colored like the fill)?
If the vector pixel are placed precisely to touch at the edges (without
overlapping strokes, even the new renderer (trunk) does show the "light
grey" edges (see attached screenshot) between them at most zoom levels.
> (Please view at original size first to prevent additional
> Please note that some of these interpolations do not seem to make
> sense, e.g. using bright grey in the brown / dark red hair of the
AFAIU the "bright grey" (lines) are antialiased edges of the vector
squares (against the transparent background), not interpolation errors.
> I am very aware that Inkscape may not be the weapon of choice for this
> kind of operation. Still, my questions:
> - Is there any way to prevent Inkscape from interpolation /
> anti-aliasing upon exporting such an image?
Yes: export at bitmap sizes (or resolutions) where you know that the
downscaled "vector pixels" fall precisely on pixel grid lines in the
Assuming 40x40px for each "vector pixel", and a total of 33 columns and
17 rows (-> page size of 1320x680 px), do export e.g. at 4.5dpi, 9dpi,
18dpi, 22.5dpi, ... and the exported PNG will _not_ have any noticeable
Alternatively, use dimensions which are dividable by the number of rows
and columns of "vector pixels" in the drawing: assuming the page size has
a width of 33 x 40 px = 1320 px
a height of 17 x 40 px = 680 px
export to bitmap sizes of e.g. 66x34, 132x68, 264x136, 330x170 ...
> - If this is an interpolation issue: why does Inkscape use such
> inappropriate colors?
In my understanding it is not an interpolation issue - it is about
antialiasing (against a transparent background). Inkscape does not have
an option to turn off antialiasing when exporting to bitmap (nor when
rendering on-canvas) - and yes, this feature has been requested various
times in the bug tracker. But if you want "pixelized" art, you have to
make sure yourself that all edges of the "vector pixels" in your drawing
will match a pixel grid line in the exported bitmap (else your squares
might not be squares any more (if inkscape had an option to turn off
antialiasing), or get antialiased (blurry)).
- SVG file with pixel art redrawn based on the screenshot
(vector squares 40x40 px, page size 1320x680 px):
visible layer: adjacent squares have been unioned
hidden layer: all individual squares (no unions)
- exported to bitmap with 4.5, 9, 18 and 22.5 dpi
(corresponds to bitmap sizes 66x34, 132x68, 264x156, 330x170 ...)
- screenshot of the SVG file in Inkscape 0.48.2