1

I got a question concerning the .png export of Inkscape. I want to draw 2 rectangles which touch each other (snapping enabled, snap bounding box corners). Each box has a certain fill color and no stroke paint. After exporting a .png image I would expect to have only two colors in my Image, but instead IrfanView tells me I got 3 colors. Zooming in, this third color occurs at the boundary line where the rectangles touch. Zooming in with Gimp, there is transparency between the rectangles. Neither by letting the rectangles overlap, nor by using stroke paint, I can get rid of this 3rd color.

Does anybody know how to solve this problem? For my purpose I need a .png image which contains only certain color values that I used to fill rectangles.

Screenshot of the boundary between the rectangles with Gimp

Screenshot of the boundary between the rectangles with IrfanView

here is the XML code of the rectangeles:

sodipodi:docname="1.svg">
  <defs
     id="defs4" />
  <sodipodi:namedview
     id="base"
     pagecolor="#ffffff"
     bordercolor="#666666"
     borderopacity="1.0"
     inkscape:pageopacity="0.0"
     inkscape:pageshadow="2"
     inkscape:zoom="2.8"
     inkscape:cx="195.53572"
     inkscape:cy="607.85714"
     inkscape:document-units="px"
     inkscape:current-layer="layer1"
     showgrid="false"
     inkscape:snap-bbox="true"
     inkscape:bbox-nodes="true"
     inkscape:snap-intersection-paths="true"
     inkscape:object-paths="true"
     inkscape:bbox-paths="true"
     inkscape:window-width="1280"
     inkscape:window-height="1002"
     inkscape:window-x="1912"
     inkscape:window-y="23"
     inkscape:window-maximized="1" />
  <metadata
     id="metadata7">
    <rdf:RDF>
      <cc:Work
         rdf:about="">
        <dc:format>image/svg+xml</dc:format>
        <dc:type
          rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
        <dc:title />
      </cc:Work>
    </rdf:RDF>
  </metadata>
  <g
     inkscape:label="Layer 1"
     inkscape:groupmode="layer"
     id="layer1">
    <rect
       style="opacity:1;fill:#797979;fill-opacity:1;stroke:none;stroke-width:1.77165353;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
       id="rect3336"
       width="514.28571"
       height="182.85715"
       x="85.714287"
       y="255.21935"
       inkscape:export-xdpi="300"
       inkscape:export-ydpi="300" />
    <rect
       style="opacity:1;fill:#dfdfdf;fill-opacity:1;stroke:none;stroke-width:1.77165353;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
       id="rect4140"
       width="514.28571"
       height="199.28571"
       x="85.714287"
       y="438.07648"
       inkscape:export-xdpi="300"
       inkscape:export-ydpi="300" />
  </g>
</svg>
2

1 Answer 1

1

I tired various things in Inkscape:

  1. Playing around with same color stroke.
  2. Adding a 0 or 1 pixel spacing using the Remove Overlaps tool in Object > Align and Distribute.
  3. Raising the dpi of the exported PNGs from the default 90 (tried as much as 600)

I also read through the question @Paolo-Gibellini suggested and similar questions, which pointed me in the right direction.

The only workaround I found was:

  1. Export from Inkscape as SVG
  2. Import into GIMP (default import resolution worked for me)
  3. Export from GIMP in PNG (defualt settings worked for me)

To verify in GIMP that this worked, open the output PNG and go to Colors > Info > Color Cube Analysis (instructions for GIMP 2.8.10). The number of unique colors will be 2. @Axel, I have not used IrfanView, but that should confirm that there are indeed only 2 colors as well.

Please be advised that how the actual image previews/displays will vary in various programs. I really zoomed in on the images in various programs on OS X and Ubuntu and different programs created different artifacts around edges. Nevertheless, the PNG output from GIMP does seem to only contain 2 colors while the PNG output directly from Inkscape contained 4-5 colors when I checked.

1
  • 1
    Fine this worked, but only if I disabled antialiasing in Inkskape like described in the question @Paolo-Gibellini suggested. Thanks!!
    – Axel
    Commented Nov 9, 2016 at 12:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.