| 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 |  | 88 | use Image::MetaData::JPEG::data::Tables qw(:TagsAPP1_Exif :TagsAPP1_XMP); | 
|  | 15 |  |  |  |  | 33 |  | 
|  | 15 |  |  |  |  | 4169 |  | 
| 7 | 15 |  |  | 15 |  | 98 | no  integer; | 
|  | 15 |  |  |  |  | 30 |  | 
|  | 15 |  |  |  |  | 87 |  | 
| 8 | 15 |  |  | 15 |  | 336 | use strict; | 
|  | 15 |  |  |  |  | 33 |  | 
|  | 15 |  |  |  |  | 423 |  | 
| 9 | 15 |  |  | 15 |  | 78 | use warnings; | 
|  | 15 |  |  |  |  | 32 |  | 
|  | 15 |  |  |  |  | 2247 |  | 
| 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 | 261 | my ($this) = @_; | 
| 31 |  |  |  |  |  |  | # If the data area begins with "Exif\000\000" it is an Exif section | 
| 32 | 65 | 100 |  |  |  | 421 | 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 |  |  |  | 12 | 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 |  |  |  |  | 5 | $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; |