Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SVG metadata and performance #3393

Open
polarbearing opened this issue Sep 14, 2018 · 6 comments
Open

SVG metadata and performance #3393

polarbearing opened this issue Sep 14, 2018 · 6 comments

Comments

@polarbearing
Copy link
Contributor

Image editing software often leaves a lot of metadata in the SVG code. In the icons I submitted, I usually took a text editor and cleaned everything that apparently does not contribute to the icon shape.

I don't know if it is worth the effort. It makes the SVG code a bit more human-readable and shrinks the size about 50%, but we talk about small files already. On the other hand some of these files are used quite often in the rendering.

Thus it would be interesting if somebody could investigate if that has any influence on the performance, thus it should be generally recommended.

Example of meta code:

 xmlns:dc="http://purl.org/dc/elements/1.1/"
 xmlns:cc="http://creativecommons.org/ns#"
 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
 xmlns:svg="http://www.w3.org/2000/svg"
 xmlns="http://www.w3.org/2000/svg"
<defs
     id="defs3802" />
  <metadata
     id="metadata3805">
    <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></dc:title>
      </cc:Work>
    </rdf:RDF>
  </metadata>

       id="g105"

       id="icon-name"
@HolgerJeromin
Copy link
Contributor

The deploy (this is not handled in this repo) could sanitize all svgs.
Same is done for the website svg files:

https://github.com/openstreetmap/openstreetmap-website/blob/7c7ff4fdf71ae8f450299ddfdcfc4aa137338d28/Gemfile#L43-L44

@polarbearing
Copy link
Contributor Author

Fine, but this style is inherited by other projects as well (e.g. German style).
Wouldn't it be better to handle the sanitizing at the root cause, instead of having every deployment do its own?

@Tomasz-W
Copy link

Thanks for raising this issue. I also noticed, that there are dozens of different SVG code schemes in our files, and I'm also interested, does the longest ones are causing some problems. As I'm not a tech guy but designer, I rather won't help technically, but I thought - maybe there is possibility of some converter, which would make output files short as possible?

@Adamant36
Copy link
Contributor

Good call @polarbearing. If someone wants to cleanup/unify the icon schemes id be willing to add the improved icons to the pixel alignment PR. It sounds like something that would be worth doing.

@Adamant36
Copy link
Contributor

Never mind. The pixel alignment PR just got merged.

@polarbearing
Copy link
Contributor Author

@polarbearing hails from the OSM hackweekend in Berlin.

Discussed the issue with our friend from OSMbuildings, he has an example for a minimal svg here. Just tested that, it loads fine in Ad$be Ill$str$t$r. Even the first <?xml... line is redundant, only xmlns="http://www.w3.org/2000/svg and version="1.1" are required.

There are some SVG cleaners flying around, some of them open source. Somebody willing to test? How does this travis thing here work, would that be a hook to automate the cleaning?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants