Attached is my own bash script 'animtext' for making cinelerra image
lists. It works for jpg and png and can automatically determines which
to use. It also works out the image size for you.
The instructions are in comments at the beginning of the script. The
script relies on you having imagemagick installed.
Just cd into the directory with your image files and type 'animtext' for
the most basic mode of operation.
Last I checked this worked. Let me know if something has broken. This
is part of a larger set of scripts which are currently in too chaotic a
state to release... But I will get them there sometime - they are
really handy for general image manipulation working with animation with
cinelerra, imagemagick and a digital camera.
Graham
#/bin/sh
#Create cinelerra style text file listing image paths for each frame
#this script can be called standalone or from within the animate script
#it takes three parameters: filetype (png or jpg) (default is to try and
determine what file type is in the directory), framerate (default is 12) and
directory to index (default is the directory from which the script is called)
#you probably need to make sure you choose a legitimate cinelerra frame rate
#examples:
#animtext
#(this uses default framerate of 12, does its own checking of the filetype in
the directory, and uses the current directory)
#
#animtext jpg 23.976 animations/sources/1/
#
#animtext jpg 30 /home/gray/animations/sources/2/
hd=`echo ~`
startdir=$PWD
if [ $1 ]
then
filetype=$1
else
#check png and jpgs
#needs refinement as, for instance, .jng would be considered legitimate in
this test
ls -1 $sourcedir | grep ".[pj][np][g]" > "${hd}"/animreadytemptext.txt
#select the first that appears in any of those categories
testfile=$(cat "${hd}"/animreadytemptext.txt | sed -n 1p)
#run the imagemagick identifier to make sure of what it is
test=`identify ${testfile}`
if echo ${test} | grep JPEG -q
then
filetype=jpg
elif echo ${test} | grep PNG -q
then
filetype=png
fi
fi
mmv '*.jpeg' '#1.jpg' 2>/dev/null
mmv '*..JPEG' '#1.jpg' 2>/dev/null
mmv '*.PNG' '#1.png' 2>/dev/null
#rename .jpeg .jpg * 2>/dev/null
#rename .JPEG .jpg * 2>/dev/null
#rename .PNG .png * 2>/dev/null
#following code fails now my distro doesn't support rename
filetype=$(echo $filetype | tr '[A-Z]' '[a-z]' | sed '+s+e++')
echo
echo 'This script will create a Cinelerra compliant text index of the
'${filetype}' image files in the directory. The index will be called
'${filetype}'.txt and will be created in the same directory as the images
themselves. With cinelerra open up this text-index file to access the
animation. If you move the image files or the directory then you will need to
recreate this index file.'
echo
if [ $1 ]
then
echo 'Creating a text file listing the '${filetype}' files.'
else
echo 'Creating a text file listing the '${filetype}' files. (Use 1st
parameter to over-ride)'
fi
echo
if [ $2 ]
then
framerate=$2
echo 'Using framerate '${framerate}'.'
else
framerate=12
echo 'Default framerate of 12 will be used. (Use second parameter to
specify).'
fi
echo
if [ $3 ]
then
if [ ${3:0:1} = "/" ]
then
indexdir=${3}
else
indexdir=`echo $PWD`'/'${3}
fi
#add trailing backslash
if [ ${indexdir:(-1)} = '/' ]
then
indexdir=${indexdir}
else
indexdir=${indexdir}'/'
fi
echo 'Indexing files in the '${indexdir}' directory.'
else
indexdir=`echo $PWD'/'`
echo 'Indexing files in the current directory. (Use third parameter to
override).'
fi
echo
#list filenames in correct order
cd "${indexdir}"
#ls -1 "'${indexdir}'"*.${filetype} > "${hd}"/animreadytemptext.txt
ls -1 *.${filetype} > "${hd}"/animreadytemptext.txt
if [ "${filetype}" = jpg ]
then
filetypeheader="JPEGLIST"
else
filetypeheader="PNGLIST"
fi
#create filetype header
echo ${filetypeheader} > "${hd}"/animreadytemptext2.txt
echo `echo $filetypeheader | sed 'i# First line is always'` >>
"${hd}"/animreadytemptext2.txt
echo "# Frame rate:" >> "${hd}"/animreadytemptext2.txt
echo ${framerate} >> "${hd}"/animreadytemptext2.txt
testfile=$(cat "${hd}"/animreadytemptext.txt | sed -n 1p)
#size=identify ${indexdir}${testfile}
size=`identify ${indexdir}${testfile}`
#create Width header
echo "# Width:" >> "${hd}"/animreadytemptext2.txt
identifyfiletype=$(echo -n $filetypeheader | sed '+s+LIST++')
width=`echo $size | sed '+s+.*'${identifyfiletype}' ++' | sed '+s+x.*++'`
echo $width >> "${hd}"/animreadytemptext2.txt
#create Height header
echo "# Height:" >> "${hd}"/animreadytemptext2.txt
if [ "${filetype}" = "png" ]
then
height=`echo ${size} | sed '+s+.*PNG [0-9]*x++' | sed '+s+ [0-9]*x[0-9]*.*++'`
else
height=`echo ${size} | sed '+s+.*JPEG [0-9]*x++' | sed '+s+DirectClass.*++'`
fi
echo $height >> "${hd}"/animreadytemptext2.txt
#create list of files with full paths
for f in `cat "${hd}"/animreadytemptext.txt`
do
destfile=${indexdir}${f}
echo ${destfile} >> "${hd}"/animreadytemptext2.txt
done
#save the list and cleanup
filename=$(echo $filetype | tr '[A-Z]' '[a-z]')'list.txt'
mv "${hd}"/animreadytemptext2.txt "${indexdir}${filename}"
rm "${hd}"/animreadytemptext.txt
cd "${startdir}"
echo "Completed."
echo