03/06/03 17:55 /P4baUDR
>>797
KENTのスクリプト
#------------------#
# JPEGサイズ認識 #
#------------------#
sub JpegSize {
local($jpeg) = @_;
local($t, $m, $c, $l, $W, $H);
open(JPEG, "$jpeg") || return (0,0);
binmode JPEG;
read(JPEG, $t, 2);
while (1) {
read(JPEG, $t, 4);
($m, $c, $l) = unpack("a a n", $t);
if ($m ne "\xFF") { $W = $H = 0; last; }
elsif ((ord($c) >= 0xC0) && (ord($c) <= 0xC3)) {
read(JPEG, $t, 5);
($H, $W) = unpack("xnn", $t);
last;
}
else {
read(JPEG, $t, ($l - 2));
}
}
close(JPEG);
return ($W, $H);
}