Check Trim Sprite then switch Layers does not adjust trimming coordinates

The spritesheet Trim Sprite option works, but if you switch Layers while keeping the export popup open and the sprites differ positions / dimensions across the different layers, trimming won’t refresh and so the new sprites may be wrongly trimmed, sometimes cropped, sometimes there is too much padding around them (I’m not talking about the natural margin that appears due to Trim Sprite taking enough space to work with all frames; even if the sprites don’t move or change size between frames, the trimming old the previously selected layer is preserved).

Interestingly, checking By Grid then unchecking it again will force trimming refresh and fix this.

If your last export was not with Trim Sprite active, you can close the popup, reopen it, select the layer you want to export, then check Trim Sprite. Otherwise, it’s more complicated as the popup will open directly with Trim Sprite checked… You’ll need to either uncheck Trim Sprite, or select the layer you want, to a dummy export to make it the new default export, then do a second export with the fixed trimming.

This applies to any layer export, including Visible and Selected layers.

Reproduction steps:

  1. Draw some objects with very different top-left and width/height (try some rectangles with just a little intersection) on different layers.
  2. Open File > Export Sprite Sheet popup. In Sprite tab, choose some Layers. I recommend to select individual layer of some object located in the top-left.
  3. In Borders tab, check Trim Sprite. This should trim properly, focusing on the top-left area.
  4. Back to Sprite tab, switch selected layer to some object elsewhere. I recommend an individual layer with some object located in the bottom-right, but big enough to have a small part in the previous top-left area.
  5. Note that the sprite is now trimmed, or if it was not touching the previous trimming area, completely invisible.
  6. Back to Sprite tab, uncheck and recheck Trim Sprite. When unchecked you can see the full object, but when checked the problem persists.
  7. Now check By Grid, and uncheck it. This time, the issue was fixed and trimming was refreshed to the new layer’s object’s coordinates.

I have an example .ase file if needed.