Hearthstone card image repository
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs
pre Add Witchwood release cards. Apr 12, 2018
rel Fix #18: Card Changes - Balance Update February 2019. Feb 12, 2019
.npmignore Add NPM package. Jun 20, 2017
LICENSE Add license. Nov 30, 2016
Makefile Add check script to check validity of JSON/images after creating imag… Apr 5, 2018
README.md Update images.json. Bump version. Feb 12, 2019
RELEASE.md Make tag step simpler. Nov 30, 2018
check.sh Add check script to check validity of JSON/images after creating imag… Apr 5, 2018
create-images.rb Ensure card maps are sorted for consistency. Nov 9, 2018
images.json Update images.json. Bump version. Feb 12, 2019
package.json Update images.json. Bump version. Feb 12, 2019
sync.sh

README.md

Hearthstone Card Images npm

Hearthstone card image repository for use in conjunction with HearthstoneJSON data. Try the demo application. See also 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

Downloading Images

Via compressed archive

This method is best if you wish to use the provided sync.sh script to stay up-to-date.

Setup: Download card images as a .zip or .tar.gz compressed archive from the releases page. Extract and combine card images in the pre (prerelease cards) and rel (released cards) folders into a single card images folder.

Updating: Download and run the sync.sh script to keep your images up-to-date with the latest images in this repo.

curl -LOs https://raw.githubusercontent.com/schmich/hearthstone-card-images/master/sync.sh
# Inspect sync.sh.
bash sync.sh images

sync.sh incrementally downloads card images from the repo to a local directory if the card image has changed or is missing locally. It compares the local file hash to the card image hash stored in images.json. The hash is the 5 character prefix of the base64-encoded SHA1 hash of the image contents.

Via 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: Use git fetch and git reset to update your shallow clone without growing your local git history.

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

Via images.json

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

You can use images.json to fetch card image URLs by DBF ID. It is published as a versioned NPM package that gets updated when cards are added or changed (see versioning).

Example: Using JavaScript to map from a card's DBF ID to its card image URL using images.json:

npm i hearthstone-card-images

// Build map from DBF ID to card image URL.
function indexCardImages() {
  const database = require('hearthstone-card-images');

  let images = {};
  let base = database.config.base;
  let version = database.config.version;
  for (let type in database.cards) {
    for (let id in database.cards[type]) {
      let url = `${base}/${version}/${type}/${id}.png`;
      images[id] = url;
    }
  }

  return images;
}

// Show all available card images.
let images = indexCardImages();
for (let id in images) {
  let url = images[id];
  console.log(`${id} -> ${url}`);
}

Notes

  • 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
  • Released cards are under the rel folder; prerelease cards are under the pre folder
  • For prerelease cards, their name serves as their card ID until they are released
  • Not all cards in HearthstoneJSON's cards.json have a corresponding image
  • Currently, only non-golden en-US card images are available

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.