Author Topic: Fuzzy edges when exporting to png  (Read 9425 times)

October 14, 2017, 02:53:59 AM
Read 9425 times

lijasinkscape

  • Sr. Newbie

  • Offline
  • **

  • 4
I guess this is a really common question, but I cant get find an answer to it. When exporting an image to png, all edges, even on boxes, becomes fuzzy, see images below.
Is it possible to get them sharp? I feel like it should be possible, but maybe I am missing something?

The left image shows the export to png, and the left is how it looks like in inkscape.

https://imgur.com/5rsz7qH
  • 0.91

October 14, 2017, 03:41:21 AM
Reply #1

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
Welcome to the forum!

Probably you have some less than ideal settings for some options in the Export PNG dialog. 

 -- Definitely make sure that the DPI is set for 96.
 -- The manual info:  http://tavmjong.free.fr/INKSCAPE/MANUAL/html/File-Export.html#File-Export-PNG

If you still can't get sharp exports, please share an SVG file with us, which contains the image you want to export, along with all the particulars (such as if the image is required to be a certain size or certain resolution or etc.).

Not that it would give you any additional benefits for exporting, but just fyi, the current stable version of Inkscape is 0.92.2.  :)
  • Inkscape version 0.92.3
  • Windows 7 Pro, 64-bit
Inkscape Tutorials (and manuals)                      Inkscape Community Gallery                        Inkscape for Cutting Design                     



"Be ashamed to die until you have won some victory for humanity" - Horace Mann                       

October 14, 2017, 04:46:38 AM
Reply #2

Moini

  • IC Mentor

  • Offline
  • ******

  • 1,568
    • VektorRascheln
I would suggest using the Pixel-snap extension (don't know where to find, but google will know), or to use a high dpi value to minimize the issue (e.g. 300).

October 14, 2017, 06:39:04 AM
Reply #3

Lazur

  • IC Mentor

  • Offline
  • ******
  • Inkscape Filters Wizard

  • 1,154
  • Gender
    Male

    Male
The issue you mention is due to anti-aliasing.
related topic

Rendering a larger area and downsampling (scaling back) the image in a raster editor may lead to a more crisp image.

As mentioned above if your node coordinates match the exported image's px grid, horizontal/vertical edges will be rendered sharp.
The pixellize filter can reduce the anti-aliasing on arbitrary shapes -which, tweaks the full alpha channel to full transparent and opaque, meaning if you are using various opacity, it won't work.

Those are my general thoughts.

However in addition the rendering is not flawless either and you can hack together crystal clear straight or elliptical edges due to an issue:
gradients are not rendered with anti-aliasing. Quite a bummer, huh?
Very impractical but theoretically possible to build up a drawing only of gradient fills that represent edges.

October 14, 2017, 06:47:02 AM
Reply #4

lijasinkscape

  • Sr. Newbie

  • Offline
  • **

  • 4
Welcome to the forum!

Probably you have some less than ideal settings for some options in the Export PNG dialog. 

 -- Definitely make sure that the DPI is set for 96.
 -- The manual info:  http://tavmjong.free.fr/INKSCAPE/MANUAL/html/File-Export.html#File-Export-PNG

If you still can't get sharp exports, please share an SVG file with us, which contains the image you want to export, along with all the particulars (such as if the image is required to be a certain size or certain resolution or etc.).

Not that it would give you any additional benefits for exporting, but just fyi, the current stable version of Inkscape is 0.92.2. 

I would like to export the image in multiple sizes, for exampel 32x32 and 64x64 pixels. However, when I change the dpi, the image export size also changes, meaning that I only can export in one size if I set the dpi to 96?
Anyways, if I set the dpi to 96, the fuzzy edges are still there.

I will share the svg file. It is not me who made the svg file. The guy who made it made in some flash-tool I think. Here it is: https://www.dropbox.com/s/xte6rumo5piw8vf/test.svg?dl=0

Thanks, I will have to check the new version out :)
  • 0.91

