Flag icons for user location - lichess-org/lila GitHub Wiki
The list of locations a user can select from is available in modules/user/src/main/Flags.scala The 'flag code' corresponds to 24×24 px images of flags, all stored under public/flags.
We use flags from GoSquared's Flag Icon Set, in the shiny style.
GoSquared's flag icon set has not been updated in many years. If you want to add a flag which follows this style, you can follow this reverse-engineered process for approximating GoSquared's style.
Pre-requisites
This guide uses the following software:- Inkscape to edit SVG
- GIMP to resize and edit PNG
- ImageMagick to apply the shiny overlay
- oxipng to optimise the resulting PNG.
How to generate a flag step-by-step
- Get a high-quality copy of the flag, ideally in SVG. Wikimedia Commons has many of them and usually in the public domain. If they are in the public domain, you do not need to add attributions in the credit.
- Edit the SVG using Inkscape:
- Go to Transform -> Scale and change the height to 106.25%.
If there are any graphic elements on top of the flag like insignia, please scale them separately, increasing both width and height for those to 106.25% also. Re-arrange as needed afterwards - Go to File -> Document Properties... and select 'Resize to content'
- Save the SVG
- Go to Transform -> Scale and change the height to 106.25%.
- Convert SVG to PNG at a high size (this can be done from within Inkscape)
- Edit PNG using GIMP:
- Using scale tool, scale down to 22×16 px, again using 'Linear' interpolation, and Clipping set to 'Crop with aspect'
- Select Image -> Crop to content
- Go Image -> Canvas size and set to 24×24 px. Click 'Centre' on the flag, and then 'Resize'
- Save the PNG (using the 'Export' or 'Overwrite' functions under the File menu)
- Get the 24 px shiny overlay from GoSquared: https://github.com/gosquared/flags/tree/master/src/overlays/normal
- Apply the overlay: Run
magick composite 24.png YOUR_FLAG_NAME.png FINAL_FLAG_NAME.pngto apply shiny overlay onto your flag - Optimise the PNG: Run
oxipng -o maxon the final output to make it as small as possible.