Giter Site home page Giter Site logo

favicon_factory's Introduction

FaviconFactory

Tired of managing dozens of favicons to support all the browsers, resolutions, and formats?

favicon_factory generates from an SVG the minimal set of icons needed by modern browsers.

The source SVG is ideal for modern browsers. And it may contain a <style> tag with @media (prefers-color-scheme: dark) to support light/dark themes, which is ignored when generating favicons.

Icons will be generated in the same folder as the source SVG unless already existing:

  • favicon.ico (32x32) for legacy browsers; serve it from /favicon.ico because tools, like RSS readers, just look there.
  • apple-touch-icon.png (180x180) for Apple devices when adding a webpage to the home screen; a background and a padding around the icon is applied to make it look pretty.
  • manifest.webmanifest that includes icon-192.png and icon-512.png for Android devices; the former for display on the home screen, and the latter for the splash screen while the PWA is loading.

Users

Installation

Vips or ImageMagick+Inkscape are required. If both are present, FaviconFactory defaults to Vips.

Vips:

brew install vips
sudo apt-get install libvips
sudo apt-get install libvips-tools

ImageMagick and Inkscape:

brew install imagemagick
brew install inkscape
sudo apt-get install imagemagick # for v7 consider https://github.com/SoftCreatR/imei/
sudo apt-get install inkscape

Add favicon_factory to the Gemfile:

bundle add favicon_factory

Or just install the executable:

gem install favicon_factory

Usage

To generate the favicons (see samples/ for an example set):

favicon_factory samples/favicon.svg

# Info: Generating samples/favicon.ico
# Info: Generating samples/icon-192.png
# Info: Generating samples/icon-512.png
# Info: Generating samples/apple-touch-icon.png
# Info: Generating samples/manifest.webmanifest
# Info: Add the following to the `<head>`
#   <!-- favicons generated with the favicon_factory gem -->
#   <link rel="icon" href="/favicon.svg" type="image/svg+xml">
#   <link rel="icon" href="/favicon.ico" sizes="32x32">
#   <link rel="apple-touch-icon" href="/apple-touch-icon.png">
#   <link rel="manifest" href="/manifest.webmanifest">

To show all the options:

favicon_factory --help

Development

After checking out the repo, run bin/setup to install the dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub.

License

The gem is available as open source under the terms of the MIT License.

Credits

This gem was inspired by an article on Evil Martians.

favicon_factory's People

Contributors

3v0k4 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.