[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ossig] help on shell scripts



On Sun, 2005-07-10 at 18:05 -0700, Ng Swee Meng wrote:
> i was working on a bash script to resize photo in a
> directory(because my friend have pictures with a total
> of  >100MB). and i happen to have imagemagick on my
> linux system. 
> 
> the requirement is that, it is able to process every
> file in the family. and exclude non-graphic file

If you already have them tagged with a suitable extension, then do a
simple *.png or something like that.

> 
> the point, 
> how do i pass directory as an argument in bash? 
Just Pass it!

> how do i exclude other file type except picture?

You can try "file" magic

$cat > pop
#!/bin/sh
for img in $1
do
echo $img
done

$./pop "*.jpg *.png"
a.jpg
b.png
idx.png
left.png
right.png

I Use this.

#!/bin/sh

for file in *.png; do
convert \
        -geometry 550x550 \
        -quality 90 \
        -interlace Plane \
        -comment "MyCOMMENT - %f" \
        -border 2x2 \
        -bordercolor black \
        "$file" \
     "`echo $file|perl -pi -e 's|^IMG_||g'|perl -pi -e 's|JPG\$|jpg|g'`"
done




---------------------------------------------------------
To unsubscribe: send mail to ossig-request@mncc.com.my
with "unsubscribe ossig" in the body of the message