[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Sheflug] Batch Process Images - Debian
Forwarded from Robin Rowe after Mailman did something strange to his
e-mail....
From:
Robin Rowe <Robin at movieeditor dot com>
Perl script enclosed.
Robin
Richard Ibbotson wrote:
> Hi
>
> Oh... right.... thanks for everyone's help :) Here we go... 'man
> imagemagick'. I'd forgotten about that. Too much use of KDE and
> Gnome...
>
>> JPEG images at 1024x768 tend to range from 200-300KB, so I'd
>> suggest you perhaps try ImageMagick's 'convert' program, say, on
>> the lines of
>>
>> for i in *.jpg ; do
>> j=`basename $i jpg`
>> convert -geometry 1024x768 $i newpics/$j.1024x768.jpg
>> done
>
> Hmm... looks useful :)
>
>> This should work OK, since digital camera photos generally
>> have a 4:3 aspect ratio.
>
> Yes, but the pro cameras tend to have 3 to 10Mb files for the 35 m/m
> SLR replacement and the digital Rollei medium format camera is about
> 10Mb to 30Mb in size. Hence the need for image processing when
> uploading to a web page. In my case 3008x2000 pixels is small.
>
> You can do this with Photoshop in Mac or winduhs but to be honest I
> prefer the Linux desktop and think that ImageMagick is better
anyway.
> Oh.... mogrify... might work !
>
>
--
Robin Rowe
310-278-4012
310-435-6082 mobile
MovieEditor.com
140 S. Elm Dr., Ste. 6
Beverly Hills, California 90212
www.MovieEditor.com
pix2_html.pl
#!/usr/bin/perl -w
# heidi @ animae.org 12/16/2005, translation from pix2_html.sh
# originally written by Robin.Rowe@xxxxxxxxxxxxxxx 5/3/2004
# License OSI MIT
use strict;
my $dir = "thumbs";
my $html = 'index.html';
my $convert = 'gm convert';
my $size = '480x480';
my $description = 'Photos by Robin Rowe';
sub MkDir
{ if(!(-d $dir))
{ mkdir $dir or die "Could not make directory $dir: $!";
} }
sub IsImageFileType($)
{ my $file=lc(shift);
if ( -1==index($file,'.tif')
and -1==index($file,'.tiff')
and -1==index($file,'.jpg')
and -1==index($file,'.jpeg')
and -1==index($file,'.png')
and -1==index($file,'.doc') )
{ return 0;
}
return 1;
}
sub IsDocFileType($)
{ my $file=lc(shift);
if ( -1==index($file,'.pdf')
and -1==index($file,'.txt')
and -1==index($file,'.doc') )
{ return 0;
}
return 1;
}
sub RenameFiles
{ foreach my $file (glob '*')
{ #if(UnknownFileType($file))
#{ next;
#}
my $filename=$file;
$filename =~ s/ /_/g;
if($filename ne $file)
{ print("rename $file\n");
rename($file,$filename);
} } }
sub CreateThumbnails
{ open(my $OUT,'>',$html) or die "Could not open $html: $!";
print($OUT <<ZZZ);
<HTML><BODY><H3>$description</H3><P><P><!--CinePaint pix_html.sh-->
ZZZ
foreach my $file (glob '*')
{ if(!IsImageFileType($file))
{ if(IsDocFileType($file))
{ print($OUT <<ZZZ);
<P><A HREF=$file>$file</A></P>
ZZZ
next;
}
print("skipping $file\n");
next;
}
print("$file\n");
if ( -1!=index($file,'.doc'))
{ print($OUT <<ZZZ);
<P><A HREF="$file">$file</A></P>
ZZZ
next;
}
# print("$file\n");
my $filename=$file;
$file="$file.jpg";
if(!(-f "$dir/$file"))
{ system "$convert -resize $size $filename
$dir/$file";
}
print($OUT <<ZZZ);
<P><A HREF=$filename><IMG SRC=$dir/$file ALT=\"$filename\"></A>
$filename</P>
ZZZ
}
print($OUT <<ZZZ);
</BODY></HTML>
ZZZ
close($OUT);
}
sub main
{ MkDir();
RenameFiles();
CreateThumbnails();
print("done!\n");
}
main();
_______________________________________________
Sheffield Linux User's Group
http://www.sheflug.org.uk/mailfaq.html
GNU - The choice of a complete generation