Patrick wrote:
On Thursday 21 November 2002 02:23 am, Nasim Shamlou wrote:

Morning,

I remember someone else having asked something similar to the
question I have, but I looked and looked but couldn't find it, so
I'll ask again:

Is there a way to resize a set of images all at once, instead of
editing them one by one?
And if this can't be done with The Gimp, is there another program I
could use?

I have about 100 images, and it would take far too long to start
resizing each one individually.

Thanks.
-Nasim Sh.

Hi,
here are a few scripts that may be usefull

sorry it is a little bit long

create a txt file copy the script in it
type chmod 755 the_name_of_the_file
put the file in /usr/bin
and use the cript from the folder containing the files


#!/bin/bash
for i in *jpg
do
# rotate the file and change its name to temp.jpeg

put here one of the line starting by convert that is in between the~~~~~

# remove the file
rm "$i" ;

# give temp.jpeg the file name
mv temp.jpeg $i ;

done

~~~~~~~
#land2portrait 90 CCW
convert -rotate "-90>" "$i" temp.jpeg;

#land2portrait 90 CCW
convert -rotate "90>" "$i" temp.jpeg;

#port2land 90_CCW
convert -rotate "-90<" "$i" temp.jpeg;

#port2land 90_CW
convert -rotate "90<" "$i" temp.jpeg;

#landscape 180
convert -rotate "180>" "$i" temp.jpeg;

#portrait 180
convert -rotate "-180" "$i" temp.jpeg;
~~~~~~~~


this file allows you to create a web page (W3C compliant) with thumnails of pictures as link to the same pictures.

you may need to have to adjust the file if the mail system screwed up by adding carriage returns

you will find there commands to resize images

#!/bin/sh

# ~~~~~~~~ original credit ~~~~~~~~~~~~~
#vim: set sw=4 ts=4 et:
# wirtten by katja socher <[EMAIL PROTECTED]>
# and guido socher <[EMAIL PROTECTED]>
# ~~~~~~ end original credit ~~~~~~~~~~~

# I found the file at
# http://linuxfocus.org/English/July2001/article211.shtml

# the file has been heavily modified by myself
# to be able to create w3 compliant html page

# this is my first bash script, don't hesitate to email me
# any error or improvement

# Philippe Rousselot Aug. 2002, EMail: linux at rousselot dot org


ver="1.0"
one=1
number=1
extension=".html"
page_numb=1 ;
j=0
array=('' '' '')

test()
{
case $page_numb in
1) page_numb="01" ;;
2) page_numb="02" ;;
3) page_numb="03" ;;
4) page_numb="04" ;;
5) page_numb="05" ;;
6) page_numb="06" ;;
7) page_numb="07" ;;
8) page_numb="08" ;;
9) page_numb="09" ;;

esac
}

