• Editor
  • How to crop image to exclude the part that are outside of mesh?

Image1 : this is a slot's layer I export from psd, which I export from Spine with CLI (I suppose "exportType": "current" return restpose in CLI?)
Image2 : this is the slot's image in the spine project directory

I noticed that the size of Image1 \Image2 are not the same.
Then I noticed that the "mesh" deforming this slot is smaller than this slot image, (because it is cutting off some area of low alpha, it is unnoticeable). As spine only render what's in the mesh, this is why Image1 is smaller than Image2?

If so, is there some way that I crop Image2 and exclude the part that are outside of mesh?

Related Discussions
...

To crop an image to exclude parts that are outside of a mesh in Spine, you would typically need to adjust the image itself before importing it into Spine or after exporting it. Spine's focus is on animating and manipulating meshes and images within its environment, and while it offers extensive tools for mesh editing, direct image cropping based on mesh boundaries isn't a standard feature within Spine itself.

However, you can manage the image size and the mesh area in a few ways:

  1. Adjust Padding and Use Layer Masks in Photoshop: Before importing your images into Spine, ensure they are cropped or have sufficient padding to accommodate the mesh. You can use Photoshop or similar software to adjust the image size or add padding. Layer masks can also be used for non-destructive editing (PhotoshopToSpine script usage).
  2. Edit Mesh in Spine: If the mesh does not cover the entire image, you can edit the mesh in Spine to include or exclude parts of the image. This won't crop the image file itself but will affect what parts of the image are used and visible in your animation.
  3. External Image Editing: After exporting your animation or images from Spine, you can use external image editing tools to crop the images further as needed.

For your specific case, where you notice a size difference between the exported image and the original slot's image due to the mesh cutting off areas of low alpha, you would likely need to manually crop the original image using an external image editor based on the mesh boundaries you have in Spine. This process isn't automated within Spine, so adjustments to the image file itself would need to be done outside of Spine, either before importing or after exporting.

There many export settings that can affect the size of exports from Spine. Also if your mesh is deformed or rotated or scaled then the export may be larger than the source image.

The current export type is the pose you currently see in the editor. When doing a CLI export... I'm not sure, it may be the setup pose.

What is the actual goal? Why do you want the export to match the source image size? You can set the size of your export explicitly with the crop settings.