ComputerGhost / FaviconFetcher

Scan a webpage for favicons, or just easily download the one you want.
MIT License
5 stars 3 forks source link

Distance calculation sometimes results in poor quality image #19

Open kiddailey opened 4 months ago

kiddailey commented 4 months ago

Use case

Display an icon at 64x64, using the best possible quality from the icons available, and always display an icon if any are available.

For example, let us say that I specify the following:

And let's also say that a site provides the following icon types:

For the request with my above min/max/perfect parameter, FaviconFetcher will return the 16x16 image due to the distance calculation:

Queue Size Distance
16x16 -67.88
120x120 -79.20

However, in this sample use-case, scaling the 16x16 up to 64x64 would look terrible, especially when a much better result would come from scaling down the 120x120.

Feature Request

Alternatives

Thoughts?

kiddailey commented 4 months ago

As a workaround for this, I've implemented a change to the IconImage.Save() method with PR #24 that can take an additional "size" parameter. In this way, the caller can scale the image proportionally when saving.

It's not perfect as the Fetcher will still be storing a collection of potentially large images in memory, but feels like a good compromise for the time being.

Edit: I moved the code for this into the SVG support branch and pull request as I needed it there anyway and closed the original PR. Keeping this open for discussion on the original idea.

Also SkiaSharp's Resize method isn't the best :/