Inkscape.org
Beyond the Basics Export svg loses color and adds pixels on export
  1. #1
    Craig Coleman Craig Coleman @icebowl
    *

    I created an SV using JAVA.  https://craigcoleman.com/miracles/  .

    When I load graphic with Inkscape and export to a png or jpg

    I lose some of the color and the colors fade on the line.  

    Additionally I get some pixels around some of the lines. I copy the image from the web and copy it into gimp then zoom in.

    This is the code I wrote to create a line :

     <line     x1="5"  y1="450"  x2="5"  y2="562" style="stroke:#777777;stroke-width:1" id="line1" />

    Here are the jpg and png

    https://craigcoleman.com/art/files/miracles-5.jpg

    https://craigcoleman.com/art/files/miracles-5.png

    I am wondering if I should use a path.

    Please throw me a bone.

  2. #2
    David248 David248 @David248
    😀*

    I don't fully understand your problem, but I think I does turn around bitmap limitations vs vector : you can't expect the same quality when exporting to bitmaps. The more you zoom in bitmaps, the more you'll see abnormal pixels.

    Please point out the tiny differences you are talking about, I can't barely see nothing at normal zoom level.

  3. #3
    Tyler Durden Tyler Durden @TylerDurden
    🔥

    I'd keep in mind that using 1px vertical lines having a 1px stroke will have the strokes on a half pixel. Renderers will need to interpolate the edges of the strokes, which may result in aliasing artifacts.Line or path will probably have similar results.

    @Lazur is the expert on these issues. Maybe Lazur can comment.

  4. #4
    Aero Aero @Aero◻️
    🔥😀

    Try this:
    Select the black rectangle in your svg and move it half a pixel in the x direction.
    With the rectangle still selected open the export dialog and set dpi to 288.
    Export selection.
     

  5. #5
    Craig Coleman Craig Coleman @icebowl

    Thank you for all the advice!  I am working with my code.  I now understand rendering will affect an output from svg to png/jpg

    I wonder how a path would work instead of a line?

  6. #6
    Craig Coleman Craig Coleman @icebowl

    Using a path with a dpi of 288 really helps!  The entire image is to large to upload.  Thank you!

     

     

    <svg height="900" width="1200" >
    <rect width="1200" height="900" x="0" y="0"  fill="#000000" />
    <text x="500" y="40" font-size="40" fill="#ffffff">Miracles נִסָא </text>
    <path d="M5 450 L5 562" style="fill:none;stroke:#777777;stroke-width:1" />
    <path d="M6 450 L6 539" style="fill:none;stroke:#777777;stroke-width:1" />
    <path d="M7 450 L7 549" style="fill:none;stroke:#777777;stroke-width:1" />
    <path d="M8 450 L8 539" style="fill:none;stroke:#777777;stroke-width:1" />
    <path d="M9 450 L9 522" style="fill:none;stroke:#777777;stroke-width:1" />
    <path d="M10 450 L10 530" style="fill:none;stroke:#777777;stroke-width:1" />
    <path d="M11 450 L11 532" style="fill:none;stroke:#777777;stroke-width:1" />
    <path d="M12 450 L12 532" style="fill:none;stroke:#777777;stroke-width:1" />
    <path d="M13 450 L13 543" style="fill:none;stroke:#777777;stroke-width:1" />
    ......

     

    Test Path
  7. #7
    Aero Aero @Aero◻️
    <svg height="900" width="1200" >
    	<rect width="1200" height="900" x="0" y="0" fill="#000000" id="rect1"/>
    	<text x="500" y="40" font-size="40" fill="#ffffff" id="text1">Miracles נִסָא </text>
    	<path d="M 5.5,450 V 562" style="fill:none;stroke:#777777;stroke-width:1"/>
    	<path d="M 6.5,450 V 539" style="fill:none;stroke:#777777;stroke-width:1"/>
    	<path d="M 7.5,450 V 549" style="fill:none;stroke:#777777;stroke-width:1"/>
    	<path d="M 8.5,450 V 539" style="fill:none;stroke:#777777;stroke-width:1"/>
    	<path d="M 9.5,450 V 522" style="fill:none;stroke:#777777;stroke-width:1"/>
    	<path d="M 10.5,450 V 530" style="fill:none;stroke:#777777;stroke-width:1"/>
    	<path d="M 11.5,450 V 532" style="fill:none;stroke:#777777;stroke-width:1"/>
    	<path d="M 12.5,450 V 532" style="fill:none;stroke:#777777;stroke-width:1"/>
    	<path d="M 13.5,450 V 543" style="fill:none;stroke:#777777;stroke-width:1"/>
    ....

     

  8. #8
    Lazur Lazur @Lazur
    *

    Thank's for the mention @TylerDurden. Here is a "flattened" version.

    png:

     

    svg:

    The vertical lines were shifted by 0.5 px. To capture 1 px details pixel perfect, you need to adjust everything to the pixel grid -of the final output.

    Like, working with a px rid in inkscape, even coordinates and exporting at increments of 96 dpi.

    If the vertical lines aren't exactly matching the grid but next to eachother as is, the anti-aliasing can interfere with the outcome as in your export. 

    For experimentation: try zooming in and out with your original html. At some zoom levels there are visible gaps, other times there is no gap.

    Created the "flattened version" to address the issue. Paths are combined, stroke converted to a path and they are merged together. 

    Unnecessary nodes removed. 

    This way, the image would display right even if rotated by a certain degree. 

    Still. Those lines at random angles in the image aren't looking the best in my humble opinion. 

    Can try oversampling -export svg at 192 dpi and scale down the raster image by 50%. 

  9. #9
    Craig Coleman Craig Coleman @icebowl
    *

    Lazur & Tyler

    Thank you so much.  I need to try to replicate this with code (java).

    I appreciate the effort and the explanation.

    Craig

Inkscape Inkscape.org Inkscape Forum Beyond the Basics Export svg loses color and adds pixels on export