File Coverage

blib/lib/Image/MetaData/JPEG/parsers/app14.pl
Criterion Covered Total %
statement 21 21 100.0
branch 1 2 50.0
condition n/a
subroutine 5 5 100.0
pod 0 1 0.0
total 27 29 93.1


line stmt bran cond sub pod time code
1             ###########################################################
2             # A Perl package for showing/modifying JPEG (meta)data. #
3             # Copyright (C) 2004,2005,2006 Stefano Bettelli #
4             # See the COPYING and LICENSE files for license terms. #
5             ###########################################################
6 15     15   94 use Image::MetaData::JPEG::data::Tables qw(:TagsAPP14);
  15         30  
  15         1926  
7 15     15   92 no integer;
  15         31  
  15         97  
8 15     15   353 use strict;
  15         37  
  15         429  
9 15     15   77 use warnings;
  15         42  
  15         3677  
10              
11             ###########################################################
12             # This method parses a misterious Adobe APP14 segment. #
13             # Adobe uses this segment to record information at the #
14             # time of compression such as whether or not the sample #
15             # values were blended and which color transform was #
16             # performed upon the data. The format is the following: #
17             #---------------------------------------------------------#
18             # 5 bytes "Adobe" as identifier (non null-terminated) #
19             # 2 bytes DCTEncode/DCTDecode version number (0x65) #
20             # 2 bytes flags0 #
21             # 2 bytes flags1 #
22             # 1 byte transform code #
23             #=========================================================#
24             # Ref: "Supporting the DCT Filters in PostScript Level 2",#
25             # Adobe Developer Support, Tech. note #5116, pag.27 #
26             ###########################################################
27             sub parse_app14 {
28 2     2 0 6 my ($this) = @_;
29 2         4 my $offset = 0;
30             # exactly 12 bytes, or die
31 2         18 $this->test_size(12);
32             # they say that this segment always starts with a specific
33             # string from Adobe, namely "Adobe". For the time being,
34             # die if you find something else
35 2         9 my $identifier = $this->store_record
36             ('Identifier', $ASCII, $offset, 5)->get_value();
37 2 50       8 $this->die("Wrong identifier ($identifier)")
38             if $identifier ne $APP14_PHOTOSHOP_IDENTIFIER;
39             # the rest is trivial
40 2         8 $this->store_record('DCT_TransfVersion' , $SHORT, $offset );
41 2         7 $this->store_record('Flags0' , $UNDEF, $offset, 2);
42 2         8 $this->store_record('Flags1' , $UNDEF, $offset, 2);
43 2         14 $this->store_record('TransformationCode', $BYTE, $offset );
44             }
45              
46             # successful load
47             1;