CLI JSON - "frameTags"->"from"/"to" do not match "frames" when frames are empty and --trim is used #1244

Closed
jameswilddev opened this Issue Sep 2, 2016 · 3 comments

Comments

Projects
None yet
2 participants

jameswilddev commented Sep 2, 2016 edited

When the following file is exported using:

aseprite --batch --trim --list-tags --sheet player.png player.ase --format json-array --data player.json

player.zip

The following JSON file is created:

{ "frames": [
   {
    "filename": "player 0.ase",
    "frame": { "x": 0, "y": 0, "w": 33, "h": 13 },
    "rotated": false,
    "trimmed": true,
    "spriteSourceSize": { "x": 9, "y": 25, "w": 33, "h": 13 },
    "sourceSize": { "w": 64, "h": 64 },
    "duration": 100
   },
   {
    "filename": "player 2.ase",
    "frame": { "x": 33, "y": 0, "w": 14, "h": 33 },
    "rotated": false,
    "trimmed": true,
    "spriteSourceSize": { "x": 22, "y": 18, "w": 14, "h": 33 },
    "sourceSize": { "w": 64, "h": 64 },
    "duration": 100
   },
   {
    "filename": "player 3.ase",
    "frame": { "x": 47, "y": 0, "w": 31, "h": 32 },
    "rotated": false,
    "trimmed": true,
    "spriteSourceSize": { "x": 19, "y": 23, "w": 31, "h": 32 },
    "sourceSize": { "w": 64, "h": 64 },
    "duration": 100
   }
 ],
 "meta": {
  "app": "http://www.aseprite.org/",
  "version": "1.2-beta1",
  "image": "player.png",
  "format": "I8",
  "size": { "w": 78, "h": 33 },
  "scale": "1",
  "frameTags": [
   { "name": "a", "from": 0, "to": 0, "direction": "forward" },
   { "name": "b", "from": 2, "to": 3, "direction": "forward" }
  ]
 }
}

As can be seen, Aseprite has dropped frame (2 in editor, 1 in file) from the "frames" array as it is empty, but the frame ranges in "frameTags" still act as though it is there (three frames have been exported, 0-2, but frames 2-3 are referenced).

I'm not sure this is correct anyway - if a frame is supposed to be empty, even if ranges shift to accommodate dropped frames, the frame will be skipped.

For now I will use --filename-format {frame} and --format json-hash to work around this (I need to determine which items in "frames" correspond to the ranges defined in "frameTags").

jameswilddev changed the title from "frames" and "frameTags"->"from"/"to" lose ordering when frames are empty and --trim is used to CLI JSON - "frames" and "frameTags"->"from"/"to" lose ordering when frames are empty and --trim is used Sep 2, 2016

jameswilddev changed the title from CLI JSON - "frames" and "frameTags"->"from"/"to" lose ordering when frames are empty and --trim is used to CLI JSON - "frames" and "frameTags"->"from"/"to" do not match "frames" when frames are empty and --trim is used Sep 2, 2016

jameswilddev changed the title from CLI JSON - "frames" and "frameTags"->"from"/"to" do not match "frames" when frames are empty and --trim is used to CLI JSON - "frameTags"->"from"/"to" do not match "frames" when frames are empty and --trim is used Sep 2, 2016

dacap added the bug label Sep 2, 2016

dacap added this to the v1.1 milestone Sep 5, 2016

dacap self-assigned this Sep 5, 2016

Owner

dacap commented Sep 5, 2016

Hi @jameswilddev, about this bug, I'm still not yet sure how to fix this issue properly. In this specific case, as the empty frame is outside the tag, it looks like we should completely ignore the empty frame and tag b should adjusted to the range from 1 to 2 (range [1,2]).

Anyway what happens if the empty frame is inside the tag a (i.e. a tag has two frames, [0,1] range)?

screen shot 2016-09-05 at 2 17 55 pm

Should tag a be adjusted to [0,0] range when the frame 1 is trimmed/discarded because it's empty? Or should tag a include the empty frame and in that case the JSON array include an empty frame too (which I'm not sure how it should be specified)?

Owner

dacap commented Sep 6, 2016

I'm still thinking about this. In your specific case the frame tags from/to fields should be adjusted as you said, but in the second case I gave, where the empty frame is inside the frame tag, the frame could be kept with an empty/invalid frame and spriteSourceSize fields (0,0,0,0):

...
    {
    "filename": "player 1.ase",
    "frame": { "x": 0, "y": 0, "w": 0, "h": 0 },
    "rotated": false,
    "trimmed": true,
    "spriteSourceSize": { "x": 0, "y": 0, "w": 0, "h": 0 },
    "sourceSize": { "w": 64, "h": 64 },
    "duration": 100
   }
...
  "frameTags": [
   { "name": "a", "from": 0, "to": 1, "direction": "forward" },
   { "name": "b", "from": 2, "to": 3, "direction": "forward" }
  ]
...

Anyway, in a second thought I'm thinking that information about empty frames might useful in all cases (even in your own case). (e.g. to known the frame duration). Maybe --ignore-empty option might be useful to completely discard the empty frames in these cases. I've to think more about this issue.

dacap closed this in 1c88af5 Sep 6, 2016

Owner

dacap commented Sep 6, 2016

Hi @jameswilddev, in the next release you will be able to fix this issue using --ignore-empty parameter in your command line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment