New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@chipcode/image-loader

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chipcode/image-loader

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

  • 0.2.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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.

Keywords

FAQs

Package last updated on 04 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc