npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

dimicon

v0.0.0-beta.1

Published

**D**ocker **Im**age **Icon** - A Rust library for fetching Docker image icons from various sources.

Downloads

84

Readme

dimicon

Docker Image Icon - A Rust library for fetching Docker image icons from various sources.

Crates.io Documentation License: MIT

Features

  • Fetch icons from Docker Hub image logos
  • Fetch icons from Docker Hub organization Gravatars
  • Fetch icons from Docker Official Images (via jsDelivr CDN)
  • Fetch icons from GitHub Container Registry (via GitHub Avatar)
  • Parse Docker image reference strings in various formats

Installation

Add this to your Cargo.toml:

[dependencies]
dimicon = "0.1"
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }

Quick Start

use dimicon::IconService;

#[tokio::main]
async fn main() -> Result<(), dimicon::Error> {
    let service = IconService::new();

    // Get icon for an official image
    let icon = service.get_icon("nginx").await?;
    if let Some(url) = icon.url() {
        println!("nginx icon: {}", url);
    }

    // Get icon for a user/org image
    let icon = service.get_icon("localstack/localstack").await?;
    println!("localstack icon: {:?}", icon.url());

    // Get icon for a ghcr.io image
    let icon = service.get_icon("ghcr.io/astral-sh/uv").await?;
    println!("ghcr icon: {:?}", icon.url());

    Ok(())
}

Supported Registries

| Registry | Icon Source | |----------|-------------| | Docker Hub (docker.io) | Image logo → Org Gravatar → Official Image logo | | GitHub Container Registry (ghcr.io) | GitHub Avatar | | Other registries | Not supported (returns NotFound) |

Image Reference Parsing

The library can parse various Docker image reference formats:

use dimicon::ImageReference;

// Simple image name
let img = ImageReference::parse("nginx")?;
assert_eq!(img.registry, "docker.io");
assert_eq!(img.namespace, "library");
assert_eq!(img.name, "nginx");

// Image with tag
let img = ImageReference::parse("nginx:latest")?;
assert_eq!(img.tag, Some("latest".to_string()));

// User/org image
let img = ImageReference::parse("myuser/myimage:v1.0")?;
assert_eq!(img.namespace, "myuser");

// GHCR image
let img = ImageReference::parse("ghcr.io/owner/app:latest")?;
assert!(img.is_ghcr());

// Custom registry
let img = ImageReference::parse("registry.example.com/namespace/image:tag")?;
assert_eq!(img.registry, "registry.example.com");

Icon Sources

The IconSource enum represents different icon sources:

use dimicon::IconSource;

match icon {
    IconSource::DockerHubLogo { url } => println!("Docker Hub logo: {}", url),
    IconSource::DockerHubOrgGravatar { url } => println!("Org gravatar: {}", url),
    IconSource::DockerOfficialImage { url } => println!("Official image: {}", url),
    IconSource::GhcrAvatar { url } => println!("GitHub avatar: {}", url),
    IconSource::Custom { url } => println!("Custom icon: {}", url),
    IconSource::NotFound => println!("No icon found"),
}

API Overview

IconService

The main service for fetching image icons.

// Create a new service
let service = IconService::new();

// Or with a custom reqwest client
let client = reqwest::Client::builder()
    .timeout(std::time::Duration::from_secs(10))
    .build()?;
let service = IconService::with_client(client);

// Fetch icon
let icon = service.get_icon("nginx").await?;

ImageReference

Parse and inspect Docker image references.

let img = ImageReference::parse("ghcr.io/owner/app:v1")?;

img.is_docker_hub()      // false
img.is_ghcr()            // true
img.is_docker_official() // false
img.docker_hub_repo_name() // "owner/app"
img.full_name()          // "ghcr.io/owner/app:v1"

Convenience Function

For one-off lookups:

let icon = dimicon::get_icon("redis").await?;

How It Works

The library fetches icons using the following priority:

  1. Docker Official Images: Fetches logos from the docker-library/docs repository via jsDelivr CDN.

  2. Docker Hub Images: Queries the Docker Hub media API (hub.docker.com/api/media/repos_logo/v1/) for image logos.

  3. Docker Hub Organizations: Falls back to organization Gravatar via the Docker Hub v2 API.

  4. GitHub Container Registry: Uses GitHub avatar URLs based on the namespace.

Rate Limiting

Docker Hub APIs have per-IP rate limits. For production use, consider:

  • Caching icon URLs
  • Using a proxy service like go-camo for image proxying
  • Implementing request throttling

Examples

Run the basic example:

cargo run --example basic

License

MIT License - see LICENSE for details.