JonathanTheDev

Hi esoteric software team!

We recently updated our Photoshop to Spine script to the latest version [7.21], to fix some issues we had with skins. But since updating, the time it takes to export has grown substantially. It used to take around 5-10 minutes to export our Photoshop file and it now takes more than 50 minutes, which makes it difficult to do quick iterations.

I've tracked it down to be the trim code changed in version [7.19]. The new activeDocument.trim() methods are much slower than the old crop methods. Looking at the commit name and the comments added, it seems that the change was due to layer bounds not being tight when using layer styles.

This change totally makes sense, but looking through the Photoshop scripting API it seems that layer also has another bounds property, which might fix this. Layers have a property named boundsNoEffects, which sounds like it might fix the problem. Though I'm not sure, since we haven't experienced any problems with trimming in our setup. Or maybe I don't understand the whole situation, since I'm not to familiar with Photoshop. I guess you have a test setup, which you can try this solution on.

As a temporary fix to speed up our setup, we've reverted the trim code to use crop and changing this line in the Layer class.
From this:
var bounds = this.get("bounds", "ObjectValue");
To this:
var bounds = this.get("boundsNoEffects", "ObjectValue");
I hope this could help speed up trimming again :)

Kind regards,
Jonathan - Programmer at Triple Topping Games
JonathanTheDev
  • Bài viết: 8

Nate

Thanks for the tip, we'll take a look!

The bounds field seems to add an arbitrary amount of space around the actual bounds. It doesn't even match the space needed for effects, it's just very inaccurate. Hopefully boundsNoEffects is better. Worst case we could have a Fast checkbox that cuts some corners at the cost of more whitespace around the output images. That usually isn't a big problem, since it can be stripped in the texture atlas, but it depends on exactly what you are doing. You might need the tighter bounds for reasons. Also I've found myself using the script for lots of things, not just Spine.
Hình đại diện của thành viên
Nate

Nate
  • Bài viết: 11862

JonathanTheDev

Awesome!

A fast / precise option for trimming would be a nice solution too! I think that for most games it wouldn't matter too much if there's a little extra blank space around images. But I can se that sometimes it makes sense, and especially if your using the tool for other things than spine, where you really need it to be tight.
JonathanTheDev
  • Bài viết: 8

Nate

In our testing boundsNoEffects appears to work, at least with the versions of Photoshop we tried. It's terrible to have everything undocumented and not be able to know what works in various versions.

Of course boundsNoEffects cuts off any effects, so doesn't really solve the problem. However, we rasterize the layer styles, so by the time we need to rely on bounds there shouldn't be any effects anyway. The real problem was we need to update the bounds after rasterizing styles. We've done this in 7.22, so we should have the benefit of the faster cropping but still with tightly fitting bounds.

We've tested it with a number of projects and it looks good. Please let us know how it goes for you!
Hình đại diện của thành viên
Nate

Nate
  • Bài viết: 11862

JonathanTheDev

Yeah I'm glad I don't have to work with the Photoshop Scripting API. It's nice that you found a solution that's both fast and precise.

It works perfectly for us! It now takes around 3-4 minutes and the exported images look the same for our project.

Thank you for the fast support :grinteeth:
JonathanTheDev
  • Bài viết: 8


Quay về Bugs