Git Product home page Git Product logo

spriteextractor's Introduction

SpriteExtractor

When I'm prototyping games, I avoid spending time on art. I do this by grabbing temporary art assets from the internet. However, many of them have inconsistent spacing/padding and are a pain to work with in my engine. This tool fixes that.

Downloads

Pre-built binaries are located in the downloads folder.

Features

  • Optionally pack sprites tightly and generate appropriate metadata
  • Label each frame with its index for easy visual lookup
  • Process entire directories of images (recursively) all at once
  • Absolutely no dependencies
  • Can process PNG, BMP, TGA, GIF, HDR, JPEG (baseline and progressive) via stb_image.h
  • Always generates 4-component PNG images (Yes, this is a feature)

Build

You can use CMake to build this with whatever you want, which means you'll need CMake.

If you're on windows and have Visual Studio 2017 installed:

mkdir bin
cd bin
cmake -G "Visual Studio 15 Win64" ..

will make a 64-bit project which you can open up in VS and build.

If you're somewhere else and you want a makefile for a debug build, for example:

mkdir bin
cd bin
mkdir Debug
cd Debug
cmake -G "Makefile" ../.. -DCMAKE_BUILD_TYPE=Debug

will make a makefile in that directory to build a debug version of the app.

Usage

sprite_extractor -h

Should give you all the usage info. Do note that it samples the top-left pixel of the image to determine the "background" color.

Examples

I turned this

Alt text

into this

Alt text

by doing

sprite_extractor example_images/enemies_zelda_src.png example_images/enemies_zelda.png --frame-width 32 --frame-height 32 -e 5 --dest-width 512 --row-thresh 16 --min-width 4 --min-height 4

And this

Alt text

into this

Alt text

by doing

sprite_extractor example_images/player_zelda_src.png example_images/player_zelda_packed.png --pack 256 128 --frame-width 64 --frame-height 64 -e 2 --min-width 4 --min-height 4 --label --row-thresh 4

Notice how the "wave arcs" are placed into single frames despite them being separated from each other by a certain amount. This occurs because of the edge distance threshold.

I was also able to take these images (see example_images/npcs)

Alt text Alt text Alt text Alt text Alt text

And make

Alt text

by doing

sprite_extractor --dir example_images/npcs example_images/npcs_zelda.png --dest-width 128 --frame-width 32 --frame-height 32 -e 0 --min-width 4 --min-height 4

Notice how some images contained multiple frames and others just one. This is fine, it still detects them as multiple frames even if they're all in the same file, just like it did for the single image examples.

spriteextractor's People

Contributors

goodpaul6 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

longjohncoder

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.