Everything about favicon, Apple touch icon and RealFaviconGenerator
Author: Philippe Bernard
I'm a web developer and the author of RealFaviconGenerator. I created this site because I felt frustrated when I tried to generate the favicon of my previous web project.
When RFG was released 3 years ago, it barely had more than a few pages. So it started with no navigation at all if not for a few links in the footer of each page.
With its modules for Gulp, Grunt, RoR and others, with its API and other pages, the footer was definitely not enough to handle all this content. So here it comes: a Navigation Bar. And that’s fantastic.
And the old header (with a big RFG logo) is gone, leaving more room for the content. Oh, and what about the ad that used to be in the top right corner of each page? It’s gone, too.
Did you see the latest favicon package created by RealFaviconGenerator? It’s only 5 lines of HTML!
The initial promise: support everything
RealFaviconGenerator was created with the intent of providing support for all platforms. Not only a single favicon.ico for desktop browsers, as other generators did at the time. To achieve this goal, it generated as many icons as possible: all icons for iOS, from the very first iPhone to the latest iPad. All tile icons for Windows 8 and 10. All icons for Android Chromes. And support for all known platforms, such as Google TV.
The outcome? 20 lines of HTML code and almost 30 icons.
Old package. Loads of icons.
The promise was fulfilled: follow RealFaviconGenerator’s instructions and you actually support everything.
This package has become a kind of reference. Soon after the release of RealFaviconGenerator, half a dozen of generators were created. All took this code snippet as a reference. Some existing generators followed the same path.
Although that was a good start, this package was not satisfying. If you’re like me, you don’t like this huge HTML snippet. In particular, the repetitive Apple Touch icon declarations. Too much lines, and also too similar. Something was wrong.
The new deal: support everything, and keep it pragmatic
When RFG was written, support for all platforms was the big plan. This came with a drawback: this huge bunch of HTML lines and this set of files you didn’t want to put in your root directory. This is because two points were completely left behind.
Some platforms don’t deserve to be supported
Whatever the audience of your website, you want support for all major browsers and platforms. Windows Firefox. iOS Safari. Internet Explorer. Android Chrome. And all the others. But some platforms simply don’t deserve support (or not anymore).
The first victim here is Google TV. It’s 96×96 PNG icon is not generated anymore. That’s final. This product didn’t succeed, plus the original reference that described the icon is gone. “Okay but this icon didn’t hurt, why removing it?” Well, it had side effects. Because Firefox loads too many icons, you could have your almost-never-useful 96×96 Google TV icons loaded by your visitors using Firefox. Thus the cost was much higher than the benefit.
There are also deprecated icons. Android Chrome M38 and prior used to pick a 192×192 icon declared in the HTML code. Current version is M51 and it doesn’t need this declaration anymore. And remember the issue with Firefox? Yep, this 192×192 icon was also regularly loaded by FF. So this declaration is gone (although the icon itself is still present and declared by the Web App manifest).
Last item of this list is the tile icon for Windows 8.0 and IE 10. Windows 8.0 has a market share of 2.62% and no chance of growing. This is very low compared to the 26% share of Windows 8.1 and 10 combined. It is not effective to use two lines of HTML code for such platform when W8.1/10 use only one, or even none when browserconfig.xml is in the root directory.
Platforms don’t need all icons
Apart from a few exotic ones, all platforms and browsers must be supported. So how can we significantly reduce the size of the package? An obvious answer, for a given icons family, is to generate only a single, high resolution icon. For example, could we create only a single 180×180 Apple Touch icon, instead of the full range, starting at 57×57? The answer comes in two parts.
First, yes, iOS devices can deal with a high resolution icon. They are able to scale it down to fit their screen (think: non-Retina screens, small screens…). That was the obvious part.
So iOS can scale icons down, but does it do it well? This is not trivial. We could suppose iOS is using a fast, lightweight scaling algorithm, such as nearest neighbor. That would make sense. But if this hypothesis was true it would lead to poor results when an iPad Mini turns a 180×180 icon to a 144×144 one. Tests were run and the conclusion was: iOS does a great job art scaling down. It does as well as any image edition tool such as Photoshop, or ImageMagick to name the tool behind RFG. All in all, by providing a single, high resolution icon, we support all iOS devices and we support them well.
Windows tiles are another story. Microsoft defines four icons, which serve different styles: three squares icons (small, medium and big) and a rectangular icon. While RFG used to create the full set, it now produces only the medium, square icon. That should be enough for most web sites.
In the end, the new code is only 5 lines of HTML. And we still support everything. No catch with Firefox. This is much better.
New package. Five lines of pure satisfaction.
Creating a smaller package is the best solution for most websites and developers. However, there are a few drawbacks. What if you want the four Windows tiles icons? What if you are concerned with 404 when iOS devices keep asking for Touch icons in the root directory? (don’t know what this is? Check your server’s logs and look for /apple-touch-icon and 404. See?). All icons and HTML markups are still available, only a few clicks away.
From 1 to 17 icons with only thee clicks
Actually, RealFaviconGenerator will give you up to 40 files if you ask for everything. Hurray!
RealFaviconGenerator is not a mere claim, a promise that all these icons will (probably) find they way in the tabs, bookmarks and home screens or your visitors. The generated code and icons are actually tested before being released.
The compatibility test
RealFaviconGenerator quality starts with the favicon compatibility test. This is a three-forms process that allows anyone to test the generic package created by RFG on his own device(s). The test exposes your browser to two scenarios:
Favicons files are in the root directory of the web site
Favicon files are in a sub-directory
Basically, you visit a random site which is equipped with RFG’s code, do a few operations (add to bookmark, add to home screen…) and note the results. When it’s done, I get an email.
Different pics
It’s not enough to check that the tested browser displays an icon. We must find out which icon is displayed. Does Windows Firefox takes a PNG icon declared with a link tag or one of the embedded icons of favicon.ico? Does Android Chrome really takes the icons declared in the Web App manifest or an Apple Touch icon? To be certain, the compatibility test comes with different icons, so you can quickly see which one is chosen.
Which icon does Windows Chrome use?Apparently, the 32×32 PNG icon
A dedicated domain name
If you play with favicons, you know how browsers can be stubborn regarding caching. Once they load your favicon for the first time, they won’t reload it before a while. So annoying. For this reasons, the compatibility test is always mounted on a particular domain name, so that each test is run in isolation. At the time of writing, the first test is located on test01-v0-13-attempt-5.test.realfavicongenerator.net. As the name says, we are testing the upcoming package v0.13, and this is the 5th attempt.
Running the tests
Tests are run by generous contributors. Simply go to https://realfavicongenerator.net/favicon_compatibility_test and take the two-minutes tour. When a release is incoming, a little tweet usually ask for help.
Would you help testing the next version? We need non cutting edge devices such as iPhone 4, first generation iPad… https://t.co/2Oti6bkkdA
— RealFaviconGenerator (@RealFavicon) 29 juin 2016
Before a release, there is always a special trip to an Apple Store in order to fill the empty cells.
“Hello Sir, So you are interested in iPads?” “Leave me alone, I’m in the middle of my favicon test session”
Photoshop is a great tool. Use it and you can expect your pictures to be just perfect. Well, almost perfect.
Let’s see what Apple got when they created their own Touch icon:
$ wget -o apple-icon.png http://www.apple.com/apple-touch-icon.png
$ ls -l
-rw-rw-r-- 1 philippe philippe 4506 Aug 12 2015 apple-icon.png
4506 bytes for a Touch icon? Sounds legit. Now let’s have a look to its metadata:
$ exiftool apple-icon.png
ExifTool Version Number : 9.46
File Name : apple-icon.png
Directory : .
File Size : 4.4 kB
File Modification Date/Time : 2015:08:12 19:51:29+02:00
File Access Date/Time : 2016:05:17 17:00:31+02:00
File Inode Change Date/Time : 2016:05:17 17:00:31+02:00
File Permissions : rw-rw-r--
File Type : PNG
MIME Type : image/png
Image Width : 152
Image Height : 152
Bit Depth : 8
Color Type : RGB
Compression : Deflate/Inflate
Filter : Adaptive
Interlace : Adam7 Interlace
Software : Adobe ImageReady
XMP Toolkit : Adobe XMP Core 5.5-c021 79.155772, 2014/01/13-19:44:00
Original Document ID : xmp.did:15d8a979-1097-4474-accc-90fc2b02fc58
Document ID : xmp.did:25F46708355311E580E8DA1A4BE6CE82
Instance ID : xmp.iid:25F46707355311E580E8DA1A4BE6CE82
Creator Tool : Adobe Photoshop CC 2014 (Macintosh)
Derived From Instance ID : xmp.iid:d4dcd418-cd4f-4a8e-a9eb-670e43ff2ee8
Derived From Document ID : adobe:docid:photoshop:3a0c5b59-7dbd-1178-bb27-91c7aa683e3f
Image Size : 152x152
Apparently, this icon was generated by Photoshop.
These are a lot of information… What happens if we remove all EXIF data?
$ exiftool -all= -o apple-icon-no-exif.png apple-icon.png
$ ls -l
-rw-rw-r-- 1 philippe philippe 3555 May 17 17:04 apple-icon-no-exif.png
-rw-rw-r-- 1 philippe philippe 4506 Aug 12 2015 apple-icon.png
We’ve just decreased the size of the Apple Touch icon by more than 20% just by removing the metadata!
Now let’s do the same of, say, the Alphabet Touch icon, wisely generated by RealFaviconGenerator:
$ wget -O alphabet-icon.png https://abc.xyz/apple-touch-icon-152x152.png
$ exiftool -all= -o alphabet-icon-no-exif.png alphabet-icon.png
$ ls -l
-rw-rw-r-- 1 philippe philippe 3714 May 17 17:09 alphabet-icon-no-exif.png
-rw-rw-r-- 1 philippe philippe 3714 Apr 21 05:17 alphabet-icon.png
(yep, we took the 152×152 version, because this is the size of Apple’s Touch icon)
Now, the image is 3.7KB, with or without EXIF, simply because RFG does not produce verbose metadata.
Okay, it’s not entirely Photoshop’s fault. It probably has options to not be that verbose. Plus you’re responsible of post-processing your assets before deploying them. But if Apple did the mistake, others probably made it too. But at least not RFG users.
Android Chrome behaves almost like iOS: it scales down the icons correctly when it cannot find an icon that exactly matches its screen, producing excellent results using an algorithm similar to Blackman or Lanczos. Just mind special icons, such as pixel art icons that need a particular kind of algorithm such as Nearest Neighbor. But even in that case, Android Chrome offers a decent result.
I made a test with my old Galaxy S5. When Android Chrome is given a manifest declaring all documents icons for homescreen and splashscreen (9 icons, ranging from 36×36 to 512×512), it takes the 144×144 icon for the home screen and 384×384 icon for the splashscreen. Which is a good thing: as it is suggested to declare only two 192×192 and 512×512 icons, the Galaxy S5 is a good candidate to check the scale down in a real life situation.
For this test, I used this sample 512×512 icon and declared it, alone, in a manifest:
Android Chrome original 512×512 icon
Here is what my Galaxy does with it:
Added to home screen : the icon is now 144×144Splash screen, the image is now 384×384
In both cases, we can see that the results are great (despite of my suboptimal choice of theme and background colors).
As for iOS, I couldn’t find an exact match with any of the 40 algorithms provided by ImageMagick. The closest ones are Blackman, then Lanczos.
Visually, I can’t see any difference between what Chrome creates and the 512×512 icon resized to 144×144 by ImageMagick with Blackman and Lanczos:
What about a pixel-art icon, one that shouldn’t be interpolated?
512×512, pixel art icon
It’s okay, really:
A pixel art icon added to home screenPixel art icon splashscreen
As with iOS, you can spot differences between what you get and what you could expect by providing the icon with the right size (eg. 384×384 for splashscreen and my Galaxy S5) and scaled with the right algorithm (eg. Nearest Neighbor). But it’s no big deal.
When iOS Safari encounters an Apple Touch icon too large for the screen, it scales it down. Which scaling algorithm does iOS use for this task? It’s not clear. Maybe something close to Lanczos2. The main issue is when the icon requires a particular algorithm, such as Nearest Neighbor: iOS doesn’t exactly produce the expected result. But it’s no big deal.
What is the problem?
There are a lot of Apple Touch icons, ranging from 57×57 to 180×180. If you really want the full story, you can generate up to almost 20 icons! However, when an icon is missing, that’s not a blocking issue. iOS scales the icon down.
As suggested by several users and “summarized” in issue #211, it would be great to generate only one Touch icon (or only a few ones) and let the devices do the scaling. Issue solved, right?
Not so fast. There is one tiny question to answer before dropping almost redundant 20 icons: how good is iOS at resizing pictures?
Finding iOS scaling algorithm
The methodology:
Create a sample 180×180 icon with a diagonal line in it:
Push this image in a web site and add it to the home screen of my iPad Mini running iOS 9:
Here, iOS resizes the pic to 76×76.
Crop the rounded corners to remove all traces of background:
For each algorithm supported by ImageMagick (come on, more than 40!), repeat the same steps with Image Magick commands (ie. scale with the tested algorithm and crop the result), then compare iOS and ImageMagick.
And the result is… iOS doesn’t use any of the algorithms offered by ImageMagick. After studying the results returned by the ImageMagick’s compare command, this is apparently close to Lanczos2. But it’s not exactly the same. In other words, iOS applies a small anti-aliasing effect. Most of the times this is just fine.
Small issue with specific Apple Touch icons
Some images require a specific scaling algorithm. For example, you don’t want the classic scaling with pixel art pictures. Quite the contrary, you want to retain the pixelization. In this case, iOS doesn’t do what you want.
When we zoom the icons, there is clearly a difference:
On the left, a 180×180 icon scaled down by iOS. On the right, a 76×76 icon prepared with RFG and the Nearest Neighbor alforithm.
Yet, at normal scale, it’s nearly not visible. I frankly can’t see the difference between the two:
On the left, a 180×180 icon scaled down by iOS. On the right, a 76×76 icon prepared with RFG and the Nearest Neighbor alforithm.
Conclusion
If you are careful enough to pick a particular scaling algorithm when generating your icons (eg. Nearest Neighbor), then you might want to keep all the icons to make sure your visitors really get the icon you want. Else, you can safely drop smaller icons. iOS will do just well.
Creating a favicon should always be a quick and easy task. This is the promise of the Gulp plugin for RealFaviconGenerator. When using this plugin, you don’t have to learn RealFaviconGenerator’s API. Instead, go to RealFaviconGenerator.net and create your favicon as usual. In the result page, click the Gulp tab.
Here, you find step-by-step instructions to setup your favicon in your Gulpfile. A few minutes later, your favicon is fully integrated to your Gulp build!
You have three Gulp tasks at hand:
generate-favicon: the task you run once and each time there is an update on RealFaviconGenerator.
inject-favicon-markups: the task you run constantly, each time you modify one of your pages.
check-for-favicon-update: the task you run from time to time to make sure your favicon is up-to-date.
A year ago, the GruntJS plugin for RealFaviconGenerator was released. The plugin itself was usable, but it missed one important feature: the ability to be used easily, without reading RealFaviconGenerator’s API and testing.
Want to handle favicon with Grunt? Here is how to do it:
On the next page, follow the instructions. A copy/paste later, your Grunt project is ready.
I’m confident this feature will have success, at least in the long run, because:
It is about Grunt, which is one of the tools that make web development more professional. For years, manual, error prone deployment has been the norm, and this is still a common practice. In a few years, these bad habits will be over, at least among professionals.
It is about serious asset management. A few years ago, the regular way of adding jQuery to a project was to download it manually and putting its files right in the middle of the homemade material. Now more ad more people use Bower or other tools to manage these resources. It should be the same for the favicon and related icons: getting a favicon.ico and dropping it somewhere in the website project is (should be) a practice from the past.
As a mundane task, favicon should be done quickly. We spend hours crafting HTML pages, tailoring CSS and writing unit tests. But how much time would you dedicate to the favicon? Only a few minutes. This is a small task by nature. Anything that excess 5/10 minutes is flawed.
RFG addresses all this points.
Monetization
Right now, you can use this new feature for free. However, this won’t last. As I announced it in January, I want to make money with RealFaviconGenerator. I have run ads for months and the conclusion is: ads don’t even pay for the hosting costs. I actually makes more money from donations (thank you all!!), which are greatly appreciated but not very significant in total.
So I want to offer additional, paid options. What I told a few months ago still apply: what was free will remain free. We are only talking about new stuff.
Right now, I don’t know which model is the best: a classic subscription or pay-as-you-go? This is the purpose of the feedback form showed just after the instructions for Grunt:
The first question was about the platforms you would like RFG to support. The winner is… the Open Graph image, used by Facebook when you share a page.
Beyond the raw results, the social networks are the undisputed winners. Most votes for Coast and Yandex were from people who voted for everything. Whereas many feedbacks were only for OG and Twitter, or OG alone.
Options
Three options were proposed:
Small pictures: RFG resizes pictures as needed to generate the icons. Regarding small icons (16×16 and 32×32), it is sometimes better to edit them manually, or to draw them pixel-by-pixel. RFG would allow you to upload your very own custom 16×16 and/or 32×32 icon(s).
Smaller package: RFG generates 20-something icons and about 15 lines of HTML. Many people don’t want to clutter their HTML with so much code. RFG could create much less with very few side effects.
Embedded instructions: The instructions to setup your favicon (and the HTML) are given by RFG web site. The Zip file itself contains only the images and related files. In other words, the package is not standalone: if you leave RFG too soon, you end up with a useless archive. The package could contain a text file to remind the instructions.
Embedded instructions is the most wanted option. I thought most people would want a smaller package, while I considered the embedded instructions as a nice-to-have. I was wrong, and that’s the point of asking for opinions.
Tools and framework
This is my favorite part. There were less votes here, only 17. I was not surprised: the form was in the result page, where the user is presented the material he came for: the package and HTML code. Most people probably didn’t want to hear about anything else. But I could feel the interest is real. Unlike the platform and options forms, where several users selected everything, all votes here were for one tool or framework. So I could really hear a visitor asking for his favorite solution.
The winner is Grunt, by a short advance. Gulp and Ruby on Rails were nearly as popular. Symfony got no vote, but that’s okay. The test was run for only 3 days (1st day was a Sunday) and the question was asked to people who didn’t come for this.
I’ve just started something I should have done long ago: survey users for direct feedback.
During a few days, you will find three forms right in the interface of RealFaviconGenerator. The first one is about the supported platforms.
The second one is about options. Here you will find usual suspects (at least from my point of view).
The third one is for integration. RFG generate HTML, but this is not the only way. What do you use? Build tools such as Gulp? Framework like Ruby on Rails?