darkfrei wrote: ↑2018-01-17T13:49:08-07:006. Making new spritesheet with new cropped sprites from fifth stage.
Take a look at the parts of this command...
Code: Select all
magick sprite*.png -background none ^
( -clone 0--1 -layers merge ^
-set option:cropper "%[@]" +delete ) ^
-crop %[cropper] +repage ^
MIFF:- | magick montage MIFF:- ^
-background none -tile 8x8 -geometry +0+0 outsprites.png
Each line number does just a few things...
1. Read in all the "sprite*.png" images, and set the background color to "none".
2. Inside the parentheses make a copy of them all, stack them, and flatten them to one layer.
3. Get the crop information from the FX expression "%[@]" which calculates the values same as if you used "-trim" to remove all the excess blank space, but it doesn't have to actually trim them. The variable "%[cropper]" will now contain something like this: "105x51+23+29". Since you don't need that cloned flattened image after this, "+delete" it.
4. Use that variable "%[cropper]" to crop all the images to the same dimensions and offsets. The "+repage" resets all their page geometries to HxW+0+0.
5. Instead of outputting an image, you output ImageMagick's special format MIFF. That way you can pipe the whole stack of cropped sprite pieces to your "montage" command. Use "magick montage MIFF:-" after the pipe to move those images into your "montage" command.
6. Set the background, tile arrangement, and geometry. Give it an output file name, and it's done.
The result should be a sprite sheet with all the images in a grid, all the same sizes and orientations, but without any unneeded transparent space surrounding them.
If you're using a command like that in a BAT script, you need to make all the percent signs "%" into double percent sign "%%".