• Editor
  • Photoshop to spine script pixel character efficiency update

@Nate The last update you did for the selection option in the photoshop to spine script was excellent and greatly appreciated. I've been working with pixel characters as of late and the one step that I always have to do before running the script is to resize the image to a specific image size with nearest neighbor resample turned on. After I run the script I always have to make sure to close the file without saving it.

I was hoping to see if this step could be set as a option in the script window. Maybe a option that lets you set a specified aspect ratio by pixels and the resample setting you want.

Related Discussions
...

Thank you for your feedback and suggestion regarding the PhotoshopToSpine script. It's great to hear that the recent updates have been helpful for you.

To address your request for resizing images with a specific aspect ratio and resample setting before running the script, it would indeed be a useful feature to add. Currently, the script does not support this functionality directly within the script window. However, you can manually resize your images in Photoshop using the nearest neighbor resample setting before running the script, as you have been doing.

For a more automated approach, you could consider adding a custom function to the script that handles the resizing process. Here is a basic example of how you might modify the script to include this functionality:

// Add this function to resize the image
function resizeImage(doc, width, height) {
    var idImgS = charIDToTypeID("ImgS");
    var desc = new ActionDescriptor();
    var idWdth = charIDToTypeID("Wdth");
    var idPxl = charIDToTypeID("#Pxl");
    desc.putUnitDouble(idWdth, idPxl, width);
    var idHght = charIDToTypeID("Hght");
    desc.putUnitDouble(idHght, idPxl, height);
    var idIntr = charIDToTypeID("Intr");
    var idIntp = charIDToTypeID("Intp");
    var idNrst = charIDToTypeID("Nrst");
    desc.putEnumerated(idIntr, idIntp, idNrst);
    executeAction(idImgS, desc, DialogModes.NO);
}

// Call the function before running the main script logic
resizeImage(app.activeDocument, 800, 600); // Example dimensions

This code snippet resizes the active document to 800x600 pixels using the nearest neighbor resample setting. You can adjust the dimensions as needed.

If you prefer not to modify the script yourself, you can continue resizing your images manually until such a feature is officially added to the script. We appreciate your patience and understanding as we work on improving the script.

Have you seen that 4.2 can import a PSD directly? It's suuuper fast!

The PhotoshopToSpine script (and Spine 4.2's import PSD) has a scale feature. Is the problem that you are unable to use that because you need nearest neighbor filtering? We could add that to 4.2 pretty easily. We do plan to port all the import PSD improvements back to the PhotoshopToSpine script in time.

Thanks Nate, I didn't notice that feature yet but I'm looking forward to using it. The company I work for still uses the 4.1 version of spine but we're working to update to the latest 4.2 at some point. As of now I'm stuck with using the script which does have a scale feature but it only scales down a image while I need to scale the image up. I appreciate the code snippet and I'll try to update the script with it.

I look forward to testing out this 4.2 feature soon.

4.2 is a huge time saver with import PSD, physics, etc. You can show them this! 😃
http://esotericsoftware.com/blog/Spine-4.2-The-physics-revolution

I just increased the PhotoshopToSpine script scale slider max to 400%. Does that help?

This is the line that does the scaling:

activeDocument.resizeImage(UnitValue(imageSize, "px"), null, null, ResampleMethod.BICUBICAUTOMATIC);

The API docs for ResampleMethod are here:
https://theiviaxx.github.io/photoshop-docs/Photoshop/ResampleMethod.html
You can use nearest filtering by changing that line to:

activeDocument.resizeImage(UnitValue(imageSize, "px"), null, null, ResampleMethod.NEARESTNEIGHBOR);

Thanks Nate, I just showed them the page and they're loving it. I'm sure it will get us to transfer to it sooner. As for the script I believe it should work but when I try to push the scale past %100 it gives me a warning that it can't go past that %100 and closes the script.

Ok I figured out what the issue was on the script. Thanks again Nate this was a great help.

@Nate actually the script doesn't seem to scale up the image at all.

nm I yet again figured it out. I really have to have more confidence in my abilities lol. Sorry about this.

Sorry, I should have tested the script better. I've updated it (7.40), should work correctly now!