October 14, 2017, 07:39:29 AM
Reply #5

Lazur

  • IC Mentor

  • Offline
  • ******
  • Inkscape Filters Wizard

  • 1,154
  • Gender
    Male

    Male
Added a pixellize filter to it, should work "much better".

Like the image not only would show "smudged" edges but the anti-aliasing rendering gap issue between the objects. (Probably it would look better redrawn with shapes overlapping instead...)

October 14, 2017, 02:17:33 PM
Reply #6

flamingolady

  • IC Mentor

  • Offline
  • ******
  • Flamingo Lady

  • 154
  • Gender
    Female

    Female
I also say to export at 300 dpi.  It changes the 'size' but does not chg the height, width size.  It adds the extra pixels, which will give you better resolution.  Do a few tests to see what I mean.  Export one at the 96 size, then one only changing the dpi box to 300, open them both next to each other and compare.  Should be the same size, meaning same height, same width, just a better, sharper view.  The size thing can be confusing, there's size, then there's size, lol.  Wish they'd put diff words in the 'size' that shows on the png export.

October 14, 2017, 06:20:44 PM
Reply #7

Moini

  • IC Mentor

  • Offline
  • ******

  • 1,568
    • VektorRascheln
At 32 pixels, fuzzy edges are to be expected, unless you snap your object corners exactly to the pixel edges in a 32x32 template (either using snapping, or the pixel-snap extension). Antialiasing (which is the term for Inkscape trying to make the picture look as good as possible, while you're exporting it to a tiny size, when object borders do not end on the border of a pixel in the resulting image, but in between) cannot be deactivated in Inkscape 0.92.2 (but it will be possible in 0.93).

The dpi value is probably irrelevant for your icons. dpi and size of an image in pixels are inversely proportional, if the template size stays the same. dpi is just dots (usually that corresponds to pixels) per inch. So if you export a 1 inch template image at a size of 32 px x 32 px, it will be 32 dpi. That's fine, as long as you don't want to print it.

October 14, 2017, 07:09:49 PM
Reply #8

Lazur

  • IC Mentor

  • Offline
  • ******
  • Inkscape Filters Wizard

  • 1,154
  • Gender
    Male

    Male
Example image drawn only with gradients:
-click for svg source-


Image should look aliased at any zoom level/exporting, just as with the pixellize filter.
« Last Edit: October 15, 2017, 05:20:23 AM by Lazur »

October 15, 2017, 04:57:03 AM
Reply #9

Moini

  • IC Mentor

  • Offline
  • ******

  • 1,568
    • VektorRascheln

October 15, 2017, 05:08:19 AM
Reply #10

Moini

  • IC Mentor

  • Offline
  • ******

  • 1,568
    • VektorRascheln
Interesting to see that gradients are not antialiased... The pixelize filter is cool. But why does it add such a large area around the objects? (I know I can remove that, but there may be a reason for this behaviour). It's fun to edit the object and watch the pixels move in the icon preview dialog...

October 15, 2017, 05:19:35 AM
Reply #11

Lazur

  • IC Mentor

  • Offline
  • ******
  • Inkscape Filters Wizard

  • 1,154
  • Gender
    Male

    Male
Oh yes have to correct that.
Thank's for the note.
Reuploaded it due to working on animation and the first upload had some broken javascript inside.

By default all filters have an 120% larger bounding box, pixellize is no exception.
If I wanted to export the filtered -"pixellized"- object, I'd expect to have a 1 px safety margin around the object which has 0 alpha. Since filtered areas cannot be defined in that +2+2 pixels, a larger area can come handy.

October 15, 2017, 08:20:53 AM
Reply #12

lijasinkscape

  • Sr. Newbie

  • Offline
  • **

  • 4
Thank you for all replies. Just to make things clear, it is not only the outer edges of the image that becomes fuzzy, it is also where two edges meet that is not sharp (like my example image showed in my first post). It is ok that anti aliasing is used for rounded corners etc, but where to edges meet I dont want the "fuzzyness".

It becomes a bit better if I export to 512x512 and the resize it to 64x64, but it is ofcourse not ideal.

It also becomes a bit better if I have an overlap of two objects.

Where can i find the pixellize option?
  • 0.91

October 15, 2017, 11:04:02 AM
Reply #13

Moini

  • IC Mentor

  • Offline
  • ******

  • 1,568
    • VektorRascheln
Filters -> Pixel tools -> Pixellize

October 15, 2017, 12:14:45 PM
Reply #14

flamingolady

  • IC Mentor

  • Offline
  • ******
  • Flamingo Lady

  • 154
  • Gender
    Female

    Female
just an fyi  - I sometimes clip my object to remove the blurring or fuzziness.  saw it done in a tutorial many yrs ago, and I guess it stuck. 
I've not used the pixellize function yet, haven't been on .92 that long.  Still getting up the nerve to go to 92.2. 

October 15, 2017, 12:41:26 PM
Reply #15

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
Hhm, I seem to be missing something here.  I can export the image without any fuzziness.  Where do you all see the non-crisp borders?
  • Inkscape version 0.92.3
  • Windows 7 Pro, 64-bit
Inkscape Tutorials (and manuals)                      Inkscape Community Gallery                        Inkscape for Cutting Design                     



"Be ashamed to die until you have won some victory for humanity" - Horace Mann                       

October 15, 2017, 02:03:38 PM
Reply #16

lijasinkscape

  • Sr. Newbie

  • Offline
  • **

  • 4
Hhm, I seem to be missing something here.  I can export the image without any fuzziness.  Where do you all see the non-crisp borders?

Every object gets anti-aliasing edges. The edges get an alpha value of 0.5. This is fine for for example rounded corners etc, but not "straigt edges".
Here is an example: https://imgur.com/a/sYeZT

I am realizing that fuzzy might have been the wrong word for what I have been trying to explain.  :duh:
  • 0.91

October 15, 2017, 03:06:31 PM
Reply #17

Lazur

  • IC Mentor

  • Offline
  • ******
  • Inkscape Filters Wizard

  • 1,154
  • Gender
    Male

    Male
Most of that is the anti-aliasing rendering gap issue.
With proper structure you can avoid that. Frankly the vector now looks as a bucket fill of a raster editor was vectorised colour by colour.
It would take 5 minutes the max redrawing the shapes properly.

October 15, 2017, 04:11:42 PM
Reply #18

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
No worries about saying "fuzzy", I got it from the topic title!

So this is about anti-aliasing?  This is about the rendering gap for adjacent edges?  Then we need to give this link:  https://inkscape.org/en/learn/faq/#theres-seam-or-artifact-between-adjacent-objects-sharing-same-border-or-between-patterns

For this image, I would suggest "underlapping" (opposite of overlapping).  That would be the very best solution in this case, in my opinion -- for the inner area.  We can tell you how to do that in Inkscape.  Or else you would need to find a graphic which is prepared better.

This problem would only be an issue for the outer edges if you are planning to tile the image.  Since it looks so much like a button, I'm guessing you  aren't planning to tile.  But if you are, then I've found the Stitch filter (in the above link) is the best solution.

If you aren't tiling it, then for the outer edge, you would really only see that "fuzziness" at high zoom or scale.  If you're just zooming, don't worry about it.  (Because you'll be displaying it at 100%, right?)  If you're scaling, then it would be better to scale it as vector paths, in the SVG file, before  you export.  One of the best benefits of vector graphics (such as SVG) which is not shared by raster graphics (such as PNG) is that you can scale without any lose of quality or pixelation. 

So scale first, export last.  If you want to fix the inner gaps by underlapping, that could be first or 2nd -- as long as exporting is still last.
  • Inkscape version 0.92.3
  • Windows 7 Pro, 64-bit
Inkscape Tutorials (and manuals)                      Inkscape Community Gallery                        Inkscape for Cutting Design                     



"Be ashamed to die until you have won some victory for humanity" - Horace Mann