sub JPEGData { my $self = shift; my $pos = 2; my $len = length($_[0]); $self->{_jepgdata} = $_[0]; while((my $s=substr($_[0], $pos, 2)) ne "\xff\xc0" and $pos < $len) { $pos += 2+unpack('n', substr($_[0], $pos+2,2)); } croak "Can't get the width and height of JPEG data" if $pos>=$len; @{$self}{qw/_width _height/} = unpack('nn', substr($_[0], $pos+5,4)); undef $self->{_jpegfile}; $self; }