Sprite sheet dimentions
-
- Posts: 2
- Joined: 2017-07-06T11:46:08-07:00
- Authentication code: 1151
Sprite sheet dimentions
Is there a way to get sprite sheet dimensions when montaging images sequence? I need width and height data to be appended automatically to file name.
- GeeMack
- Posts: 718
- Joined: 2015-12-01T22:09:46-07:00
- Authentication code: 1151
- Location: Central Illinois, USA
Re: Sprite sheet dimentions
Without knowing which version of IM you're using or what platform or OS you're working on, generally I'd say that's an extremely simple task. The exact best answer may be quite different from one situation to another, so check the suggestions at THIS link, then give us more specific information about your requirements.MikeVansoz wrote: ↑2017-07-06T11:50:51-07:00Is there a way to get sprite sheet dimensions when montaging images sequence? I need width and height data to be appended automatically to file name.
-
- Posts: 2
- Joined: 2017-07-06T11:46:08-07:00
- Authentication code: 1151
Re: Sprite sheet dimentions
Win 7 x64
ImageMagick 6.9.3-7 Q16 x64 2016-03-06
Ok, so I break video file into png sequence using ffmpeg:
Then merge it all in one square sprite sheet with montage:
And I need to add some info about sprite sheet in output filename, like so:
ImageMagick 6.9.3-7 Q16 x64 2016-03-06
Ok, so I break video file into png sequence using ffmpeg:
Code: Select all
ffmpeg -i "%%i" -r 10 -f image2 "%%~dpni\%%10d.png"
Code: Select all
montage "%%~dpni\*.png" -background transparent -geometry +0+0 -tile 8x "%%~dpni_sprite.png"
"%%~dpni_SPRITE_WIDTHxSPRITE_HEIGHT.png"
- GeeMack
- Posts: 718
- Joined: 2015-12-01T22:09:46-07:00
- Authentication code: 1151
- Location: Central Illinois, USA
Re: Sprite sheet dimentions
After you get the original broken into its separate frames with "ffmpeg", you can use IM's "convert" to calculate the dimensions of the final montage. A command like this will output the width and height of the montage in the form of "1920x1080"...MikeVansoz wrote: ↑2017-07-07T03:49:30-07:00And I need to add some info about sprite sheet in output filename, like so:"%%~dpni_SPRITE_WIDTHxSPRITE_HEIGHT.png"
Code: Select all
convert *.png -set option:thesize "%%[fx:w*8]x%%[fx:ceil(n/8)*h]" -append -format %%[thesize] info:
Code: Select all
for /f %%I in (
'convert *.png -set option:thesize "%%[fx:w*8]x%%[fx:ceil(n/8)*h]" -append -format %%[thesize] info:'
) do (
set WIDTH_HEIGHT=%%I
)
Edited to add: If your montage uses any amount of spacing other than "-geometry +0+0" you'd have to figure that additional width and height into your "convert" command, too. It would be just barely more complicated, but in concept pretty much the same thing.