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

@chipcode/image-loader

v0.2.2

Published

Either a stand alone tool or a plugin to Octopus to load image files

Downloads

9

Readme

CHIPCODE image loader

This tool can be used on the command line or as a plugin to Octopus. It allows you to convert image files into sprite data with labels and bytes, in a format that is compatible with the Octo assembler.

Installing and running

Install as an NPM package, either for a project or globally:

npm install --save-dev @chipcode/image-loader

You can then convert images on the command line:

npx image-loader path/to/some-file.png <optional modifiers>

Which will output the assembly code to stdout.

Or you can use it through Octopus like so:

:include "path/to/some-file.png" <optional modifiers>

Supported file types

This image loader supports all file types that are supported by JIMP, which is used for the file loading under the hood. Currently those file types are:

  • JPEG
  • PNG
  • BMP
  • TIFF
  • GIF

Labels and sprites

Let's say you convert or include, for example, a file called clock.png that is 24 pixels wide and 16 pixels high. Given the dimensions, the image loader will guess that you want to have six 8x8 sprites. So the following labels will be generated, which relate to the X and Y position of the sprite within the image:

  • clock-0-0
  • clock-1-0
  • clock-2-0
  • clock-0-1
  • clock-1-1
  • clock-2-1

So in this example, clock-2-0 is the top-rightmost 8x8 sprite.

If you don't want the image loader to generate these labels, provide the no-labels modifier.

Modifiers

Modifiers are keywords that you provide to the image loader in any order, that influence how it converts your image.

Sprite resolution

The image loader tries to make an educated guess as to what resolution sprites you are trying to get out of the input image. It may not always guess correctly. Provide one of the following strings as a modifier, and the image loader will cut the image into sprites of the requested dimensions:

  • 8x1
  • 8x2
  • 8x3
  • 8x4
  • 8x5
  • 8x6
  • 8x7
  • 8x8
  • 8x9
  • 8x10
  • 8x11
  • 8x12
  • 8x13
  • 8x14
  • 8x15
  • 16x16

No labels

Provide the modifier no-labels to suppress the sprite labels in the output. For example if you don't need the labels because you are dynamically calculating the offsets into the image, they just clutter up your code. And while they don't do any harm, they do unnecessarily make your source files longer.

Debug

Provide the word debug as a modifier to let the image loader output the image to the console, as well as the selected sprite resolution and all the sprites that it has cut from the image. This quickly and easily lets you inspect if the conversion was a success, and everything went as you expected.