Saving individual frames from a strip animation

Get some cool tips about how to tweak your UT graphic, gameplay, and much more!
Post Reply
User avatar
[did]Madis
Adept
Posts: 297
Joined: Tue Jun 03, 2008 2:48 pm
Personal rank: カニはとても美味しい

Saving individual frames from a strip animation

Post by [did]Madis »

So I have a few animation strips in BMP format. I'd like to know if there's a fast and convenient way to save every single 'frame' of the strip image as a separate (pcx) file?

Doing it manually is beyond tedious.
Support Nuclear Races by visiting our ModDB profile
Image
Image
User avatar
Phorce
Experienced
Posts: 107
Joined: Tue Apr 14, 2009 8:24 pm
Personal rank: Sgt. Nutz
Location: UK
Contact:

Re: Saving individual frames from a strip animation

Post by Phorce »

I did this with an Imagemagick script once. Write a for loop and increment the pixel count each time so that each frame gets cut out.
"Weapons! ... for all occasions." Bill Hicks
User avatar
[did]Madis
Adept
Posts: 297
Joined: Tue Jun 03, 2008 2:48 pm
Personal rank: カニはとても美味しい

Re: Saving individual frames from a strip animation

Post by [did]Madis »

Phorce wrote:I did this with an Imagemagick script once. Write a for loop and increment the pixel count each time so that each frame gets cut out.
I'm not familiar with this program. How do I make it cut out 36 128x128 frames out of a 4608x128 strip?
Support Nuclear Races by visiting our ModDB profile
Image
Image
User avatar
Phorce
Experienced
Posts: 107
Joined: Tue Apr 14, 2009 8:24 pm
Personal rank: Sgt. Nutz
Location: UK
Contact:

Re: Saving individual frames from a strip animation

Post by Phorce »

http://en.wikipedia.org/wiki/Imagemagick

I think I still have the script somewhere. I'll dig it out.
"Weapons! ... for all occasions." Bill Hicks
User avatar
[did]Madis
Adept
Posts: 297
Joined: Tue Jun 03, 2008 2:48 pm
Personal rank: カニはとても美味しい

Re: Saving individual frames from a strip animation

Post by [did]Madis »

Phorce wrote:http://en.wikipedia.org/wiki/Imagemagick

I think I still have the script somewhere. I'll dig it out.
I'd appreciate it.
Support Nuclear Races by visiting our ModDB profile
Image
Image
User avatar
Phorce
Experienced
Posts: 107
Joined: Tue Apr 14, 2009 8:24 pm
Personal rank: Sgt. Nutz
Location: UK
Contact:

Re: Saving individual frames from a strip animation

Post by Phorce »

Here it is.

Code: Select all

#!/bin/bash
# Extract Animation Strip - DJ Barney / Phorce, April 2010
# Assumes left to right operation. Requires ImageMagick - http://www.imagemagick.org
# Command line: extract-animation-strip <image-file-name> <total-width> <single-frame-width> <single-frame-height> 
image=$1
totalwidth=$2
framewidth=$3
frameheight=$4
count=1
offset=0
while [ "$offset" -lt "$totalwidth" ] ;
do
 convert $image -crop "$framewidth"x"$frameheight"+$offset+0 $image$count.png;
 offset=`expr $offset + $framewidth`;
 count=`expr $count + 1`;
done;
Requires ImageMagick. Only in Linux bash at the moment although I suppose it could be interesting doing it in Windows/DOS. There is no error checking so if you get strange results double check the input numbers.
"Weapons! ... for all occasions." Bill Hicks
Post Reply