Giter Club home page Giter Club logo

export-aseprite-file's Introduction

export-aseprite-file

by David Capello

This is a script that can be used to export the data from a .aseprite file into a JSON + a collection of PNG files. This script will work with Aseprite v1.2.26 and support the future v1.3 to export tilemap/tileset data.

Example

Usage:

aseprite -b map.aseprite -script export.lua

In this example export.lua will create a folder named map with some files inside:

map/
  sprite.json
  image1.png
  image2.png
  tileset1.png

An example of map/sprite.json content:

{
  "filename": "map.aseprite",
  "width": 32,
  "height": 32,
  "frames": [
    { "duration": 0.1 },
    { "duration": 0.15 }
  ],
  "layers": [
    {
      "name": "Group Layer",
      "layers": [
        {
          "name": "Common Layer",
          "cels": [
            {
              "bounds": { "x": 10, "y": 13, "width": 12, "height": 13 },
              "frame": 0,
              "image": "map/image1.png"
            },
            {
              "bounds": { "x": 6, "y": 15, "width": 12, "height": 12 },
              "frame": 1,
              "image": "map/image2.png"
            }
          ]
        }
      ]
    },
    {
      "name": "Tilemap Layer",
      "tileset": 0,
      "cels": [
        {
          "bounds": { "x": 0, "y": 0, "width": 32, "height": 32 },
          "data": "text1",
          "frame": 0,
          "tilemap": {
            "width": 4,
            "height": 4,
            "tiles": [
              0, 1, 2, 3,
              4, 5, 5, 6,
              7, 5, 5, 8,
              9, 10, 11, 12
            ]
          }
        },
        {
          "bounds": { "x": 1, "y": 1, "width": 32, "height": 32 },
          "frame": 1,
          "color": "#f7a547",
          "data": "text2",
          "tilemap": {
            "width": 4,
            "height": 4,
            "tiles": [
              0, 1, 1, 3,
              4, 4, 4, 8,
              4, 4, 4, 8,
              9, 10, 10, 12
            ]
          }
        }
      ]
    }
  ],
  "tilesets": [
    {
      "grid": {
        "tileSize": { "width": 8, "height": 8 }
      },
      "image": "map/tileset1.png"
    }
  ],
  "tags": [
    {
      "name": "Tag A",
      "aniDir": "pingpong",
      "color": "#000000",
      "from": 0,
      "to": 2
    },
    {
      "name": "Tag B",
      "aniDir": "forward",
      "color": "#000000",
      "from": 0,
      "to": 1
    },
    {
      "name": "Tag C",
      "aniDir": "reverse",
      "color": "#000000",
      "from": 1,
      "to": 2
    }
  ],
  "slices": [
    {
      "name": "Slice 1",
      "color": "#0000ff",
      "bounds": { "x": 4, "y": 19, "width": 8, "height": 6 }
    },
    {
      "name": "Slice 2",
      "color": "#0000ff",
      "bounds": { "x": 14, "y": 9, "width": 9, "height": 11 },
      "center": { "x": 1, "y": 1, "width": 7, "height": 9 }
    },
    {
      "name": "Slice 3",
      "color": "#0000ff",
      "data": "text3",
      "bounds": { "x": 17, "y": 23, "width": 8, "height": 7 },
      "pivot": { "x": 4, "y": 2 }
    }
  ]
}

Acknowledges

This project uses json.lua by rxi to export Lua tables to JSON files.

License

This code is distributed under the terms of the MIT license. You can use this code for your own purpose to export the specific data that you need.

export-aseprite-file's People

Contributors

dacap 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

Watchers

 avatar  avatar  avatar  avatar

export-aseprite-file's Issues

Tileset export PNGs have all black index colors

on Aseprite v1.3-rc1
It keeps the transparent flag on the index I chose, but their data is all black and the palette is filled all the way to 255.
I've tested it with regular cel layers and those export their PNGs fine.

Result (tileset2.png)

tileset2
Expected (Done with aseprite's built-in spritesheet export)

sarah-neutral

Here's my aseprite file: sarah-neutral.zip

Problem with exportation.

When a try exporte my .aseprite file, this error appears:
image
all scripts are in my directory, and i can't understend why it appears. Can you help me?

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.