Imagemagick File Padding Issue


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Imagemagick File Padding Issue
# 8  
Old 07-20-2009
Quote:
Originally Posted by jsells20
Can there be a while loop inside of a while loop?
...

count=$START
while [ $count -le $END ];
do
echo $count

if [ $count -lt 10 ]; then
convert ${IMGDIR}${IMG} -charcoal $count ${OUTDIR}${OUT}.000$count.jpg
fi

count=10
while [ $count -le 99 ]; do
convert ${IMGDIR}${IMG} -charcoal $count ${OUTDIR}${OUT}.00$count.jpg
count=`expr $count + 1`
done


if [ $count -ge 100 ] ; then
convert ${IMGDIR}${IMG} -charcoal $count ${OUTDIR}${OUT}.0$count.jpg
fi


SETTING=$(echo "scale=4; 1/50" | bc)
echo "processing frame: "$count""

let count=count+1

done
So are those IF conditions inside the loop simply to ensure that the width of the number between ${OUT} and ".jpg" is constant ?

If so, then you could use "printf" and avoid those IF conditions -

Code:
$ 
$ OUT=myimage
$ count=1
$ 
$ while [ $count -le 100 ]; do
>   x=`printf "%s.%04d.jpg" $OUT $count`  # this is your output file, fixed width
>   echo $x                               # run your commands; "convert" etc.
>   count=`expr $count + 1`               # increment count
> done
myimage.0001.jpg
myimage.0002.jpg
myimage.0003.jpg
myimage.0004.jpg
myimage.0005.jpg
myimage.0006.jpg
myimage.0007.jpg
myimage.0008.jpg
myimage.0009.jpg
myimage.0010.jpg
myimage.0011.jpg
myimage.0012.jpg
...
... <output snipped for brevity>
...
myimage.0098.jpg
myimage.0099.jpg
myimage.0100.jpg
$ 
$

HTH,
tyler_durden
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

fixed length text file padding issues in AIX

Hi, I have a fixed length text file that needs to be cut into individual files in aix and facing padding issues. If I have multiple blank spaces in the file it is just making it one while cutting the files.. Eg:- $ - blank space filename:file.txt ... (2 Replies)
Discussion started by: techmoris
2 Replies

2. Shell Programming and Scripting

Padding lines in a file with newlines

Hi Guys, I have a file as shown below: 55 6 77 8 88 98 7 85 45 544 1 33 32 13 13 (5 Replies)
Discussion started by: npatwardhan
5 Replies

3. Shell Programming and Scripting

Bash for image resize using ImageMagick

Hi all, I have a FreeNAS server hosting all of my images. The original images are high resolution. What I would like to do is 2 parts: 1. do a batch resize of all of the images so I have web-friendly version and print ready version 2. run a cron job to apply the bash to any "new" files ... (1 Reply)
Discussion started by: Imhotep1963
1 Replies

4. UNIX and Linux Applications

looking for ImageMagick install package

i am struggling to find an error free, and complete install package for ImageMagick (with perl- "PerlMagick"). imagemagick.org not much help.... links for source, mirrors etc dont work. any pointers appreciated. linux server. (2 Replies)
Discussion started by: mickeymouse
2 Replies

5. UNIX for Advanced & Expert Users

Padding Carriage return to the end of XML file

Hi All, I am getting a xml file where the first field contains a carriage return and the all other fields doesnot contains any carriage return. So all the other records comes in the second line. <?xml version="1.0" encoding="UTF-8"?> <ns0:iSeriesCspIntegration... (3 Replies)
Discussion started by: dasj22
3 Replies

6. HP-UX

Padding zeros after removing commas in file

Hi Gurus, There is a ASCII file in which a comma is used as a seperator for the amount field when the amount exceed seven digits: e.g. 0001300,000. Now, this comma needs to be removed from this field, after padding leading zeros (to maintain the ASCII positions) e.g. 00001300000.... (1 Reply)
Discussion started by: pranag21
1 Replies

7. UNIX for Dummies Questions & Answers

imageMagick?

Hi I am planning to install ImageMagick on my server here. I have learned what I needed about Unix when I needed it..... but I have never installed anything before. I have downloaded the necessary file from imagemagick.org, and their installation instructions seem easy enough (only 2 or 3... (2 Replies)
Discussion started by: bob2003
2 Replies
Login or Register to Ask a Question