- or download this
#!/usr/bin/perl -w
use strict;
- or download this
use warnings;
- or download this
my $data = get_file($jpg);
my @res = sizeJPG($data);
print "$jpg width $res[0] height $res[1]\n";
- or download this
my $data = get_file($jpg);
my ($h,$v) = sizeJPG($data);
print "$jpg width $h height $v\n";
- or download this
sub sizeJPG {
return unless $_[0];
my ( $width, $height );
...
unpack( "nn", $1 ) if $_[0] =~ /\xFF\xC0...(....)/;
return ( $width, $height );
}
- or download this
local $_=shift;
- or download this
my ($width,$height)=unpack "nn", (/\xFF\xC0...(....)/)[0];
- or download this
my ($width,$height)=unpack "nn", /\xFF\xC0...(....)/ ? $1 : '';
# or "\0" x 4, maybe?
- or download this
sub get_file {
open FILE, $_[0] or die $!;
binmode FILE;
...
close FILE;
return $data;
}
- or download this
sub get_file {
local $/;
open my $fh, '<:raw', shift or die $!;
<$fh>;
}