Leser: 25
1 2 3 4
#!/usr/bin/perl my $img = new Image::BMP; $img->open_file('/root/a.bmp'); my ($r,$g,$b) = $img->xy_rgb(10,10);
1
2
3
4
5
6
7
8
#!/usr/bin/perl
use strict;
use warnings;
use Image::BMP;
my $img2 = Image::BMP->new();
$img2->open_file('another.bmp') or die("Cannot open file: $!");
print "done";
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/Perl/bin/perl
use strict;
use warnings;
use FindBin qw/$Bin/;
use Benchmark (qw/timediff timestr/);
use Image::BMP;
my $t0 = Benchmark->new();
my $img = new Image::BMP;
$img->open_file($Bin . '/cool_pig.bmp');
my ($r,$g,$b) = $img->xy_rgb(10,10);
my $t1 = Benchmark->new();
my $td = timediff($t1, $t0);
print "the code took:", timestr($td),"\n";
Quotethe code took: 1 wallclock secs ( 0.83 usr + 0.09 sys = 0.92 CPU)
Quote-bash: ./test.pl: /Perl/bin/perl: bad interpreter: No such file or directory
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#!/usr/bin/perl use strict; use warnings; use FindBin qw/$Bin/; use Benchmark (qw/timediff timestr/); use Image::BMP; my $t0 = Benchmark->new(); my $img = new Image::BMP; $img->open_file($Bin . '/a.bmp'); my ($r,$g,$b) = $img->xy_rgb(10,10); my $t1 = Benchmark->new(); my $td = timediff($t1, $t0); print "the code took:", timestr($td),"\n";
QuoteWSyS-Mini2:~# ./test.pl
the code took:74 wallclock secs (72.29 usr + 1.66 sys = 73.95 CPU)
WSyS-Mini2:~#
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 32 33 34 35
#!/usr/bin/perl use strict; use warnings; use FindBin qw/$Bin/; use Benchmark (qw/timediff timestr/); use Image::BMP; my $t0 = Benchmark->new(); my $img = new Image::BMP; my $t1 = Benchmark->new(); $img->open_file($Bin . '/a.bmp'); my $t2 = Benchmark->new(); my ($r1,$g1,$b1) = $img->xy_rgb(10,10); my $t3 = Benchmark->new(); my ($r2,$g2,$b2) = $img->xy_rgb(20,20); my $t4 = Benchmark->new(); my ($r3,$g3,$b3) = $img->xy_rgb(10,10); my $t5 = Benchmark->new(); my $td1 = timediff($t1, $t0); my $td2 = timediff($t2, $t1); my $td3 = timediff($t3, $t2); my $td4 = timediff($t4, $t3); my $td5 = timediff($t5, $t4); my $td10 = timediff($t5, $t0); print "the code 1 took:", timestr($td1),"\n"; print "the code 2 took:", timestr($td2),"\n"; print "the code 3 took:", timestr($td3),"\n"; print "the code 4 took:", timestr($td4),"\n"; print "the code 5 took:", timestr($td5),"\n"; print "the complete code took:", timestr($td10),"\n";
Quotethe code 1 took: 0 wallclock secs ( 0.01 usr + 0.00 sys = 0.01 CPU)
the code 2 took: 0 wallclock secs ( 0.11 usr + 0.01 sys = 0.12 CPU)
the code 3 took:70 wallclock secs (68.11 usr + 1.66 sys = 69.77 CPU)
the code 4 took: 0 wallclock secs ( 0.00 usr + 0.00 sys = 0.00 CPU)
the code 5 took: 0 wallclock secs ( 0.01 usr + 0.00 sys = 0.01 CPU)
the complete code took:70 wallclock secs (68.24 usr + 1.67 sys = 69.91 CPU)
$ strace perl script.pl
$ strace perl script.pl 2>strace.out && tail -f strace.out
strace perl test2.pl 2>strace.out && tail -f strace.out
Quoteread(3, "\371"..., 1) = 1
read(3, "\371"..., 1) = 1
read(3, "\371"..., 1) = 1
read(3, "\371"..., 1) = 1
read(3, "\371"..., 1) = 1
brk(0x201000) = 0x201000
read(3, "\371"..., 1) = 1
read(3, "\371"..., 1) = 1
read(3, "\371"..., 1) = 1
read(3, "\371"..., 1) = 1
read(3, "\371"..., 1) = 1
read(3, "\371"..., 1) = 1
read(3, "\371"..., 1) = 1
read(3, "\371"..., 1) = 1
read(3, "\371"..., 1) = 1
read(3, "\371"..., 1) = 1
read(3, "\371"..., 1) = 1
read(3, "\371"..., 1) = 1
read(3, "\371"..., 1) = 1
read(3, "\371"..., 1) = 1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/Perl/bin/perl
use strict;
use warnings;
use FindBin qw/$Bin/;
use Benchmark (qw/timediff timestr/);
use Image::BMP;
my $t0 = Benchmark->new();
my $img = Image::BMP->new();
$img->debug( 1 );
$img->open_file($Bin . '/cool_pig.bmp');
my ($r,$g,$b) = $img->xy_rgb(10,10);
my $t1 = Benchmark->new();
my $td = timediff($t1, $t0);
print "the code took:", timestr($td),"\n";
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#!/usr/bin/perl use strict; use warnings; use FindBin qw/$Bin/; use Benchmark (qw/timediff timestr/); use Image::BMP; my $t0 = Benchmark->new(); my $img = Image::BMP->new(); $img->debug( 1 ); $img->open_file($Bin . '/red.bmp'); my ($r,$g,$b) = $img->xy_rgb(10,10); my $t1 = Benchmark->new(); my $td = timediff($t1, $t0); print "the code took:", timestr($td),"\n";
QuoteBMP: /root/red.bmp
Image: 8/256 colors. Geometry: 240x320 76800 [comp: 0]
Reading image data - [240 x 320 x 8]...
the code took:74 wallclock secs (72.40 usr + 1.68 sys = 74.08 CPU)
1 2 3 4 5 6 7 8 9
#!/usr/bin/perl use strict; use warnings; use FindBin qw/$Bin/; use GD; my $img = GD::Image->new($Bin . '/a.bmp'); my $index=$img->getPixel(10,10) my ($r,$g,$b) = $img->rgb($index);
1 2 3 4 5 6 7 8 9
#!/usr/bin/perl use strict; use warnings; use FindBin qw/$Bin/; use Image::Magick; my $img = Image::Magick->new(); $img->Read($Bin . '/a.bmp'); my ($r,$g,$b) = $img->GetPixel(x=>10,y=>10);
1 2 3 4 5 6 7 8 9 10
#!/usr/bin/perl use strict; use warnings; use FindBin qw/$Bin/; use GD; my $img = GD::Image->new($Bin . '/red.bmp'); my $index=$img->getPixel(10,10); #<---Denke mal das du dort das ";" vergessen hast! ohne geht es auch nicht my ($r,$g,$b) = $img->rgb($index); print "$r $g $b";
QuoteCan't call method "getPixel" on an undefined value at ./test3.pl line 8.
1 2 3 4 5 6 7 8 9
#!/usr/bin/perl use strict; use warnings; use FindBin qw/$Bin/; use Image::Magick; my $img = Image::Magick->new($Bin . '/rot.bmp'); my ($r,$g,$b) = $img->GetPixel(x=>10,y=>10); print "$r $g $b";
QuoteUse of uninitialized value $r in concatenation (.) or string at ./test3.pl line 9.
Use of uninitialized value $g in concatenation (.) or string at ./test3.pl line 9.
Use of uninitialized value $b in concatenation (.) or string at ./test3.pl line 9.
1 2 3 4 5 6 7 8 9 10
#!/usr/bin/perl use strict; use warnings; use FindBin qw/$Bin/; use Image::Magick; my $img = Image::Magick->new(); $img->Read($Bin.'/red.bmp'); my ($r,$g,$b) = $img->GetPixel(x=>10,y=>10); print "$r $g $b\n";
Quote1 0 0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
#!/usr/bin/perl use strict; use warnings; se FindBin qw/$Bin/; use Image::Magick; my $img = Image::Magick->new(); $img->Read($Bin.'/red.bmp'); my ($blob)=$img->ImageToBlob(magick=>'RGB', colorspace=>'RGB', depth=>'8'); my @data=unpack("C*",$blob); my $width=$img->Get('columns'); my $height=$img->Get('rows'); for(1..$height) { for(1..$width) { my ($r,$g,$b)=splice(@data,0,3); print "($r,$g,$b) "; } print "\n"; }