fmw42 wrote: ↑2018-01-17T13:08:16-07:00
Your red image is 256x256. Is that correct for what you want?
My red image is a mask, where all alpha borders are marked as red, but it's 0,0,0,255. You cant see alpha channel and I'm just marked it.
fmw42 wrote: ↑2018-01-17T13:08:16-07:00
How do you know where to put the trimmed flattened images (in white) inside the red larger 256x256 box? How would this help you crop the original image from the mask. You do not know the relative positions of the mask in relation to your original grid of sprites? I am still confused. I still do not understand your size requirements for the mask and for the final grid of sprites.
What are the command you have tried for your steps 1-6? Perhaps that will help us understand what you are trying to do.
I'm making mask just with one command:
Code: Select all
convert "sprite_n*.png" -background none -flatten mask.png
As you can see, this mask is just all sprites that we have. I don't want to trim this mask, but I want to take all properties from this trim function (new size and position of the image where it was before) and crop all sprites with this properties (-crop _wight_x_high_+_left_+_top_.).
1. We have sprites.
This sprites I get after rendering in blender 3D. They are always same, but I don't see shadows before I render it.
2. Making mask from this sprites. This mask is a picture with the same size as all sprites.
Code: Select all
convert "sprite_n*.png" -background none -flatten mask.png
3. Get alpha borders from this mask: We are need left and top pixels, that we are using by crop function.
mask.png PNG 256x256 256x256+0+0 8-bit Grayscale Gray 5.48KB 0.000u 0:00.000
4. Get mask size: We can get wight and high of mask, where alpha is less than 100%.
Code: Select all
convert mask.png -trim info:-
pause
mask.png PNG 168x119 256x256+44+89 8-bit Gray 0.000u 0:00.006
5. Crop all sprites from first stage. Just call crop function with parameters wightxhigh+left+top.
-- I don't know how to get 168x119 and 44+89 from it.
Code: Select all
convert sprite_n*.png -crop 168x119+44+89 +repage +adjoin sprite_crop.png
-- here
168x119+44+89 must be taked from step 4, I don't know how
6. Making new spritesheet with new cropped sprites from fifth stage.
Code: Select all
montage "sprite_crop*.png" -geometry +0+0 -tile 2x2 -background rgba(0,0,0,0) -quality 100% Output\spritesheet_2x2.png