Imagemagick File Padding Issue


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Imagemagick File Padding Issue
# 1  
Old 07-20-2009
Imagemagick File Padding Issue

Hello, I'm having a problem figuring out the syntax for padding 10-99. Everything else in the program works fine so I want to focus in on just this part of the code. Below is a snippet of the code that I am having problems with. I appreciate all the help I can get. Thank you.

The script basically takes an image and adds the convert charcoal filter and spits out a sequence the user specifies. Problem is if the frame goes over 100...the padding is thrown off since 100 is set for greater than or equal to, where 10-99 needs to be specified to a limit before 100.

I seen a for loop where it prints like so..

for i in {10..99} etc... but that will not work, it only prints and {10..99} does not work for an if statement.


##no problem here

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


##cant figure out the arithmatic here!

if ( $count -ge 10 > 99 ); then
convert ${IMGDIR}${IMG} -charcoal $count ${OUTDIR}${OUT}.00$count.jpg
fi


##no problems here.

if [ $count -ge 100 ] ; then
convert ${IMGDIR}${IMG} -charcoal $count ${OUTDIR}${OUT}.0$count.jpg
fi
# 2  
Old 07-20-2009
Quote:
Originally Posted by jsells20
...
##cant figure out the arithmatic here!

if ( $count -ge 10 > 99 ); then
...
fi
...
Code:
$
$ count=10
$ echo $count
10
$
$ while [ $count -le 20 ] ; do
>   echo $count
>   count=`expr $count + 1`
> done
10
11
12
13
14
15
16
17
18
19
20
$

tyler_durden
# 3  
Old 07-20-2009
Can there be a while loop inside of a while loop? I already had one at the top. Heres the code edited. It's not correct, please correct me where im wrong.

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
# 4  
Old 07-20-2009
You can't do this because you reset count to 10 everytime. That won't get anything over 100 if count goes over 100.
Code:
count=10
while [ $count -le 99 ]; do
convert ${IMGDIR}${IMG} -charcoal $count ${OUTDIR}${OUT}.00$count.jpg
count=`expr $count + 1`
done

Maybe try

Code:
if [ $count -ge 10 && $count -le 99 ]
convert ${IMGDIR}${IMG} -charcoal $count ${OUTDIR}${OUT}.00$count.jpg
fi

# 5  
Old 07-20-2009
Hmm..when I run this...


Code:
if [ $count -ge 10 && $count -le 99 ]; then
convert ${IMGDIR}${IMG} -charcoal $count ${OUTDIR}${OUT}.00$count.jpg
fi

It goes up to 9 and stops, my error from 0-10 is...

Code:
line 88: [: missing `]'


Last edited by jsells20; 07-20-2009 at 05:23 PM..
# 6  
Old 07-20-2009
Sorry,
That shoudl be

Code:
if [ $count -ge 10 ] && [ $count -le 99 ] ;then

# 7  
Old 07-20-2009
i actually just figured that out right before you posted ;P The process is running to 101 as we speak. Hopefully all goes well. Thanks BubbaJoe, durden_tyler.

---------- Post updated at 04:48 PM ---------- Previous update was at 04:32 PM ----------

Eureka, it worked!
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