File Coverage

blib/lib/Image/MetaData/JPEG/parsers/app1.pl
Criterion Covered Total %
statement 16 16 100.0
branch 4 4 100.0
condition n/a
subroutine 5 5 100.0
pod 0 1 0.0
total 25 26 96.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   64 use Image::MetaData::JPEG::data::Tables qw(:TagsAPP1_Exif :TagsAPP1_XMP);
  15         23  
  15         2751  
7 15     15   72 no integer;
  15         17  
  15         60  
8 15     15   260 use strict;
  15         20  
  15         330  
9 15     15   55 use warnings;
  15         19  
  15         1702  
10              
11             ###########################################################
12             # This method parses an APP1 segment. Such an application #
13             # segment can host a great deal of metadata, in at least #
14             # two formats (see specialised routines for more details):#
15             # 1) Exif JPEG files use APP1 so that they do not con- #
16             # flict with JFIF metadata (which use APP0); #
17             # 2) Adobe, in order to be more standard compliant than #
18             # others, uses APP1 for its XMP metadata format. #
19             # This method decides among the various formats and then #
20             # calls a more specialised method. An error is issued if #
21             # the metadata format is not recognised. #
22             #=========================================================#
23             # Ref: "Exchangeable image file format for digital still #
24             # cameras: Exif Version 2.2", JEITA CP-3451, Apr2002 #
25             # Japan Electronic Industry Development Assoc. (JEIDA) #
26             # and: "XMP Specification", version 3.2, June 2005, Adobe #
27             # Systems Inc., San Jose, CA, http://www.adobe.com #
28             ###########################################################
29             sub parse_app1 {
30 65     65 0 109 my ($this) = @_;
31             # If the data area begins with "Exif\000\000" it is an Exif section
32 65 100       258 return $this->parse_app1_exif()
33             if $this->data(0, length $APP1_EXIF_TAG) eq $APP1_EXIF_TAG;
34             # If it begins with "http://ns.adobe.com/xap/1.0/", it is Adobe XMP
35 2 100       8 return $this->parse_app1_xmp()
36             if $this->data(0, length $APP1_XMP_TAG) eq $APP1_XMP_TAG;
37             # if the segment type is unknown, generate an error
38 1         4 $this->die('Incorrect identifier (' . $this->data(0,6) . ')');
39             }
40              
41             require 'Image/MetaData/JPEG/parsers/app1_exif.pl';
42             require 'Image/MetaData/JPEG/parsers/app1_xmp.pl';
43              
44             # successful load
45             1;