|
Author
|
Topic: Uploading images???
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Adam Martin
I'm not even gonna point out the irony.

Posts: 3325
From: Los Angeles, CA
Registered: Nov 2000
|
posted 11-10-2002 03:25 AM
The following script lists all of the .gif files in a directory and displays their width and height attributes. I'm sure you could use the formulas in it to serve your purposes. Note that it's only for .gif files. I wasn't able to quickly come up with any information on how image size is embedded in a jpeg file.
code:
#!/usr/bin/perl# gifsize open (OFN,">-"); # use standard output as default if($#ARGV > -1) { # but allow redirection to a file name close OFN; open (OFN,">$ARGV[0]"); } # print list header print OFN sprintf("%-32s %-6s %-6s\n","Filename","Width","Height"); $w = ""; $h = ""; foreach $fn (<*.gif> ) { # list all .gif files if ($fn =~ /\.gif/) { # redundant for now, until I figure out .jpg format open (FH,$fn); binmode FH; read FH,$w,6; # skip first 6 bytes read FH,$w,2; # width read FH,$h,2; # height close FH; ($wl,$wh) = unpack("CC",$w); # there is probably a more ($hl,$hh) = unpack("CC",$h); # elegant way to do this $w = $wl + ($wh * 256); $h = $hl + ($hh * 256); print OFN sprintf("%-32s %6s %6s\n",$fn,$w,$h); } } close OFN;
| IP: Logged
|
|
|
|
|
|