• Editor
  • Trim option in Photoshop Script requested

Hello 🙂

Is it possible to get an option in the Photoshop Scripts "LayersToPNG", for adding margin to trimmed images?
We create our games in HTML5 Canvas and if we rotate GFX, which is completely trimmed, on Canvas, the GFX creates an odd anti-aliasing issue in some areas.

Before Spine we always exported the GFX with 1-3px transparency margin, but it takes forever doing it manually, comparing it to the export script.

Hope you guys can help us out 🙂

Related Discussions
...
  • 編集済み

Wonderful news, that you have worked on it 😃

However, i had a bit of issues running the script. The first couple of times i ran it, the script produced some really odd cropped images of my character. I closed Photoshop and Spine, and tried again and then it cropped it out as it should. With the margin. Wonderful!

But for some odd reason it dosen't produce any JSON, even though the "Write Spine JSON" option in the script dialong has been enabled. Any idea what happens?

Very strange. Not sure what to say, it creates the JSON for me every time (Photoshop CS6 13.0 x64). Anyone else with the issue?

It's probably failing on some layers, can't check right now but if you run the script from the extendscript toolkit (I think its called) you can debug it and see if it pops up any errors.

This morning i downloaded the newest script and started over; and the scriptet acted up again. The no-JSON situation haven't happen yet, but as soon i toggle with the PNG scale option, the exported images get an odd scale factor and has been "zoomed" 😢

See the attachment.

First i put the PNG scale to 100%, which worked fine. (left window)
Then i adjusted the PNG scale to 50%, which scaled the oddly. E.g. "Arm left" is original 250x330px, but after the scale it was 63x83px. This is not 50%? :o
And then the images has been "zoom-cropped", so the hand of "Arm left" isn't on the image anymore. And it happens on every layer. (right window)

I tried another machine, also with Photoshop CS6 13.0.1x64 on Win7x64bit, but still same issue occurs. I also tried with different PSDs, which wasn't the problem either.

Won't be able to debug it before monday (earliest), since my developer has gone on weekend :shake:

Wonderful! Thanks a bunch, Nate 🙂 You saved the weekend 😉

And I just realised why the script didn't create the JSON, as mentioned earlier.
When i tried going up in the directory, i didn't type the first backslash in "Output Directory", which placed the images folder next to the PSD and without the JSON.

Again - thank you for the help!


Btw, we keep our images and our JSON files in separate folders. Is it possible to get two Output directories, one for the images and one for the JSON? :$
This would be wonderful for updateing the skeletons automatically.

Neat, really neat, Nate! Thanks for being that fast with all of the changes - It's really awesome! :rock:

I tried it a couple of times, and the only thing a came across, was when the JSON and the images are separated into different folders, the image links breaks. When i enter the paths into the script, should it be able to pass on the image path into the JSON file, so i don't have to do a "Search and replace" in spine to update it?

Another thing; my character has 3 mouth images / regions and when i import it into spine, every mouth image gets it own separate slot - and when i want to move the 3 images into one slot for animation purposes, they lose the coordinates, so i manually have to repostition it, which can be a bit of a timeconsumer. 😢
Is there some feature i overlook? I don't think the skin feature is suitable for these small changes, am i right?

Once again, thank you for taking the time to help optimize the script for our need! :clap:

Okay, your new revision unfortunately created a couple of issues 😢

  1. The PNG scale feature is broken. It doesn't scale images at all, no matter which scale i set it to.

  2. The Script don't remember my previous PNG scale preferences, so i have to re-enter the scale factor, each time i run the script.

  3. The Output directories is creating the folders is it should, but all the images are being exported to the directory of the JSON.

Fixed!

Neat! Export works again as it should, but it creates an invalid JSON file.
When i try to import the data, i get following error:
[attachment=1]zUv5ckS[1].png[/attachment]

Edit:
I attached the JSON file, if you need to examine it.
carnie_barnie_spine.json

It imports into 2.0.21, which should be released today. You might be able to change the first line:

// Change first line from:
{"skeleton":{"images":""},
// To:
{

is the AI script supposed to have a GUI and JSON file too? I just get an automatic export of all layers

why scripts dont upadate with new Spine version?


Just now update Photoshop script and try it (Photoshop cc last version). Spine get error in Json file when import data.


new script - begin JSON

{"skeleton":{"images":"images/"},
"bones":[{"name":"root"}],
"slots":[
......

Old script -

{"bones":[{"name":"root"}],
"slots":[
........

without skeleton all work fine

Conzeit wrote

is the AI script supposed to have a GUI and JSON file too? I just get an automatic export of all layers

The Illustrator script is currently much simpler and only exports layers. Maybe you could bring your AI images into Photoshop and do the export there?

mfedorov wrote

why scripts dont upadate with new Spine version?

New Spine version will be up today.

Wonderful, Nate! It works like a charm! :rock:

Bendsen wrote

Another thing; my character has 3 mouth images / regions and when i import it into spine, every mouth image gets it own separate slot - and when i want to move the 3 images into one slot for animation purposes, they lose the coordinates, so i manually have to repostition it, which can be a bit of a timeconsumer. 😢
Is there some feature i overlook? I don't think the skin feature is suitable for these small changes, am i right?

Did you have any thoughts on the qoute above?
Would it be possible to name a group layer in Photoshop a specific name, which the export script would catch and place the sublayers into one single slot in Spine? :happy: