FaviconFetcher 1.4.0

dotnet add package FaviconFetcher --version 1.4.0                
NuGet\Install-Package FaviconFetcher -Version 1.4.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FaviconFetcher" Version="1.4.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FaviconFetcher --version 1.4.0                
#r "nuget: FaviconFetcher, 1.4.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install FaviconFetcher as a Cake Addin
#addin nuget:?package=FaviconFetcher&version=1.4.0

// Install FaviconFetcher as a Cake Tool
#tool nuget:?package=FaviconFetcher&version=1.4.0                

Favicon Fetcher

FaviconFetcher contains tools for scanning a webpage for possible favicons (Scanner) and downloading the perfect one (Fetcher).

This library is perfect for non-browsers that need to download a favicon for a webpage.

Features

Favicon fetcher was built to include all needed functionality with ease of use and efficiency in mind.

  • Resources are prioritized and downloaded on demand.
  • Cache shared with other applications (off by default).
  • Supports manifest.json and browserconfig.xml, if linked from the HTML.
  • Easy to use.

Installation

Method 1 (Easy)

  1. Use Nuget Package Manager to install "FaviconFetcher".

Method 2 (Hard)

  1. Download the source code.
  2. Compile it. If compiling as "Release", ignore the errors in the FaviconFetcher.Tests project.
  3. Copy the library file to where you want it.
  4. Add a reference to it from your own project.

How to Use

Common uses are listed below. The full documentation is at https://github.com/ComputerGhost/FaviconFetcher/tree/master/doc. In places where the code differs from the documentation, the documentation is correct.

Fetcher - Find the Best Match

The fetcher will scan a webpage for favicons and download the one that best matches the given constraints.

var fetcher = new Fetcher();
var image = fetcher.FetchClosest(uri, new Size(16, 16));
// Don't forget to dispose of the image when no longer needed.

Other methods include FetchExact and Fetch. See the documentation for the full list and how to use them.

Scanner - Get a List of Favicons

To get a list of possible favicons without downloading any, use the scanner.

var scanner = new Scanner();
foreach (var result in scanner.Scan(uri))
{
    var expectedSize = result.ExpectedSize;
    var absoluteUri = result.Location;
    // do something with it.
}

Keep in mind that an icon may not exist, may be invalid, may be a different size than the one reported, or may be a duplicate. Unlike the fetcher, the scanner does not verify that its results are correct.

HttpSource - Caching

Caching is supported by both the fetcher and the scanner, but it is off by default. To enable caching, pass a configured HttpSource to the constructor.

var source = new HttpSource() {
    CachePolicy = new RequestCachePolicy(RequestCacheLevel.CacheIfAvailable)
};
var fetcher = new Fetcher(source);
var image = fetcher.FetchClosest(uri, new Size(16, 16));
// Don't forget to dispose of the image when no longer needed.

Bug Reports

Please use the Issues tab on our GitHub page to file bug reports. Or, you may contact me directly if you know my contact information.

Credits

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.4.0 1,779 6/11/2023
1.3.1 4,207 4/3/2022
1.3.0 435 4/3/2022
1.2.0 5,786 8/7/2021
1.1.0 522 2/22/2021
1.0.1 1,350 12/7/2018
1.0.0 720 11/18/2018

- Replaced System.Drawing with SkiaSharp for portability.
- Changed default user agent because "fetch" is blocked by some sites.
- Fixed a bug with extracting multiple icons from ico files.