Workaround for Rastering Errors

Share your Inkscape tricks and tutorials here.
silverhammermba
Posts: 3
Joined: Wed Jan 06, 2010 1:53 am

Workaround for Rastering Errors

Postby silverhammermba » Wed Jan 06, 2010 2:25 am

Inkscape makes very small rendering errors that can, in certain situations, look really bad in your final raster of an SVG. They occur when the edges of two shapes coincide - a common occurrence when you have stacked duplicates.

For example, look at this image. This consists of a black background with a white square and a duplicate black square on top of it.
Image
Notice that a faint white line is visible! This is technically a rendering error - the black square is a duplicate so it completely obscures the white square. No white should be visible at all! In fact, this error is infinitesimal - no matter what resolution you export at and no matter how much you zoom in in Inkscape, that white line will have the same thickness.
Image
But there is any easy workaround for this because the errors are infinitesimal. Simply export it at several times your desired image size and then use a program like Paint.NET/Photoshop/Gimp/Irfanview to resize the image back down to the size you want.
Image
Voila!

Note:If you look closely, you'll notice that the white lines are still faintly visible in this final image. I don't think it's possible to truly remove them, but the larger you export before resizing, the fainter they will appear afterwards. This was about 10x, but in my experience 4-5x is usually enough to make it look presentable.

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

Re: Workaround for Rastering Errors

Postby brynn » Wed Jan 06, 2010 5:43 am

Simply export it at several times your desired image size and then use a program like Paint.NET/Photoshop/Gimp/Irfanview to resize the image back down to the size you want.

But don't you get some pixelation issues from scaling it down so much? I mean to me, the whole reason I want to use Inkscape/vector graphics is so I can scale things without any distortion, like happens when you scale raster graphics.

I haven't used the new Inkscape eraser tool (new in 0.47), so I don't know for sure. But maybe that's a good answer to the problem you describe?

User avatar
druban
Posts: 1917
Joined: Fri Nov 20, 2009 10:48 pm

Re: Workaround for Rastering Errors

Postby druban » Wed Jan 06, 2010 8:19 am

why can't you just delete the white square -or assign it no fill no stroke?
Your mind is what you think it is.

User avatar
sas
Posts: 404
Joined: Sat Oct 06, 2007 5:42 am

Re: Workaround for Rastering Errors

Postby sas » Wed Jan 06, 2010 8:31 am

brynn wrote:But don't you get some pixelation issues from scaling it down so much?

Scaling down raster graphics isn't much of a problem (unlike scaling up), as long as a decent algorithm is used.

I haven't used the new Inkscape eraser tool (new in 0.47), so I don't know for sure. But maybe that's a good answer to the problem you describe?

It's best to change the SVG file to avoid the problem if possible, and the eraser tool might be a way to do that in some cases. But in many cases there's no easy way to fix the SVG file, and the method that silverhammermba describes is useful in those cases.

The real fix would be a completely different rendering method. It would be slow, so it wouldn't be suitable for on-screen rendering, but it could be an option for bitmap export.

druban wrote:why can't you just delete the white square -or assign it no fill no stroke?

That would work in this particular case, but real cases are not usually so easy to deal with.

silverhammermba
Posts: 3
Joined: Wed Jan 06, 2010 1:53 am

Re: Workaround for Rastering Errors

Postby silverhammermba » Mon Jan 11, 2010 8:44 am

druban wrote:why can't you just delete the white square -or assign it no fill no stroke?

Yeah, my OP was a somewhat trivial example, but imagine if instead the black square were a gradient from opaque to transparent. Then the opaque edge would have the faint white line around it. You could fix it by slightly moving the edge of the white square so that it doesn't coincide with the edge above it, but that could produce an obvious gap at larger resolutions.


Return to “Tricks & Tutorials”