| 1 | package Image::Info::PNG; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # Copyright 1999-2000, Gisle Aas. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # This library is free software; you can redistribute it and/or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # modify it under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | =begin register | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | MAGIC: /^\x89PNG\x0d\x0a\x1a\x0a/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | Information from IHDR, PLTE, gAMA, pHYs, tEXt, tIME chunks are | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | extracted. The sequence of chunks are also given by the C<PNG_Chunks> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | key. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | =end register | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 3 | our $VERSION = 1.04; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | # Test for Compress::Zlib (for reading zTXt chunks) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 3 | my $have_zlib = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 3 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 3 | require Compress::Zlib; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 3 | $have_zlib++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | # Test for Encode (for reading iTXt chunks) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 3 | my $have_encode = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 3 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 3 | require Encode; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 3 | $have_encode++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | sub my_read | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 90 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
my_read: called CC=3 SCAR=11.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 90 | my($source, $len) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 90 | my $buf; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 90 | my $n = read($source, $buf, $len); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 90 | ▶ | die "read failed: $!" unless defined $n; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 90 | ▶ | die "short read ($len/$n) at pos " . tell($source) unless $n == $len; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 90 | $buf; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | sub process_file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 8 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
process_file: called CC=39 SCAR=38.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 8 | my($info, $fh) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 8 | my $signature = my_read($fh, 8); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 8 | ▶ | die "Bad PNG signature" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | unless $signature eq "\x89PNG\x0d\x0a\x1a\x0a"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 8 | $info->push_info(0, "file_media_type" => "image/png"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 8 | $info->push_info(0, "file_ext" => "png"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 8 | my @chunks; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 8 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 45 | my($len, $type) = unpack("Na4", my_read($fh, 8)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 45 | ▶ | if (@chunks) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 37 | my $last = $chunks[-1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 37 | my $count = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 37 | ▶ | $count = $1 if $last =~ s/\s(\d+)$//; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 37 | ▶ | if ($last eq $type) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 2 | $count++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 2 | $chunks[-1] = "$type $count"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 35 | push(@chunks, $type); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 8 | push(@chunks, $type); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 45 | ▶ | last if $type eq "IEND"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 37 | my $data = my_read($fh, $len + 4); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 37 | my $crc = unpack("N", substr($data, -4, 4, "")); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 37 | ▶ | if ($type eq "IHDR" && $len == 13) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 8 branches
Condition66%2/3
$type eq "IHDR" and $len == 13
MC/DC50%1/2
$type eq "IHDR" and $len == 13
$type eq "IHDR"
$len == 13
Truth table66%2/3
A and B
A= $type eq "IHDR"B= $len == 13
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 8 | my($w, $h, $depth, $ctype, $compression, $filter, $interlace) = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | unpack("NNCCCCC", $data); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | $ctype = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 => "Gray", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 2 => "RGB", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 3 => "Indexed-RGB", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 4 => "GrayA", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 6 => "RGBA", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 8 | ▶ | }->{$ctype} || "PNG-$ctype"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
{0, 'Gray', 2, 'RGB', 3, 'Indexed-RGB', 4, 'GrayA', 6, 'RGBA'}->{$ctype} || "PNG-$ctype"
MC/DC0%0/1
{0, 'Gray', 2, 'RGB', 3, 'Indexed-RGB', 4, 'GrayA', 6, 'RGBA'}->{$ctype} || "PNG-$ctype"
{0, 'Gray', 2, 'RGB', 3, 'Indexed-RGB', 4, 'GrayA', 6, 'RGBA'}->{$ctype}
Truth table50%1/2
A
A= {0, 'Gray', 2, 'RGB', 3, 'Indexed-RGB', 4, 'GrayA', 6, 'RGBA'}->{$ctype}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 8 | ▶ | $compression = "Deflate" if $compression == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 8 | ▶ | $filter = "Adaptive" if $filter == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 8 | ▶ | $interlace = "Adam7" if $interlace == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 8 | $info->push_info(0, "width", $w); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 8 | $info->push_info(0, "height", $h); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 8 | $info->push_info(0, "SampleFormat", "U$depth"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 8 | $info->push_info(0, "color_type", $ctype); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 8 | $info->push_info(0, "Compression", $compression); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 8 | $info->push_info(0, "PNG_Filter", $filter); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 8 | ▶ | $info->push_info(0, "Interlace", $interlace) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | if $interlace; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | elsif ($type eq "PLTE") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 3 | my @table; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 3 | ▶ | while (length $data) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 36 | push(@table, sprintf("#%02x%02x%02x", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | unpack("C3", substr($data, 0, 3, "")))); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 3 | $info->push_info(0, "ColorPalette" => \@table); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | ▶ | elsif ($type eq "gAMA" && $len == 4) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$type eq "gAMA" and $len == 4
MC/DC0%0/2
$type eq "gAMA" and $len == 4
$type eq "gAMA"
$len == 4
Truth table33%1/3
A and B
A= $type eq "gAMA"B= $len == 4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | $info->push_info(0, "Gamma", unpack("N", $data)/100_000); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | ▶ | elsif ($type eq "pHYs" && $len == 9) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$type eq "pHYs" and $len == 9
MC/DC50%1/2
$type eq "pHYs" and $len == 9
$type eq "pHYs"
$len == 9
Truth table66%2/3
A and B
A= $type eq "pHYs"B= $len == 9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 5 | my $res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 5 | my($res_x, $res_y, $unit) = unpack("NNC", $data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 5 | if (0 && $unit == 1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | # convert to dpi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | $unit = "dpi"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | for ($res_x, $res_y) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | $_ *= 0.0254; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 5 | ▶ | $res = ($res_x == $res_y) ? $res_x : "$res_x/$res_y"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 5 | ▶ | if ($unit) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 5 | ▶ | if ($unit == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 5 | $res .= " dpm"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | $res .= " png-unit-$unit"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 5 | $info->push_info(0, "resolution" => $res) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | ▶ | elsif ($type eq "tEXt" || $type eq "zTXt" || $type eq "iTXt") { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%6/6
$type eq "tEXt" or $type eq "zTXt" or $type eq "iTXt"
$type eq "tEXt" or $type eq "zTXt"
MC/DC100%3/3
$type eq "tEXt" or $type eq "zTXt" or $type eq "iTXt"
$type eq "tEXt"
$type eq "zTXt"
$type eq "iTXt"
Truth table100%4/4
A or B or C
A= $type eq "tEXt"B= $type eq "zTXt"C= $type eq "iTXt"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 7 | my($key, $val) = split(/\0/, $data, 2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 7 | my($method,$ctext,$is_i); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 7 | ▶ | if ($type eq "iTXt") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 3 | ++$is_i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 3 | (my $compressed, $method, my $lang, my $trans, $ctext) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | = unpack "CaZ*Z*a*", $val; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 3 | ▶ | unless ($compressed) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 1 | undef $method; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 1 | $val = $ctext; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | elsif ($type eq "zTXt") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 3 | ($method,$ctext) = split(//, $val, 2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 7 | ▶ | if (defined $method) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 5 | ▶ | if ($have_zlib && $method eq "\0") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$have_zlib and $method eq "\0"
MC/DC0%0/2
$have_zlib and $method eq "\0"
$have_zlib
$method eq "\0"
Truth table33%1/3
A and B
A= $have_zlibB= $method eq "\0"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 5 | $val = Compress::Zlib::uncompress($ctext); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | undef $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 7 | ▶ | if ($is_i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 3 | ▶ | if ($have_encode) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 3 | $val = Encode::decode("UTF-8", $val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | undef $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 7 | ▶ | if (defined $val) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | # XXX should make sure $key is not in conflict with any | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | # other key we might generate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 7 | $info->push_info(0, $key, $val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | $info->push_info(0, "Chunk-$type" => $data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | ▶ | elsif ($type eq "tIME" && $len == 7) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$type eq "tIME" and $len == 7
MC/DC50%1/2
$type eq "tIME" and $len == 7
$type eq "tIME"
$len == 7
Truth table66%2/3
A and B
A= $type eq "tIME"B= $len == 7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 4 | $info->push_info(0, "LastModificationTime", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | sprintf("%04d-%02d-%02d %02d:%02d:%02d", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | unpack("nC5", $data))); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | elsif ($type eq "sBIT") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | $info->push_info(0, "SignificantBits" => unpack("C*", $data)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | elsif ($type eq "IDAT") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | # ignore | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 2 | $info->push_info(0, "Chunk-$type" => $data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 8 | $info->push_info(0, "PNG_Chunks", @chunks); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 8 | ▶ | unless ($info->get_info(0, "resolution")) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 3 | $info->push_info(0, "resolution", "1/1"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||