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 🙏

© 2024 – Pkg Stats / Ryan Hefner

hearthstone-card-images

v5.0.2

Published

Hearthstone card images for use with HearthstoneJSON data.

Downloads

30

Readme

Archival Notice

Due directly to the decisions and actions of Blizzard Entertainment, Inc., I will no longer be maintaining this project. The community is free to fork and continue it, but I do not wish to be involved.

Hearthstone Card Images npm

Hearthstone card images for all locales for use in conjunction with the official Hearthstone API or HearthstoneJSON data.

Try the demo application or see related projects.

All card images and names copyright © Blizzard Entertainment, Inc. Hearthstone® is a registered trademark of Blizzard Entertainment, Inc. Hearthstone Card Images is not affiliated or associated with or endorsed by Hearthstone® or Blizzard Entertainment, Inc.

Overview

  • The official Hearthstone API and HearthstoneJSON make Hearthstone JSON card info available
  • Each card has a DBF ID that uniquely identifies it
  • Use this repo to download and cache card images using one of the methods below
  • Use a card's DBF ID to serve its image from your site or app

Downloading Images

Option 1: Using git

This method is best if you wish to use git to stay up-to-date.

Setup: Create a shallow clone of this repo unless you absolutely need the full history. There are a lot of outdated card images that you can avoid altogether if you don't need them.

git clone --depth 1 --branch master --single-branch https://github.com/schmich/hearthstone-card-images

Updating: Update your shallow clone without growing your local git history with the following:

git fetch --depth 1 && git reset --hard origin/master

Option 2: Using JSON manifests

This method is best if you want fine-grained control over downloading and updating images.

Setup: Download the card images as a .zip or .tar.gz compressed archive from the releases page.

Updating: Use the versioned NPM package to track MD5 hashes of each card image for each locale. The package is updated when cards are added, removed, or updated (see versioning).

The package entrypoint points to manifest/all.json which, for each locale, maps each card DBF ID to the MD5 hash of its image contents. This hash can be used to determine if your local copy is up-to-date.

Example:

npm install hearthstone-card-images

function* cardImageHashes() {
    const manifest = require('hearthstone-card-images');

    let base = manifest.config.base;
    let version = manifest.config.version;

    for (let locale in manifest.cards) {
        for (let dbfId in manifest.cards[locale]) {
            let url = `${base}/${version}/cards/${locale}/${dbfId}.png`;
            let hash = manifest.cards[locale][dbfId];
            yield { locale, dbfId, url, hash };
        }
    }
}

for (let card of cardImageHashes()) {
    // Properties:
    //   card.locale => en_US, pt_BR
    //   card.dbfId => 64 (Swipe)
    //   card.url => https://raw.githubusercontent.com/schmich/hearthstone-card-images/5.0.0/cards/en_US/64.png
    //   card.hash => ef4e301fff3ed65b9c21194e8b22d06c (MD5 hash of image contents)
    // Updating:
    //   1. Hash local file using MD5, card.locale, and card.dbfId
    //   2. Compare local file hash to card.hash
    //   3. If missing or different, download card.url locally
}

Image Size Optimization

By default, images are 375x518 PNG format weighing around 100 KB each. A few things can be done to reduce the space and bandwidth needed for storage and transmission:

1. Resize the images

If you don't need large images, you can resize them using ImageMagick or many other image processing toolkits.

magick convert 64.png -resize 50% out.png

2. Use a PNG optimizer

pngquant and pngcrush optimize PNGs by removing extraneous metadata, trying multiple compression methods, and reducing the image's color palette by introducing dithering. Depending on your needs, the quality can be scaled to control the resulting file size.

pngquant 64.png --quality 25 --output out.png

3. Convert the images to JPG

If you don't need transparency, you can convert the images to JPG to save significantly on space. You can also trade off between quality and file size depending on your needs.

magick convert 64.png -background white -flatten -quality 50% out.jpg

4. Convert the images to WebP

The WebP image format has the benefits of JPG compression while also retaining the alpha transparency of PNG. However, this format is not yet supported by all major browsers. WebP has both lossless and lossy modes.

magick convert 64.png -define webp:lossless=true out.webp

magick convert 64.png -quality 75% out.webp

Notes

  • Card images are under the cards folder
  • Images are available for all Hearthstone locales
  • The card image URL is a GitHub asset URL and must not be used as a CDN
  • You must download, cache, and serve images yourself
  • Not all cards with a DBF ID will necessarily have a corresponding image
  • Currently, only non-golden card images are available
  • Pre-release (spoilered) cards will also be under the cards folder since Blizzard now gives them a DBF ID when they are revealed

Versioning

The NPM package adheres to SemVer 2.0.0:

  • The major version changes when the JSON format changes in a breaking way
  • The minor version changes when new cards are added
  • The patch version changes when card images are updated

Related Projects

License

All card images and names copyright © Blizzard Entertainment, Inc. Hearthstone® is a registered trademark of Blizzard Entertainment, Inc. Hearthstone Card Images is not affiliated or associated with or endorsed by Hearthstone® or Blizzard Entertainment, Inc.

All else copyright © 2016 Chris Schmich
MIT License. See LICENSE for details.