help()
{
cat <<HELP
thumbnail_multipage -- generate W3 compliant html pages with thumbnails to click on for a number of images.
USAGE: htmlthumbnails [-h] [ -W width] [-H height] [-N name_of_html_page] [-n number_of_image_per_page] path/image1 image2 ...
OPTIONS: -h this help.
EXAMPLE: htmlthumbnails -W 120 -H 80 -N page -n 6 image1 image2
EXAMPLE: htmlthumbnails -W 80 -H 120 -N page -n 6 ~/images/*.jpeg
The html code is written to files called name_of_html_page_file_number.html.
I recommend leaving the script always in the same folder and using the absolute path for the images (~/path/image).
All thumbnails have a size of widthxheight.
Make sure you use the right orientation.

This script requires ImageMagick

if you modify the script, make sure the html file still validates as HTML 4.01 Transitional!

version $ver
HELP
exit 0
}


error()
{
echo "$1"
exit "$2"

}

header()
{
#creates header for html page
cat > $filename << EOF
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd";>

<html>
<head>

<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<meta name="Author" LANG="fr" CONTENT="">
<meta name="Description" CONTENT="Page created with thumbnail_multipage">
<meta name="Description" CONTENT="">
<meta name="Keywords" LANG="fr" CONTENT="">
<meta name="Identifier-URL" CONTENT="http://";>
<meta name="Reply-to" CONTENT="">
<meta name="revisit-after" CONTENT="31">
<meta name="Publisher" CONTENT="Quanta Plus">
<meta name="Copyright" CONTENT="">
<meta name="date" CONTENT="2002-07-06">
<meta name="Generator" CONTENT="Quanta plus, gFTP">

<title> "$title" </title>

<style type="text/css">
</style>

</head>
<body>

<table border =" 0" align="center" width ="500">
<tr align="center">




EOF
}


footer()
{
cat >> $filename << EOF

<td></td><td>
<!-- link for ./$title2 -->
<a href="./$title2">$title2</a>
</td><td></td>
</tr>
</table>

<br>


<p>
<a href="http://validator.w3.org/check/referer";><img border="0"
src="http://www.w3.org/Icons/valid-html401";
alt="Valid HTML 4.01!" height="31" width="88"></a>
</p>

</body>

</html>
EOF
}

while [ -n "$1" ];
do
case $1 in
-h) help;shift 1;;
--) break;;
-W) width=$2; break;;
-H) echo "wrong argument. It should be -W";exit 1;;
-N) echo "wrong argument. It should be -W";exit 1;;
-n) echo "wrong argument. It should be -W";exit 1;;
-*) echo "error: no such option $1. -h for help";exit 1;;
*) break;;
esac
done

while [ -n "$3" ];
do
case $3 in
-h) help;shift 1;;
--) break;;
-W) echo "wrong argument. It should be -H";exit 1;;
-H) height=$4 ;break;;
-N) echo "wrong argument. It should be -H";exit 1;;
-n) echo "wrong argument. It should be -H";exit 1;;
-*) echo "error: no such option $1. -h for help";exit 1;;
*) break;;
esac
done

while [ -n "$5" ];
do
case $5 in
-h) help;shift 1;;
--) break;;
-W) echo "wrong argument. It should be -N";exit 1;;
-H) echo "wrong argument. It should be -N";exit 1;;
-N) name=$6 ; break;;
-n) echo "wrong argument. It should be -N";exit 1;;
-*) echo "error: no such option $1. -h for help";exit 1;;
*) break;;
esac
done

while [ -n "$7" ];
do
case $7 in
-h) help;shift 1;;
--) break;;
-W) echo "wrong argument. It should be -n";exit 1;;
-H) echo "wrong argument. It should be -n";exit 1;;
-N) echo "wrong argument. It should be -n";exit 1;;
-n) quota=$8 ; break;;
-*) echo "error: no such option $1. -h for help";exit 1;;
*) break;;
esac
done

dirname_image=`dirname "$9"`
th="thumbnails"
thumbnail_dir="$dirname_image/$th"
test
filename="$dirname_image/$name$page_numb$extension";
title="$name$page_numb$extension";
mkdir "$thumbnail_dir"


if [ -z "$9" ];then
error "No image specified, -h for help" 1
fi

# process each image
i=0;

header;

shift 8

for image in $* ;
do
echo "$image"
if [ ! -r "$image" ]; then
echo "ERROR: can not read $image\n"
else
i=`expr $i + 1`
bn=`basename "$image"`
array[j]=$bn

j=`expr $j + 1`
thumbnail="$thumbnail_dir/t_$bn"

convert -geometry "${width}x$height" "$image" "$thumbnail"

cat >> $filename << EOF

<td>
<!-- image nr $i -->
<a href="./$bn" name="$bn" type="image/jpeg">
<img src="./$th/t_$bn" width="$width" height="$height" alt="[$bn]" border=1>
</a>
</td>
EOF
modulo=`expr $i % 3`


if [ "$modulo" = "0" ]; then
cat >> $filename << EOF
</tr>
<tr align="center">
<td>
${array[0]}
</td>
<td>
${array[1]}
</td>
<td>
${array[2]}
</td>
</tr>
<tr align="center">
<td>
<br>
</td>
<td>
<br>
</td>
<td>
<br>
</td>
</tr>
<tr align=center>
EOF
j=0
array=('' '' '')
fi

modulo=`expr $i % $quota`


if [ "$modulo" = "0" ]; then

page_numb=`expr $page_numb + 1`;
test
filename2="$dirname_image/$name$page_numb$extension";
title2="$name$page_numb$extension";

if [ "$number" -ne "$one" ]; then
echo "<a href=\"javascript:history.back()\">Back</a>" >> $filename ;
fi


number=`expr $number + 1`
i=0
footer;
filename=$filename2
title=$title2

header;
fi

fi
done
footer

_______________________________________________
Gimp-user mailing list
[EMAIL PROTECTED]
http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-user

Reply via email to