![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| USN-784-1: ImageMagick vulnerability | iBot | Security Advisories (RSS) | 0 | 06-08-2009 09:00 PM |
| USN-681-1: ImageMagick vulnerability | iBot | Security Advisories (RSS) | 0 | 12-01-2008 01:30 PM |
| Padding Carriage return to the end of XML file | dasj22 | UNIX for Advanced & Expert Users | 3 | 05-23-2008 10:31 AM |
| Padding zeros after removing commas in file | pranag21 | HP-UX | 1 | 11-09-2005 10:22 PM |
| imageMagick? | bob2003 | UNIX for Dummies Questions & Answers | 2 | 06-03-2003 02:59 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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 |
|
||||
|
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 |
|
|||||
|
Quote:
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 |
|
|||||
|
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
|
|
||||
|
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.. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|