Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Sort FaviconURL by size based on metadata without downloading image data #91

Merged
merged 7 commits into from
Sep 25, 2024

Conversation

will-lumley
Copy link
Owner

This feature introduces the ability to sort FaviconURL entries by their inferred size, based on the metadata (sizeTag) provided in the HTML or web application manifest files. Importantly, this process occurs without downloading the favicon images, allowing for improved performance when selecting the largest or smallest favicon available.

Sorting by Size Without Downloading
• New methods largest() and smallest() allow users to sort favicons by size based on the sizeTag metadata, without downloading the images first.
• This enables more efficient selection of favicons, especially in cases where downloading all images would incur unnecessary overhead.

Metadata-Based Sorting
• Sorting relies on the sizeTag attribute, which indicates the size of the favicon in the HTML or manifest.
• If the sizeTag is not correctly provided or missing, the feature will fall back to default handling.

Limitations
• Sorting accuracy depends on the presence and correctness of the sizeTag metadata. If metadata is incorrect or missing, the actual image size may differ from what’s indicated.
• This feature is most useful when the source provides accurate metadata for favicon dimensions.

Usage

let faviconURLs = try await FaviconFinder(url: url)
    .fetchFaviconURLs()

// Find the largest favicon URL without downloading the image
let largestFavicon = try await faviconURLs.largest()

// Find the smallest favicon URL
let smallestFavicon = try await faviconURLs.smallest()

// Download the largest favicon after sorting
let favicon = try await largestFavicon.download()

// Or, more simply:

let largestFavicon = try await FaviconFinder(url: url)
    .fetchFaviconURLs()
    .largest()
    .download()

@will-lumley will-lumley linked an issue Sep 25, 2024 that may be closed by this pull request
@will-lumley will-lumley merged commit 70b327a into main Sep 25, 2024
5 checks passed
@will-lumley will-lumley deleted the tech/sort-sizes branch September 25, 2024 04:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fastest Way To Get Favicon With Sizes
1 participant