[PR #275] [MERGED] Add viewBox tag to flags with no viewBox #727

Closed
opened 2026-03-03 14:40:28 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/lipis/flag-icons/pull/275
Author: @edorivai
Created: 8/10/2016
Status: Merged
Merged: 8/14/2016
Merged by: @lipis

Base: masterHead: master


📝 Commits (1)

  • 240292a Add viewBox tag to flags with no viewBox

📊 Changes

473 files changed (+473 additions, -473 deletions)

View changed files

📝 flags/1x1/ad.svg (+1 -1)
📝 flags/1x1/ae.svg (+1 -1)
📝 flags/1x1/af.svg (+1 -1)
📝 flags/1x1/ag.svg (+1 -1)
📝 flags/1x1/ai.svg (+1 -1)
📝 flags/1x1/al.svg (+1 -1)
📝 flags/1x1/ao.svg (+1 -1)
📝 flags/1x1/aq.svg (+1 -1)
📝 flags/1x1/ar.svg (+1 -1)
📝 flags/1x1/as.svg (+1 -1)
📝 flags/1x1/at.svg (+1 -1)
📝 flags/1x1/au.svg (+1 -1)
📝 flags/1x1/aw.svg (+1 -1)
📝 flags/1x1/ax.svg (+1 -1)
📝 flags/1x1/az.svg (+1 -1)
📝 flags/1x1/bb.svg (+1 -1)
📝 flags/1x1/bd.svg (+1 -1)
📝 flags/1x1/be.svg (+1 -1)
📝 flags/1x1/bf.svg (+1 -1)
📝 flags/1x1/bg.svg (+1 -1)

...and 80 more files

📄 Description

Hey, great stuff!

We needed to have the viewBox set, and found that not all flags have that. So we wrote a simple (read: dumb) little script that adds the viewBox to those SVG's that didn't have any yet. To be sure we wrote it very defensively, so it doesn't change the file if:

  • There is already a viewBox attribute present, OR
  • Our dumb regex doesn't match (this happens for instance when the width and height properties are reversed in order) OR
  • The width and height properties are not (640 x 480) or (512 x 512)

Despite these limitations, the script still works pretty well, we managed to add the viewBox to 473 files.

Here's the script's output, showing which files it was unable to update:

As you see, quite a few of the flags already had a viewBox set. We were not sure whether these were all correct. For instance 4x3/am.svg shows: height="480" width="640" viewBox="0 0 0.5160635 3.096381". We know too little of SVG's to say whether this works as expected.

Funnily, 1x1/py.svg has dimensions of 513x512. Typo?

Finally, you can check the script yourself in https://github.com/dsempel/flag-icon-css/tree/viewbox

npm install

to get our dev dependencies, and

npm run addViewBox

to run the script.

Let us know what you think!


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/lipis/flag-icons/pull/275 **Author:** [@edorivai](https://github.com/edorivai) **Created:** 8/10/2016 **Status:** ✅ Merged **Merged:** 8/14/2016 **Merged by:** [@lipis](https://github.com/lipis) **Base:** `master` ← **Head:** `master` --- ### 📝 Commits (1) - [`240292a`](https://github.com/lipis/flag-icons/commit/240292ae9d4422428853bb702de08da3a782452c) Add viewBox tag to flags with no viewBox ### 📊 Changes **473 files changed** (+473 additions, -473 deletions) <details> <summary>View changed files</summary> 📝 `flags/1x1/ad.svg` (+1 -1) 📝 `flags/1x1/ae.svg` (+1 -1) 📝 `flags/1x1/af.svg` (+1 -1) 📝 `flags/1x1/ag.svg` (+1 -1) 📝 `flags/1x1/ai.svg` (+1 -1) 📝 `flags/1x1/al.svg` (+1 -1) 📝 `flags/1x1/ao.svg` (+1 -1) 📝 `flags/1x1/aq.svg` (+1 -1) 📝 `flags/1x1/ar.svg` (+1 -1) 📝 `flags/1x1/as.svg` (+1 -1) 📝 `flags/1x1/at.svg` (+1 -1) 📝 `flags/1x1/au.svg` (+1 -1) 📝 `flags/1x1/aw.svg` (+1 -1) 📝 `flags/1x1/ax.svg` (+1 -1) 📝 `flags/1x1/az.svg` (+1 -1) 📝 `flags/1x1/bb.svg` (+1 -1) 📝 `flags/1x1/bd.svg` (+1 -1) 📝 `flags/1x1/be.svg` (+1 -1) 📝 `flags/1x1/bf.svg` (+1 -1) 📝 `flags/1x1/bg.svg` (+1 -1) _...and 80 more files_ </details> ### 📄 Description Hey, great stuff! We needed to have the viewBox set, and found that not all flags have that. So we wrote a simple (read: dumb) little script that adds the viewBox to those SVG's that didn't have any yet. To be sure we wrote it very defensively, so it doesn't change the file if: - There is already a `viewBox` attribute present, OR - Our dumb regex doesn't match (this happens for instance when the width and height properties are reversed in order) OR - The width and height properties are not (640 x 480) or (512 x 512) Despite these limitations, the script still works pretty well, we managed to add the viewBox to 473 files. Here's the script's output, showing which files it was unable to update: - [/flags/1x1/am.svg](https://raw.githubusercontent.com/lipis/flag-icon-css/master/flags/1x1/am.svg) Already a viewBox present. - [/flags/1x1/ba.svg](https://raw.githubusercontent.com/lipis/flag-icon-css/master/flags/1x1/ba.svg) Already a viewBox present. - [/flags/1x1/bq.svg](https://raw.githubusercontent.com/lipis/flag-icon-css/master/flags/1x1/bq.svg) Already a viewBox present. - [/flags/1x1/cn.svg](https://raw.githubusercontent.com/lipis/flag-icon-css/master/flags/1x1/cn.svg) Already a viewBox present. - [/flags/1x1/ge.svg](https://raw.githubusercontent.com/lipis/flag-icon-css/master/flags/1x1/ge.svg) Already a viewBox present. - [/flags/1x1/gg.svg](https://raw.githubusercontent.com/lipis/flag-icon-css/master/flags/1x1/gg.svg) Already a viewBox present. - [/flags/1x1/hn.svg](https://raw.githubusercontent.com/lipis/flag-icon-css/master/flags/1x1/hn.svg) Already a viewBox present. - [/flags/1x1/je.svg](https://raw.githubusercontent.com/lipis/flag-icon-css/master/flags/1x1/je.svg) Already a viewBox present. - [/flags/1x1/ls.svg](https://raw.githubusercontent.com/lipis/flag-icon-css/master/flags/1x1/ls.svg) Already a viewBox present. - [/flags/1x1/me.svg](https://raw.githubusercontent.com/lipis/flag-icon-css/master/flags/1x1/me.svg) Already a viewBox present. - [/flags/1x1/mm.svg](https://raw.githubusercontent.com/lipis/flag-icon-css/master/flags/1x1/mm.svg) Already a viewBox present. - [/flags/1x1/pn.svg](https://raw.githubusercontent.com/lipis/flag-icon-css/master/flags/1x1/pn.svg) Already a viewBox present. - [/flags/1x1/py.svg](https://raw.githubusercontent.com/lipis/flag-icon-css/master/flags/1x1/py.svg) Unexpected dimensions 513 512 - [/flags/1x1/rs.svg](https://raw.githubusercontent.com/lipis/flag-icon-css/master/flags/1x1/rs.svg) Couldn't match. - [/flags/1x1/ss.svg](https://raw.githubusercontent.com/lipis/flag-icon-css/master/flags/1x1/ss.svg) Already a viewBox present. - [/flags/1x1/tj.svg](https://raw.githubusercontent.com/lipis/flag-icon-css/master/flags/1x1/tj.svg) Couldn't match. - [/flags/1x1/tk.svg](https://raw.githubusercontent.com/lipis/flag-icon-css/master/flags/1x1/tk.svg) Already a viewBox present. - [/flags/1x1/ve.svg](https://raw.githubusercontent.com/lipis/flag-icon-css/master/flags/1x1/ve.svg) Already a viewBox present. - [/flags/4x3/ae.svg](https://raw.githubusercontent.com/lipis/flag-icon-css/master/flags/4x3/ae.svg) Already a viewBox present. - [/flags/4x3/af.svg](https://raw.githubusercontent.com/lipis/flag-icon-css/master/flags/4x3/af.svg) Already a viewBox present. - [/flags/4x3/am.svg](https://raw.githubusercontent.com/lipis/flag-icon-css/master/flags/4x3/am.svg) Already a viewBox present. - [/flags/4x3/aq.svg](https://raw.githubusercontent.com/lipis/flag-icon-css/master/flags/4x3/aq.svg) Already a viewBox present. - [/flags/4x3/ax.svg](https://raw.githubusercontent.com/lipis/flag-icon-css/master/flags/4x3/ax.svg) Already a viewBox present. - [/flags/4x3/ba.svg](https://raw.githubusercontent.com/lipis/flag-icon-css/master/flags/4x3/ba.svg) Already a viewBox present. - [/flags/4x3/bq.svg](https://raw.githubusercontent.com/lipis/flag-icon-css/master/flags/4x3/bq.svg) Already a viewBox present. - [/flags/4x3/cn.svg](https://raw.githubusercontent.com/lipis/flag-icon-css/master/flags/4x3/cn.svg) Already a viewBox present. - [/flags/4x3/ge.svg](https://raw.githubusercontent.com/lipis/flag-icon-css/master/flags/4x3/ge.svg) Already a viewBox present. - [/flags/4x3/gg.svg](https://raw.githubusercontent.com/lipis/flag-icon-css/master/flags/4x3/gg.svg) Already a viewBox present. - [/flags/4x3/hn.svg](https://raw.githubusercontent.com/lipis/flag-icon-css/master/flags/4x3/hn.svg) Already a viewBox present. - [/flags/4x3/je.svg](https://raw.githubusercontent.com/lipis/flag-icon-css/master/flags/4x3/je.svg) Already a viewBox present. - [/flags/4x3/ls.svg](https://raw.githubusercontent.com/lipis/flag-icon-css/master/flags/4x3/ls.svg) Already a viewBox present. - [/flags/4x3/me.svg](https://raw.githubusercontent.com/lipis/flag-icon-css/master/flags/4x3/me.svg) Already a viewBox present. - [/flags/4x3/mm.svg](https://raw.githubusercontent.com/lipis/flag-icon-css/master/flags/4x3/mm.svg) Already a viewBox present. - [/flags/4x3/pn.svg](https://raw.githubusercontent.com/lipis/flag-icon-css/master/flags/4x3/pn.svg) Already a viewBox present. - [/flags/4x3/rs.svg](https://raw.githubusercontent.com/lipis/flag-icon-css/master/flags/4x3/rs.svg) Couldn't match. - [/flags/4x3/ss.svg](https://raw.githubusercontent.com/lipis/flag-icon-css/master/flags/4x3/ss.svg) Already a viewBox present. - [/flags/4x3/tj.svg](https://raw.githubusercontent.com/lipis/flag-icon-css/master/flags/4x3/tj.svg) Couldn't match. - [/flags/4x3/tk.svg](https://raw.githubusercontent.com/lipis/flag-icon-css/master/flags/4x3/tk.svg) Already a viewBox present. - [/flags/4x3/ve.svg](https://raw.githubusercontent.com/lipis/flag-icon-css/master/flags/4x3/ve.svg) Already a viewBox present. As you see, quite a few of the flags already had a viewBox set. We were not sure whether these were all correct. For instance `4x3/am.svg` shows: `height="480" width="640" viewBox="0 0 0.5160635 3.096381"`. We know too little of SVG's to say whether this works as expected. Funnily, `1x1/py.svg` has dimensions of `513x512`. Typo? Finally, you can check the script yourself in https://github.com/dsempel/flag-icon-css/tree/viewbox ``` npm install ``` to get our dev dependencies, and ``` npm run addViewBox ``` to run the script. Let us know what you think! --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-03 14:40:28 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/flag-icons#727
No description provided.