SVG images generated by common drawing softwares contains unnecessary data: calc layer, metadata, namespaces and comments.

Non compliant Code Example

<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
    width="210mm"
    height="297mm"
    viewBox="0 0 210 297"
    version="1.1"
    id="svg5"
    inkscape:version="1.2.2 (b0a8486541, 2022-12-01)"
    sodipodi:docname="dessin2.svg"
    xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
    xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
    xmlns="http://www.w3.org/2000/svg"
    xmlns:svg="http://www.w3.org/2000/svg">
    <g
            inkscape:label="Calque 1"
            inkscape:groupmode="layer"
            id="layer1">
        <circle
            style="fill:#ff00ff;stroke-width:0.264583"
            id="path111"
            cx="104.02724"
            cy="152.19028"
            r="73.177132" />
    </g>
</svg>

Compliant Solution

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 210 297" width="210mm" height="297mm">
    <circle cx="104.02724" cy="152.19028" r="73.177132" style="fill:#ff00ff;stroke-width:0.264583"/>
</svg>

Relevance Analysis

The following results were obtained through local experiments.

Configuration

  • SQLite Database: 5-6 GB

  • Processor: Intel® Core™ Ultra 5 135U, 2100 MHz, 12 cores, 14 logical processors

  • RAM: 16 GB

  • CO2 Emissions Measurement: Using CodeCarbon

Context

For example, by using SVGOMG, a tool for optimizing SVGs, we were able to reduce the file size from 22 KB to 11 KB, a 50% reduction. This is useful for page loading or data storage.

image

Test Execution

For this analysis, we simulated a process of manipulating these SVG files. The objective was to measure the impact of file size on CO2 emissions. We used an "optimized" SVG file and a "non-optimized" SVG file. The modification consisted of changing certain parts of the SVG and saving the final result.

Impact Analysis

output

Conclusion

The emissions with the non-optimized file are 1.3928360831225074e-08, while the emissions with the optimized file are 9.68571752760373e-09, representing a 30% reduction in emissions.

We recommend incorporating file optimization techniques as part of our standard development practices and exploring additional opportunities to reduce the environmental impact of our digital products.