Thread JPG Bilder: Abfrage der Bildergröße (3 answers)
Opened by wolfgangk at 2003-12-08 09:44

format_c
 2003-12-08 09:50
#74952 #74952
User since
2003-08-04
1706 Artikel
HausmeisterIn
[Homepage] [default_avatar]
Hier etwas aus meinen gesammelten Werken:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
sub jpegsize {
my $file = shift;
open (JPEG,"<",$file) or die $!;
my $jpeg = join "",<JPEG>;
close JPEG;
my ($count)=2;
my ($length)=length($jpeg);
my ($ch)="";
my ($c1,$c2,$x,$y,$c,$d,$width,$height);
while (($ch ne "\xda") && ($count<$length)) {
while (($ch ne "\xff") && ($count < $length)) {
$ch=substr($jpeg,$count,1);
$count++;
}
while (($ch eq "\xff") && ($count<$length)) {
$ch=substr($jpeg,$count,1);
$count++;
}
if ((ord($ch) >= 0xC0) && (ord($ch) <= 0xC3)) {
$count+=3;
($x,$y,$c,$d)=unpack("C"x4,substr($jpeg,$count,4));
$width=$c<<8|$d;
$height=$x<<8|$y;
return($width,$height);
} else {
($c1,$c2)= unpack("C"x2,substr($jpeg,$count,2));
$count += $c1<<8|$c2;
}
}
undef;
}


Gruß Alex

View full thread JPG Bilder: Abfrage der Bildergröße