Image/ExifTool.pm

filter: Statementstmt 72.7% 3280 / 4509 Branchbran 60.6% 2115 / 3486 Conditioncond 51.7% 958 / 1853 MC/DCmcdc 28.5% 300 / 1050 Subroutinesub 87.9% 160 / 182 Podpod 16.2% 26 / 160 totaltotal 60.8% 6839 / 11240 CC 2456 SCAR 80.3
CC
2456
Cov
65%
ProcessJPEG
15402.1
ExtractInfo
5217.0
DoProcessTIFF
1278.4
CRAP 3079.0
« Image/ExifTool/GIF.pm ↑ Summary Image/ExifTool/TagInfoXML.pm »
1 #------------------------------------------------------------------------------
2 # File: ExifTool.pm
3 #
4 # Description: Read and write meta information
5 #
6 # URL: https://exiftool.org/
7 #
8 # Revisions: Nov. 12/2003 - P. Harvey Created
9 # (See html/history.html for revision history)
10 #
11 # Legal: Copyright (c) 2003-2026, Phil Harvey (philharvey66 at gmail.com)
12 # This library is free software; you can redistribute it and/or
13 # modify it under the same terms as Perl itself.
14 #------------------------------------------------------------------------------
15  
16 package Image::ExifTool;
17  
18 113 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 113 require 5.004; # require 5.004 for UNIVERSAL::isa (otherwise 5.002 would do)
20 113 require Exporter;
21 113 ▶use File::RandomAccess;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 113 ▶use overload;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 113 ▶use vars qw($VERSION $RELEASE @ISA @EXPORT_OK %EXPORT_TAGS $AUTOLOAD @fileTypes
Subroutine BEGIN: called CC=1 SCAR=0.0
25 %allTables @tableOrder $exifAPP1hdr $xmpAPP1hdr $xmpExtAPP1hdr
26 $psAPP13hdr $psAPP13old @loadAllTables %UserDefined $evalWarning
27 %noWriteFile %magicNumber @langs $defaultLang %langName %charsetName
28 %mimeType $swapBytes $swapWords $currentByteOrder %unpackStd
29 %jpegMarker %specialTags %fileTypeLookup $testLen $exeDir
30 113 %static_vars $advFmtSelf $configFile @configFiles $noConfig);
31  
32 113 $VERSION = '13.55';
33 113 $RELEASE = '';
34 113 @ISA = qw(Exporter);
35 113 %EXPORT_TAGS = (
36 # all public non-object-oriented functions:
37 Public => [qw(
38 ImageInfo AvailableOptions GetTagName GetShortcuts GetAllTags
39 GetWritableTags GetAllGroups GetDeleteGroups GetFileType CanWrite
40 CanCreate AddUserDefinedTags OrderedKeys
41 )],
42 # exports not part of the public API, but used by ExifTool modules:
43 DataAccess => [qw(
44 ReadValue GetByteOrder SetByteOrder ToggleByteOrder Get8u Get8s Get16u
45 Get16s Get32u Get32s Get64u Get64s GetFloat GetDouble GetFixed32s Write
46 WriteValue Tell Set8u Set8s Set16u Set32u Set64u Set64s
47 )],
48 Utils => [qw(GetTagTable TagTableKeys GetTagInfoList AddTagToTable HexDump)],
49 Vars => [qw(%allTables @tableOrder @fileTypes)],
50 );
51  
52 # set all of our EXPORT_TAGS in EXPORT_OK
53 113 Exporter::export_ok_tags(keys %EXPORT_TAGS);
54  
55 # test for problems that can arise if encoding.pm is used
56 113 ▶{ my $t = "\xff"; die "Incompatible encoding!\n" if ord($t) != 0xff; }
Branch: 1 branch
BranchTrueFalseTotal
if ord $t != 255 0 113 113
57  
58 # The following functions defined in Image::ExifTool::Writer.pl are declared
59 # here so their prototypes will be available. These Writer routines will be
60 # autoloaded when any of them is called.
61 sub SetNewValue($;$$%);
62 sub SetNewValuesFromFile($$;@);
63 sub GetNewValue($$;$);
64 sub GetNewValues($$;$);
65 sub CountNewValues($);
66 sub SaveNewValues($);
67 sub RestoreNewValues($);
68 sub WriteInfo($$;$$);
69 sub SetFileModifyDate($$;$$$);
70 sub SetFileName($$;$$$);
71 sub SetSystemTags($$);
72 sub GetAllTags(;$);
73 sub GetWritableTags(;$);
74 sub GetAllGroups($;$);
75 sub GetNewGroups($);
76 sub GetDeleteGroups();
77 sub AddUserDefinedTags($%);
78 sub SetAlternateFile($$$);
79 # non-public routines below
80 sub InsertTagValues($$;$$$$);
81 sub IsWritable($);
82 sub IsSameFile($$$);
83 sub IsRawType($);
84 sub GetNewFileName($$);
85 sub LoadAllTables();
86 sub GetNewTagInfoList($;$);
87 sub GetNewTagInfoHash($@);
88 sub GetLangInfo($$);
89 sub Get64s($$);
90 sub Get64u($$);
91 sub GetFixed64s($$);
92 sub GetExtended($$);
93 sub Set64u(@);
94 sub Set64s(@);
95 sub DecodeBits($$;$);
96 sub EncodeBits($$;$$);
97 sub Filter($$$);
98 sub HexDump($;$%);
99 sub DumpTrailer($$);
100 sub DumpUnknownTrailer($$);
101 sub VerboseInfo($$$%);
102 sub VerboseValue($$$;$);
103 sub VPrint($$@);
104 sub Rationalize($;$);
105 sub Write($@);
106 sub GetGeolocateTags($$;$);
107 sub WriteTrailerBuffer($$$);
108 sub AddNewTrailers($;@);
109 sub Tell($);
110 sub WriteValue($$;$$$$);
111 sub WriteDirectory($$$;$);
112 sub WriteBinaryData($$$);
113 sub CheckBinaryData($$$);
114 sub WriteTIFF($$$);
115 sub PackUTF8(@);
116 sub UnpackUTF8($);
117 sub SetPreferredByteOrder($;$);
118 sub ImageDataHash($$$;$$);
119 sub CopyBlock($$$);
120 sub CopyFileAttrs($$$);
121 sub TimeNow(;$$);
122 sub InverseDateTime($$;$$);
123 sub NewGUID();
124 sub MakeTiffHeader($$$$;$$);
125  
126 # other subroutine definitions
127 sub SplitFileName($);
128 sub EncodeFileName($$;$);
129 sub WindowsLongPath($$);
130 sub Open($*$;$);
131 sub Exists($$;$);
132 sub IsDirectory($$);
133 sub Rename($$$);
134 sub Unlink($@);
135 sub SetFileTime($$;$$$$);
136 sub DoEscape($$);
137 sub ConvertFileSize($;$);
138 sub ParseArguments($;@); #(defined in attempt to avoid mod_perl problem)
139 sub ReadValue($$$;$$$);
140  
141 # list of main tag tables to load in LoadAllTables() (sub-tables are recursed
142 # automatically). Note: They will appear in this order in the documentation
143 # unless tweaked in BuildTagLookup::GetTableOrder().
144 113 @loadAllTables = qw(
145 PhotoMechanic Exif GeoTiff CanonRaw KyoceraRaw Lytro MinoltaRaw PanasonicRaw
146 SigmaRaw JPEG GIMP Jpeg2000 GIF BMP BMP::OS2 BMP::Extra BPG BPG::Extensions
147 WPG ICO PICT PNG MNG FLIF DjVu DPX OpenEXR ZISRAW MRC LIF MRC::FEI12 MIFF
148 PCX PGF PSP PhotoCD Radiance Other::PFM PDF PostScript Photoshop::Header
149 Photoshop::Layers Photoshop::ImageData FujiFilm::RAFHeader FujiFilm::RAF
150 FujiFilm::IFD FujiFilm::MRAW Samsung::Trailer Sony::SRF2 Sony::SR2SubIFD
151 Sony::PMP ITC ID3 ID3::Lyrics3 FLAC AAC Ogg Vorbis DSF WavPack APE
152 APE::NewHeader APE::OldHeader Audible MPC MPEG::Audio MPEG::Video MPEG::Xing
153 M2TS QuickTime QuickTime::ImageFile QuickTime::Stream QuickTime::Tags360Fly
154 Matroska Matroska::StdTag MOI MXF DV Flash Flash::FLV Real::Media
155 Real::Audio Real::Metafile Red RIFF AIFF ASF TNEF WTV DICOM FITS XISF MIE
156 JSON HTML XMP::SVG Palm Palm::MOBI Palm::EXTH Torrent EXE EXE::PEVersion
157 EXE::PEString EXE::DebugRSDS EXE::DebugNB10 EXE::Misc EXE::MachO EXE::PEF
158 EXE::ELF EXE::AR EXE::CHM LNK LNK::INI PCAP Font VCard Text VCard::VCalendar
159 VCard::VNote RSRC Rawzor ZIP ZIP::GZIP ZIP::RAR ZIP::RAR5 RTF OOXML iWork
160 ISO FLIR::AFF FLIR::FPF MacOS MacOS::MDItem FlashPix::DocTable
161 );
162  
163 # alphabetical list of current Lang modules
164 113 @langs = qw(cs de en en_ca en_gb es fi fr it ja ko nl pl ru sk sv tr zh_cn zh_tw);
165  
166 113 $defaultLang = 'en'; # default language
167  
168 # language names
169 113 %langName = (
170 cs => 'Czech (Čeština)',
171 de => 'German (Deutsch)',
172 en => 'English',
173 en_ca => 'Canadian English',
174 en_gb => 'British English',
175 es => 'Spanish (Español)',
176 fi => 'Finnish (Suomi)',
177 fr => 'French (Français)',
178 it => 'Italian (Italiano)',
179 ja => 'Japanese (日本語)',
180 ko => 'Korean (한국어)',
181 nl => 'Dutch (Nederlands)',
182 pl => 'Polish (Polski)',
183 ru => 'Russian (Русский)',
184 sk => 'Slovak (Slovenčina)',
185 sv => 'Swedish (Svenska)',
186 'tr'=> 'Turkish (Türkçe)',
187 zh_cn => 'Simplified Chinese (简体中文)',
188 zh_tw => 'Traditional Chinese (繁體中文)',
189 );
190  
191 # recognized file types, in the order we test unknown files
192 # Notes: 1) There is no need to test for like types separately here
193 # 2) Put types with weak file signatures at end of list to avoid false matches
194 # 3) PLIST must be in this list for the binary PLIST format, although it may
195 # cause a file to be checked twice for XML
196 113 @fileTypes = qw(JPEG EXV CRW DR4 TIFF GIF MRW RAF X3F JP2 PNG MIE MIFF PS PDF
197 PSD XMP BMP WPG BPG PPM WV RIFF AIFF ASF MOV MPEG Real SWF PSP
198 FLV OGG FLAC APE MPC MKV MXF DV PMP IND PGF ICC ITC FLIR FLIF
199 FPF LFP HTML VRD RTF FITS XISF XCF DSF DSS QTIF FPX PICT ZIP
200 GZIP PLIST RAR 7Z BZ2 CZI TAR EXE EXR HDR CHM LNK WMF AVC DEX
201 DPX RAW Font JUMBF RSRC M2TS MacOS PHP PCX DCX DWF DWG DXF WTV
202 Torrent VCard LRI R3D AA PDB PFM2 MRC LIF JXL MOI ISO ALIAS PCAP
203 JSON MP3 KVAR TNEF DICOM PCD NKA ICO TXT AAC);
204  
205 # file types that we can write (edit)
206 113 my @writeTypes = qw(JPEG TIFF GIF CRW MRW ORF RAF RAW PNG MIE PSD XMP PPM EPS
207 X3F PS PDF ICC VRD DR4 JP2 JXL EXIF AI AIT IND MOV EXV FLIF
208 RIFF);
209 113 my %writeTypes; # lookup for writable file types (hash filled if required)
210  
211 # file extensions that we can't write for various base types
212 # (See here for 3FR reason: https://exiftool.org/forum/index.php?msg=17570)
213 113 %noWriteFile = (
214 TIFF => [ qw(3FR DCR K25 KDC SRF) ],
215 XMP => [ qw(SVG INX NXD) ],
216 JP2 => [ qw(J2C JPC) ],
217 MOV => [ qw(INSV) ],
218 );
219 # file extensions that we can only write for various base types
220 113 my %onlyWriteFile = ( RIFF => [ qw(WEBP) ] );
221  
222 # file types that we can create from scratch
223 # - must update CanCreate() documentation if this list is changed!
224 113 my %createTypes = map { $_ => 1 } qw(XMP ICC MIE VRD DR4 EXIF EXV);
225  
226 # file type lookup for all recognized file extensions (upper case)
227 # (if extension may be more than one type, the type is a list where
228 # the writable type should come first if it exists)
229 113 %fileTypeLookup = (
230 '360' => ['MOV', 'GoPro 360 video'],
231 '3FR' => ['TIFF', 'Hasselblad RAW format'],
232 '3G2' => ['MOV', '3rd Gen. Partnership Project 2 audio/video'],
233 '3GP' => ['MOV', '3rd Gen. Partnership Project audio/video'],
234 '3GP2'=> '3G2',
235 '3GPP'=> '3GP',
236 '7Z' => ['7Z', '7z archive'],
237 A => ['EXE', 'Static library'],
238 AA => ['AA', 'Audible Audiobook'],
239 AAC => ['AAC', 'Advanced Audio Coding'],
240 AAE => ['PLIST','Apple edit information'],
241 AAX => ['MOV', 'Audible Enhanced Audiobook'],
242 ACR => ['DICOM','American College of Radiology ACR-NEMA'],
243 ACFM => ['Font', 'Adobe Composite Font Metrics'],
244 AFM => ['Font', 'Adobe Font Metrics'],
245 AMFM => ['Font', 'Adobe Multiple Master Font Metrics'],
246 AI => [['PDF','PS'], 'Adobe Illustrator'],
247 AIF => 'AIFF',
248 AIFC => ['AIFF', 'Audio Interchange File Format Compressed'],
249 AIFF => ['AIFF', 'Audio Interchange File Format'],
250 AIT => 'AI',
251 ALIAS=> ['ALIAS','MacOS file alias'],
252 APE => ['APE', "Monkey's Audio format"],
253 APNG => ['PNG', 'Animated Portable Network Graphics'],
254 ARW => ['TIFF', 'Sony Alpha RAW format'],
255 ARQ => ['TIFF', 'Sony Alpha Pixel-Shift RAW format'],
256 ASF => ['ASF', 'Microsoft Advanced Systems Format'],
257 AVC => ['AVC', 'Advanced Video Connection'], # (extensions are actually _AU,_AD,_IM,_ID)
258 AVI => ['RIFF', 'Audio Video Interleaved'],
259 AVIF => ['MOV', 'AV1 Image File Format'],
260 AZW => 'MOBI', # (see http://wiki.mobileread.com/wiki/AZW)
261 AZW3 => 'MOBI',
262 BMP => ['BMP', 'Windows Bitmap'],
263 BPG => ['BPG', 'Better Portable Graphics'],
264 BTF => ['BTF', 'Big Tagged Image File Format'], #(unofficial)
265 BZ2 => ['BZ2', 'BZIP2 archive'],
266 CAP => 'PCAP',
267 C2PA => ['JUMBF','Coalition for Content Provenance and Authenticity'],
268 CHM => ['CHM', 'Microsoft Compiled HTML format'],
269 CIFF => ['CRW', 'Camera Image File Format'],
270 COS => ['COS', 'Capture One Settings'],
271 CR2 => ['TIFF', 'Canon RAW 2 format'],
272 CR3 => ['MOV', 'Canon RAW 3 format'],
273 CRM => ['MOV', 'Canon RAW Movie'],
274 CRW => ['CRW', 'Canon RAW format'],
275 CS1 => ['PSD', 'Sinar CaptureShop 1-Shot RAW'],
276 CSV => ['TXT', 'Comma-Separated Values'],
277 CUR => ['ICO', 'Windows Cursor'],
278 CZI => ['CZI', 'Zeiss Integrated Software RAW'],
279 DC3 => 'DICM',
280 DCM => 'DICM',
281 DCP => ['TIFF', 'DNG Camera Profile'],
282 DCR => ['TIFF', 'Kodak Digital Camera RAW'],
283 DCX => ['DCX', 'Multi-page PC Paintbrush'],
284 DEX => ['DEX', 'Dalvik Executable format'],
285 DFONT=> ['Font', 'Macintosh Data fork Font'],
286 DIB => ['BMP', 'Device Independent Bitmap'],
287 DIC => 'DICM',
288 DICM => ['DICOM','Digital Imaging and Communications in Medicine'],
289 DIR => ['DIR', 'Directory'],
290 DIVX => ['ASF', 'DivX media format'],
291 DJV => 'DJVU',
292 DJVU => ['AIFF', 'DjVu image'],
293 DLL => ['EXE', 'Windows Dynamic Link Library'],
294 DNG => ['TIFF', 'Digital Negative'],
295 DOC => ['FPX', 'Microsoft Word Document'],
296 DOCM => [['ZIP','FPX'], 'Office Open XML Document Macro-enabled'],
297 # Note: I have seen a password-protected DOCX file which was FPX-like, so I assume
298 # that any other MS Office file could be like this too. The only difference is
299 # that the ZIP and FPX formats are checked first, so if this is wrong, no biggie.
300 DOCX => [['ZIP','FPX'], 'Office Open XML Document'],
301 DOT => ['FPX', 'Microsoft Word Template'],
302 DOTM => [['ZIP','FPX'], 'Office Open XML Document Template Macro-enabled'],
303 DOTX => [['ZIP','FPX'], 'Office Open XML Document Template'],
304 DPX => ['DPX', 'Digital Picture Exchange' ],
305 DR4 => ['DR4', 'Canon VRD version 4 Recipe'],
306 DS2 => ['DSS', 'Digital Speech Standard 2'],
307 DSF => ['DSF', 'DSF Stream File'],
308 DSS => ['DSS', 'Digital Speech Standard'],
309 DV => ['DV', 'Digital Video'],
310 DVB => ['MOV', 'Digital Video Broadcasting'],
311 'DVR-MS'=>['ASF', 'Microsoft Digital Video recording'],
312 DWF => ['DWF', 'Autodesk drawing (Design Web Format)'],
313 DWG => ['DWG', 'AutoCAD Drawing'],
314 DYLIB=> ['EXE', 'Mach-O Dynamic Link Library'],
315 DXF => ['DXF', 'AutoCAD Drawing Exchange Format'],
316 EIP => ['ZIP', 'Capture One Enhanced Image Package'],
317 EPS => ['EPS', 'Encapsulated PostScript Format'],
318 EPS2 => 'EPS',
319 EPS3 => 'EPS',
320 EPSF => 'EPS',
321 EPUB => ['ZIP', 'Electronic Publication'],
322 ERF => ['TIFF', 'Epson Raw Format'],
323 EXE => ['EXE', 'Windows executable file'],
324 EXR => ['EXR', 'Open EXR'],
325 EXIF => ['EXIF', 'Exchangable Image File Metadata'],
326 EXV => ['EXV', 'Exiv2 metadata'],
327 F4A => ['MOV', 'Adobe Flash Player 9+ Audio'],
328 F4B => ['MOV', 'Adobe Flash Player 9+ audio Book'],
329 F4P => ['MOV', 'Adobe Flash Player 9+ Protected'],
330 F4V => ['MOV', 'Adobe Flash Player 9+ Video'],
331 FFF => [['TIFF','FLIR'], 'Hasselblad Flexible File Format'],
332 FIT => 'FITS',
333 FITS => ['FITS', 'Flexible Image Transport System'],
334 FLAC => ['FLAC', 'Free Lossless Audio Codec'],
335 FLA => ['FPX', 'Macromedia/Adobe Flash project'],
336 FLIF => ['FLIF', 'Free Lossless Image Format'],
337 FLIR => ['FLIR', 'FLIR File Format'], # (not an actual extension)
338 FLV => ['FLV', 'Flash Video'],
339 FPF => ['FPF', 'FLIR Public image Format'],
340 FPX => ['FPX', 'FlashPix'],
341 GIF => ['GIF', 'Compuserve Graphics Interchange Format'],
342 GLV => ['MOV', 'Garmin Low-resolution Video'],
343 GPR => ['TIFF', 'General Purpose RAW'], # https://gopro.github.io/gpr/
344 GZ => 'GZIP',
345 GZIP => ['GZIP', 'GNU ZIP compressed archive'],
346 HDP => ['TIFF', 'Windows HD Photo'],
347 HDR => ['HDR', 'Radiance RGBE High Dynamic Range'],
348 HEIC => ['MOV', 'High Efficiency Image Format still image'],
349 HEIF => ['MOV', 'High Efficiency Image Format'],
350 HIF => 'HEIF',
351 HTM => 'HTML',
352 HTML => ['HTML', 'HyperText Markup Language'],
353 ICAL => 'ICS',
354 ICC => ['ICC', 'International Color Consortium'],
355 ICM => 'ICC',
356 ICO => ['ICO', 'Windows Icon'],
357 ICS => ['VCard','iCalendar Schedule'],
358 IDML => ['ZIP', 'Adobe InDesign Markup Language'],
359 IIQ => ['TIFF', 'Phase One Intelligent Image Quality RAW'],
360 IND => ['IND', 'Adobe InDesign'],
361 INDD => ['IND', 'Adobe InDesign Document'],
362 INDT => ['IND', 'Adobe InDesign Template'],
363 INSV => ['MOV', 'Insta360 Video'],
364 INSP => ['JPEG', 'Insta360 Picture'],
365 INX => ['XMP', 'Adobe InDesign Interchange'],
366 ISO => ['ISO', 'ISO 9660 disk image'],
367 ITC => ['ITC', 'iTunes Cover Flow'],
368 J2C => ['JP2', 'JPEG 2000 codestream'],
369 J2K => 'J2C',
370 JNG => ['PNG', 'JPG Network Graphics'],
371 JP2 => ['JP2', 'JPEG 2000 file'],
372 # JP4? - looks like a JPEG but the image data is different
373 JPC => 'J2C',
374 JPE => 'JPEG',
375 JPEG => ['JPEG', 'Joint Photographic Experts Group'],
376 JPH => ['JP2', 'High-throughput JPEG 2000'],
377 JPF => 'JP2',
378 JPG => 'JPEG',
379 JPM => ['JP2', 'JPEG 2000 compound image'],
380 JPS => ['JPEG', 'JPEG Stereo image'],
381 JPX => ['JP2', 'JPEG 2000 with extensions'],
382 JSON => ['JSON', 'JavaScript Object Notation'],
383 JUMBF=> ['JUMBF','JPEG Universal Metadata Box Format'],
384 JXL => ['JXL', 'JPEG XL'],
385 JXR => ['TIFF', 'JPEG XR'],
386 K25 => ['TIFF', 'Kodak DC25 RAW'],
387 KDC => ['TIFF', 'Kodak Digital Camera RAW'],
388 KEY => ['ZIP', 'Apple Keynote presentation'],
389 KTH => ['ZIP', 'Apple Keynote Theme'],
390 KVAR => ['KVAR', 'Kandao Video Asset Resource'], #PH (NC)
391 LA => ['RIFF', 'Lossless Audio'],
392 LFP => ['LFP', 'Lytro Light Field Picture'],
393 LFR => 'LFP', # (Light Field RAW)
394 LIF => ['LIF', 'Leica Image File'],
395 LNK => ['LNK', 'Windows shortcut'],
396 LRF => ['MOV', 'Low-Resolution video File'], # (DJI)
397 LRI => ['LRI', 'Light RAW'],
398 LRV => ['MOV', 'Low-Resolution Video'], # (GoPro)
399 M2T => 'M2TS',
400 M2TS => ['M2TS', 'MPEG-2 Transport Stream'],
401 M2V => ['MPEG', 'MPEG-2 Video'],
402 M4A => ['MOV', 'MPEG-4 Audio'],
403 M4B => ['MOV', 'MPEG-4 audio Book'],
404 M4P => ['MOV', 'MPEG-4 Protected'],
405 M4V => ['MOV', 'MPEG-4 Video'],
406 MACOS=> ['MacOS','MacOS ._ sidecar file'],
407 MAX => ['FPX', '3D Studio MAX'],
408 MEF => ['TIFF', 'Mamiya (RAW) Electronic Format'],
409 MIE => ['MIE', 'Meta Information Encapsulation format'],
410 MIF => 'MIFF',
411 MIFF => ['MIFF', 'Magick Image File Format'],
412 MKA => ['MKV', 'Matroska Audio'],
413 MKS => ['MKV', 'Matroska Subtitle'],
414 MKV => ['MKV', 'Matroska Video'],
415 MNG => ['PNG', 'Multiple-image Network Graphics'],
416 MOBI => ['PDB', 'Mobipocket electronic book'],
417 MODD => ['PLIST','Sony Picture Motion metadata'],
418 MOI => ['MOI', 'MOD Information file'],
419 MOS => ['TIFF', 'Creo Leaf Mosaic'],
420 MOV => ['MOV', 'Apple QuickTime movie'],
421 MP3 => ['MP3', 'MPEG-1 Layer 3 audio'],
422 MP4 => ['MOV', 'MPEG-4 video'],
423 MPC => ['MPC', 'Musepack Audio'],
424 MPEG => ['MPEG', 'MPEG-1 or MPEG-2 audio/video'],
425 MPG => 'MPEG',
426 MPO => ['JPEG', 'Extended Multi-Picture format'],
427 MQV => ['MOV', 'Sony Mobile Quicktime Video'],
428 MRC => ['MRC', 'Medical Research Council image'],
429 MRW => ['MRW', 'Minolta RAW format'],
430 MTS => 'M2TS',
431 MXF => ['MXF', 'Material Exchange Format'],
432 # NDPI => ['TIFF', 'Hamamatsu NanoZoomer Digital Pathology Image'],
433 NEF => ['TIFF', 'Nikon (RAW) Electronic Format'],
434 NEWER => 'COS',
435 NKA => ['NKA', 'Nikon NX Studio Adjustments'],
436 NKSC => ['XMP', 'Nikon Sidecar'],
437 NMBTEMPLATE => ['ZIP','Apple Numbers Template'],
438 NRW => ['TIFF', 'Nikon RAW (2)'],
439 NUMBERS => ['ZIP','Apple Numbers spreadsheet'],
440 NXD => ['XMP', 'Nikon NX-D Settings'],
441 O => ['EXE', 'Relocatable Object'],
442 ODB => ['ZIP', 'Open Document Database'],
443 ODC => ['ZIP', 'Open Document Chart'],
444 ODF => ['ZIP', 'Open Document Formula'],
445 ODG => ['ZIP', 'Open Document Graphics'],
446 ODI => ['ZIP', 'Open Document Image'],
447 ODP => ['ZIP', 'Open Document Presentation'],
448 ODS => ['ZIP', 'Open Document Spreadsheet'],
449 ODT => ['ZIP', 'Open Document Text file'],
450 OFR => ['RIFF', 'OptimFROG audio'],
451 OGG => ['OGG', 'Ogg Vorbis audio file'],
452 OGV => ['OGG', 'Ogg Video file'],
453 ONP => ['JSON', 'ON1 Presets'],
454 OPUS => ['OGG', 'Ogg Opus audio file'],
455 ORF => ['ORF', 'Olympus RAW format'],
456 ORI => 'ORF',
457 OTF => ['Font', 'Open Type Font'],
458 PAC => ['RIFF', 'Lossless Predictive Audio Compression'],
459 PAGES => ['ZIP', 'Apple Pages document'],
460 PBM => ['PPM', 'Portable BitMap'],
461 PCAP => ['PCAP', 'Packet Capture'],
462 PCAPNG => ['PCAP', 'Packet Capture Next Generation'],
463 PCD => ['PCD', 'Kodak Photo CD Image Pac'],
464 PCT => 'PICT',
465 PCX => ['PCX', 'PC Paintbrush'],
466 PDB => ['PDB', 'Palm Database'],
467 PDF => ['PDF', 'Adobe Portable Document Format'],
468 PEF => ['TIFF', 'Pentax (RAW) Electronic Format'],
469 PFA => ['Font', 'PostScript Font ASCII'],
470 PFB => ['Font', 'PostScript Font Binary'],
471 PFM => [['Font','PFM2'], 'Printer Font Metrics'], # (description is overridden for Portable FloatMap images)
472 PGF => ['PGF', 'Progressive Graphics File'],
473 PGM => ['PPM', 'Portable Gray Map'],
474 PHP => ['PHP', 'PHP Hypertext Preprocessor'],
475 PHP3 => 'PHP',
476 PHP4 => 'PHP',
477 PHP5 => 'PHP',
478 PHPS => 'PHP',
479 PHTML=> 'PHP',
480 PICT => ['PICT', 'Apple PICTure'],
481 PLIST=> ['PLIST','Apple Property List'],
482 PMP => ['PMP', 'Sony DSC-F1 Cyber-Shot PMP'], # should stand for Proprietery Metadata Package ;)
483 PNG => ['PNG', 'Portable Network Graphics'],
484 POT => ['FPX', 'Microsoft PowerPoint Template'],
485 POTM => [['ZIP','FPX'], 'Office Open XML Presentation Template Macro-enabled'],
486 POTX => [['ZIP','FPX'], 'Office Open XML Presentation Template'],
487 PPAM => [['ZIP','FPX'], 'Office Open XML Presentation Addin Macro-enabled'],
488 PPAX => [['ZIP','FPX'], 'Office Open XML Presentation Addin'],
489 PPM => ['PPM', 'Portable Pixel Map'],
490 PPS => ['FPX', 'Microsoft PowerPoint Slideshow'],
491 PPSM => [['ZIP','FPX'], 'Office Open XML Presentation Slideshow Macro-enabled'],
492 PPSX => [['ZIP','FPX'], 'Office Open XML Presentation Slideshow'],
493 PPT => ['FPX', 'Microsoft PowerPoint Presentation'],
494 PPTM => [['ZIP','FPX'], 'Office Open XML Presentation Macro-enabled'],
495 PPTX => [['ZIP','FPX'], 'Office Open XML Presentation'],
496 PRC => ['PDB', 'Palm Database'],
497 PS => ['PS', 'PostScript'],
498 PS2 => 'PS',
499 PS3 => 'PS',
500 PSB => ['PSD', 'Photoshop Large Document'],
501 PSD => ['PSD', 'Photoshop Document'],
502 PSDT => ['PSD', 'Photoshop Document Template'],
503 PSP => ['PSP', 'Paint Shop Pro'],
504 PSPFRAME => 'PSP',
505 PSPIMAGE => 'PSP',
506 PSPSHAPE => 'PSP',
507 PSPTUBE => 'PSP',
508 QIF => 'QTIF',
509 QT => 'MOV',
510 QTI => 'QTIF',
511 QTIF => ['QTIF', 'QuickTime Image File'],
512 R3D => ['R3D', 'Redcode RAW Video'],
513 RA => ['Real', 'Real Audio'],
514 RAF => ['RAF', 'FujiFilm RAW Format'],
515 RAM => ['Real', 'Real Audio Metafile'],
516 RAR => ['RAR', 'RAR Archive'],
517 RAW => [['RAW','TIFF'], 'Kyocera Contax N Digital RAW or Panasonic RAW'],
518 RIF => 'RIFF',
519 RIFF => ['RIFF', 'Resource Interchange File Format'],
520 RM => ['Real', 'Real Media'],
521 RMVB => ['Real', 'Real Media Variable Bitrate'],
522 RPM => ['Real', 'Real Media Plug-in Metafile'],
523 RSRC => ['RSRC', 'Mac OS Resource'],
524 RTF => ['RTF', 'Rich Text Format'],
525 RV => ['Real', 'Real Video'],
526 RW2 => ['TIFF', 'Panasonic RAW 2'],
527 RWL => ['TIFF', 'Leica RAW'],
528 RWZ => ['RWZ', 'Rawzor compressed image'],
529 SEQ => ['FLIR', 'FLIR image Sequence'],
530 SKETCH => ['ZIP', 'Sketch design file'],
531 SO => ['EXE', 'Shared Object file'],
532 SR2 => ['TIFF', 'Sony RAW Format 2'],
533 SRF => ['TIFF', 'Sony RAW Format'],
534 SRW => ['TIFF', 'Samsung RAW format'],
535 SVG => ['XMP', 'Scalable Vector Graphics'],
536 SWF => ['SWF', 'Shockwave Flash'],
537 TAR => ['TAR', 'TAR archive'],
538 THM => ['JPEG', 'Thumbnail'],
539 THMX => [['ZIP','FPX'], 'Office Open XML Theme'],
540 TIF => 'TIFF',
541 TIFF => ['TIFF', 'Tagged Image File Format'],
542 TNEF => ['TNEF', 'Transport Neural Encapsulation Format'], # (actual extension is .DAT)
543 TORRENT => ['Torrent', 'BitTorrent description file'],
544 TS => 'M2TS',
545 TTC => ['Font', 'True Type Font Collection'],
546 TTF => ['Font', 'True Type Font'],
547 TUB => 'PSP',
548 TXT => ['TXT', 'Text file'],
549 URL => ['LNK', 'Windows shortcut URL'],
550 VCARD=> ['VCard','Virtual Card'],
551 VCF => 'VCARD',
552 VOB => ['MPEG', 'Video Object'],
553 VNT => [['FPX','VCard'], 'Scene7 Vignette or V-Note text file'],
554 VRD => ['VRD', 'Canon VRD Recipe Data'],
555 VSD => ['FPX', 'Microsoft Visio Drawing'],
556 WAV => ['RIFF', 'WAVeform (Windows digital audio)'],
557 WDP => ['TIFF', 'Windows Media Photo'],
558 WEBM => ['MKV', 'Google Web Movie'],
559 WEBP => ['RIFF', 'Google Web Picture'],
560 WMA => ['ASF', 'Windows Media Audio'],
561 WMF => ['WMF', 'Windows Metafile Format'],
562 WMV => ['ASF', 'Windows Media Video'],
563 WV => ['WV', 'WavPack Audio'],
564 WVP => 'WV',
565 X3F => ['X3F', 'Sigma RAW format'],
566 XCF => ['XCF', 'GIMP native image format'],
567 XHTML=> ['HTML', 'Extensible HyperText Markup Language'],
568 XISF => ['XISF', 'Extensible Image Serialization Format'],
569 XLA => ['FPX', 'Microsoft Excel Add-in'],
570 XLAM => [['ZIP','FPX'], 'Office Open XML Spreadsheet Add-in Macro-enabled'],
571 XLS => ['FPX', 'Microsoft Excel Spreadsheet'],
572 XLSB => [['ZIP','FPX'], 'Office Open XML Spreadsheet Binary'],
573 XLSM => [['ZIP','FPX'], 'Office Open XML Spreadsheet Macro-enabled'],
574 XLSX => [['ZIP','FPX'], 'Office Open XML Spreadsheet'],
575 XLT => ['FPX', 'Microsoft Excel Template'],
576 XLTM => [['ZIP','FPX'], 'Office Open XML Spreadsheet Template Macro-enabled'],
577 XLTX => [['ZIP','FPX'], 'Office Open XML Spreadsheet Template'],
578 XMP => ['XMP', 'Extensible Metadata Platform'],
579 VSDX => ['ZIP', 'Visio Diagram Document'],
580 WOFF => ['Font', 'Web Open Font Format'],
581 WOFF2=> ['Font', 'Web Open Font Format 2'],
582 WPG => ['WPG', 'WordPerfect Graphics'],
583 WTV => ['WTV', 'Windows recorded TV show'],
584 ZIP => ['ZIP', 'ZIP archive'],
585 );
586  
587 # typical extension for each file type (if different than FileType)
588 # - case is not significant
589 113 my %fileTypeExt = (
590 'Canon 1D RAW' => 'tif',
591 DICOM => 'dcm',
592 FLIR => 'fff',
593 GZIP => 'gz',
594 JPEG => 'jpg',
595 M2TS => 'mts',
596 MPEG => 'mpg',
597 TIFF => 'tif',
598 VCard => 'vcf',
599 );
600  
601 # descriptions for file types not found in above file extension lookup
602 113 my %fileDescription = (
603 DICOM => 'Digital Imaging and Communications in Medicine',
604 XML => 'Extensible Markup Language',
605 'Win32 EXE' => 'Windows 32-bit Executable',
606 'Win32 DLL' => 'Windows 32-bit Dynamic Link Library',
607 'Win64 EXE' => 'Windows 64-bit Executable',
608 'Win64 DLL' => 'Windows 64-bit Dynamic Link Library',
609 VNote => 'V-Note document',
610 );
611  
612 # MIME types for applicable file types above
613 # (missing entries default to 'application/unknown', but note that other MIME
614 # types may be specified by some modules, eg. QuickTime.pm and RIFF.pm)
615 113 %mimeType = (
616 '3FR' => 'image/x-hasselblad-3fr',
617 '7Z' => 'application/x-7z-compressed',
618 AA => 'audio/audible',
619 AAC => 'audio/aac',
620 AAE => 'application/vnd.apple.photos',
621 AI => 'application/vnd.adobe.illustrator',
622 AIFF => 'audio/x-aiff',
623 ALIAS=> 'application/x-macos',
624 APE => 'audio/x-monkeys-audio',
625 APNG => 'image/apng',
626 ASF => 'video/x-ms-asf',
627 ARW => 'image/x-sony-arw',
628 BMP => 'image/bmp',
629 BPG => 'image/bpg',
630 BTF => 'image/x-tiff-big', #(NC) (ref http://www.asmail.be/msg0055371937.html)
631 BZ2 => 'application/bzip2',
632 C2PA => 'application/c2pa',
633 'Canon 1D RAW' => 'image/x-raw', # (uses .TIF file extension)
634 CHM => 'application/x-chm',
635 COS => 'application/octet-stream', #PH (NC)
636 CR2 => 'image/x-canon-cr2',
637 CR3 => 'image/x-canon-cr3',
638 CRM => 'video/x-canon-crm',
639 CRW => 'image/x-canon-crw',
640 CSV => 'text/csv',
641 CUR => 'image/x-cursor', #PH (NC)
642 CZI => 'image/x-zeiss-czi', #PH (NC)
643 DCP => 'application/octet-stream', #PH (NC)
644 DCR => 'image/x-kodak-dcr',
645 DCX => 'image/dcx',
646 DEX => 'application/octet-stream',
647 DFONT=> 'application/x-dfont',
648 DICOM=> 'application/dicom',
649 DIVX => 'video/divx',
650 DJVU => 'image/vnd.djvu',
651 DNG => 'image/x-adobe-dng',
652 DOC => 'application/msword',
653 DOCM => 'application/vnd.ms-word.document.macroEnabled.12',
654 DOCX => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
655 DOT => 'application/msword',
656 DOTM => 'application/vnd.ms-word.template.macroEnabledTemplate',
657 DOTX => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
658 DPX => 'image/x-dpx',
659 DR4 => 'application/octet-stream', #PH (NC)
660 DS2 => 'audio/x-ds2',
661 DSF => 'audio/x-dsf',
662 DSS => 'audio/x-dss',
663 DV => 'video/x-dv',
664 'DVR-MS' => 'video/x-ms-dvr',
665 DWF => 'model/vnd.dwf',
666 DWG => 'image/vnd.dwg',
667 DXF => 'application/dxf',
668 EIP => 'application/x-captureone', #(NC)
669 EPS => 'application/postscript',
670 ERF => 'image/x-epson-erf',
671 EXE => 'application/octet-stream',
672 EXR => 'image/x-exr',
673 EXV => 'image/x-exv',
674 FFF => 'image/x-hasselblad-fff',
675 FITS => 'image/fits',
676 FLA => 'application/vnd.adobe.fla',
677 FLAC => 'audio/flac',
678 FLIF => 'image/flif',
679 FLIR => 'image/x-flir-fff', #PH (NC)
680 FLV => 'video/x-flv',
681 Font => 'application/x-font-type1', # covers PFA, PFB and PFM (not sure about PFM)
682 FPF => 'image/x-flir-fpf', #PH (NC)
683 FPX => 'image/vnd.fpx',
684 GIF => 'image/gif',
685 GPR => 'image/x-gopro-gpr',
686 GZIP => 'application/x-gzip',
687 HDP => 'image/vnd.ms-photo',
688 HDR => 'image/vnd.radiance',
689 HTML => 'text/html',
690 ICC => 'application/vnd.iccprofile',
691 ICO => 'image/x-icon', #PH (NC)
692 ICS => 'text/calendar',
693 IDML => 'application/vnd.adobe.indesign-idml-package',
694 IIQ => 'image/x-raw',
695 IND => 'application/x-indesign',
696 INX => 'application/x-indesign-interchange', #PH (NC)
697 ISO => 'application/x-iso9660-image',
698 ITC => 'application/itunes',
699 J2C => 'image/x-j2c', #PH (NC)
700 JNG => 'image/jng',
701 JP2 => 'image/jp2',
702 JPEG => 'image/jpeg',
703 JPH => 'image/jph',
704 JPM => 'image/jpm',
705 JPS => 'image/x-jps',
706 JPX => 'image/jpx',
707 JSON => 'application/json',
708 JUMBF=> 'application/octet-stream', #PH (invented format)
709 JXL => 'image/jxl', #PH (NC)
710 JXR => 'image/jxr',
711 K25 => 'image/x-kodak-k25',
712 KDC => 'image/x-kodak-kdc',
713 KEY => 'application/x-iwork-keynote-sffkey',
714 LFP => 'image/x-lytro-lfp', #PH (NC)
715 LIF => 'image/x-lif',
716 LNK => 'application/octet-stream',
717 LRI => 'image/x-light-lri',
718 M2T => 'video/mpeg',
719 M2TS => 'video/m2ts',
720 MAX => 'application/x-3ds',
721 MEF => 'image/x-mamiya-mef',
722 MIE => 'application/x-mie',
723 MIFF => 'application/x-magick-image',
724 MKA => 'audio/x-matroska',
725 MKS => 'application/x-matroska',
726 MKV => 'video/x-matroska',
727 MNG => 'video/mng',
728 MOBI => 'application/x-mobipocket-ebook',
729 MOI => 'application/octet-stream', #PH (NC)
730 MOS => 'image/x-raw',
731 MOV => 'video/quicktime',
732 MP3 => 'audio/mpeg',
733 MP4 => 'video/mp4',
734 MPC => 'audio/x-musepack',
735 MPEG => 'video/mpeg',
736 MRC => 'image/x-mrc',
737 MRW => 'image/x-minolta-mrw',
738 MXF => 'application/mxf',
739 NEF => 'image/x-nikon-nef',
740 NKSC => 'application/x-nikon-nxstudio',
741 NRW => 'image/x-nikon-nrw',
742 NUMBERS => 'application/x-iwork-numbers-sffnumbers',
743 ODB => 'application/vnd.oasis.opendocument.database',
744 ODC => 'application/vnd.oasis.opendocument.chart',
745 ODF => 'application/vnd.oasis.opendocument.formula',
746 ODG => 'application/vnd.oasis.opendocument.graphics',
747 ODI => 'application/vnd.oasis.opendocument.image',
748 ODP => 'application/vnd.oasis.opendocument.presentation',
749 ODS => 'application/vnd.oasis.opendocument.spreadsheet',
750 ODT => 'application/vnd.oasis.opendocument.text',
751 OGG => 'audio/ogg',
752 OGV => 'video/ogg',
753 ONP => 'application/on1',
754 ORF => 'image/x-olympus-orf',
755 OTF => 'application/font-otf',
756 PAGES=> 'application/x-iwork-pages-sffpages',
757 PBM => 'image/x-portable-bitmap',
758 PCAP => 'application/vnd.tcpdump.pcap',
759 PCD => 'image/x-photo-cd',
760 PCX => 'image/pcx',
761 PDB => 'application/vnd.palm',
762 PDF => 'application/pdf',
763 PEF => 'image/x-pentax-pef',
764 PFA => 'application/x-font-type1', # (needed if handled by PostScript module)
765 PGF => 'image/pgf',
766 PGM => 'image/x-portable-graymap',
767 PHP => 'application/x-httpd-php',
768 PICT => 'image/pict',
769 PLIST=> 'application/xml', # (binary PLIST format is 'application/x-plist', recognized at run time)
770 PMP => 'image/x-sony-pmp', #PH (NC)
771 PNG => 'image/png',
772 POT => 'application/vnd.ms-powerpoint',
773 POTM => 'application/vnd.ms-powerpoint.template.macroEnabled.12',
774 POTX => 'application/vnd.openxmlformats-officedocument.presentationml.template',
775 PPAM => 'application/vnd.ms-powerpoint.addin.macroEnabled.12',
776 PPAX => 'application/vnd.openxmlformats-officedocument.presentationml.addin', # (NC, PH invented)
777 PPM => 'image/x-portable-pixmap',
778 PPS => 'application/vnd.ms-powerpoint',
779 PPSM => 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12',
780 PPSX => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
781 PPT => 'application/vnd.ms-powerpoint',
782 PPTM => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12',
783 PPTX => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
784 PS => 'application/postscript',
785 PSD => 'application/vnd.adobe.photoshop',
786 PSP => 'image/x-paintshoppro', #(NC)
787 QTIF => 'image/x-quicktime',
788 R3D => 'video/x-red-r3d', #PH (invented)
789 RA => 'audio/x-pn-realaudio',
790 RAF => 'image/x-fujifilm-raf',
791 RAM => 'audio/x-pn-realaudio',
792 RAR => 'application/x-rar-compressed',
793 RAW => 'image/x-raw',
794 RM => 'application/vnd.rn-realmedia',
795 RMVB => 'application/vnd.rn-realmedia-vbr',
796 RPM => 'audio/x-pn-realaudio-plugin',
797 RSRC => 'application/ResEdit',
798 RTF => 'text/rtf',
799 RV => 'video/vnd.rn-realvideo',
800 RW2 => 'image/x-panasonic-rw2',
801 RWL => 'image/x-leica-rwl',
802 RWZ => 'image/x-rawzor', #(duplicated in Rawzor.pm)
803 SEQ => 'image/x-flir-seq', #PH (NC)
804 SKETCH => 'application/sketch',
805 SR2 => 'image/x-sony-sr2',
806 SRF => 'image/x-sony-srf',
807 SRW => 'image/x-samsung-srw',
808 SVG => 'image/svg+xml',
809 SWF => 'application/x-shockwave-flash',
810 TAR => 'application/x-tar',
811 THMX => 'application/vnd.ms-officetheme',
812 TIFF => 'image/tiff',
813 TNEF => 'application/vnd.ms-tnef',
814 Torrent => 'application/x-bittorrent',
815 TTC => 'application/font-ttf',
816 TTF => 'application/font-ttf',
817 TXT => 'text/plain',
818 VCard=> 'text/vcard',
819 VRD => 'application/octet-stream', #PH (NC)
820 VSD => 'application/x-visio',
821 VSDX => 'application/vnd.ms-visio.drawing',
822 WDP => 'image/vnd.ms-photo',
823 WEBM => 'video/webm',
824 WMA => 'audio/x-ms-wma',
825 WMF => 'application/x-wmf',
826 WMV => 'video/x-ms-wmv',
827 WPG => 'image/x-wpg',
828 WTV => 'video/x-ms-wtv',
829 WV => 'audio/x-wavpack',
830 X3F => 'image/x-sigma-x3f',
831 XCF => 'image/x-xcf',
832 XISF => 'image/x-xisf',
833 XLA => 'application/vnd.ms-excel',
834 XLAM => 'application/vnd.ms-excel.addin.macroEnabled.12',
835 XLS => 'application/vnd.ms-excel',
836 XLSB => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12',
837 XLSM => 'application/vnd.ms-excel.sheet.macroEnabled.12',
838 XLSX => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
839 XLT => 'application/vnd.ms-excel',
840 XLTM => 'application/vnd.ms-excel.template.macroEnabled.12',
841 XLTX => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
842 XML => 'application/xml',
843 XMP => 'application/rdf+xml',
844 ZIP => 'application/zip',
845 );
846  
847 # module names for processing routines of each file type
848 # - undefined entries default to same module name as file type
849 # - module name '' defaults to Image::ExifTool
850 # - module name '0' indicates a recognized but unsupported file
851 113 my %moduleName = (
852 AA => 'Audible',
853 ALIAS=> 0,
854 AVC => 0,
855 BTF => 'BigTIFF',
856 BZ2 => 0,
857 CRW => 'CanonRaw',
858 CHM => 'EXE',
859 COS => 'CaptureOne',
860 CZI => 'ZISRAW',
861 DEX => 0,
862 DOCX => 'OOXML',
863 DCX => 0,
864 DIR => 0,
865 DR4 => 'CanonVRD',
866 DSS => 'Olympus',
867 DWF => 0,
868 DWG => 0,
869 DXF => 0,
870 EPS => 'PostScript',
871 EXIF => '',
872 EXR => 'OpenEXR',
873 EXV => '',
874 ICC => 'ICC_Profile',
875 IND => 'InDesign',
876 FLV => 'Flash',
877 FPF => 'FLIR',
878 FPX => 'FlashPix',
879 GZIP => 'ZIP',
880 HDR => 'Radiance',
881 JP2 => 'Jpeg2000',
882 JPEG => '',
883 JUMBF=> 'Jpeg2000',
884 JXL => 'Jpeg2000',
885 KVAR => 'Kandao',
886 LFP => 'Lytro',
887 LRI => 0,
888 MOV => 'QuickTime',
889 MKV => 'Matroska',
890 MP3 => 'ID3',
891 MRW => 'MinoltaRaw',
892 NKA => 'Nikon',
893 OGG => 'Ogg',
894 ORF => 'Olympus',
895 PDB => 'Palm',
896 PCD => 'PhotoCD',
897 PFM2 => 'Other',
898 PHP => 0,
899 PMP => 'Sony',
900 PS => 'PostScript',
901 PSD => 'Photoshop',
902 QTIF => 'QuickTime',
903 R3D => 'Red',
904 RAF => 'FujiFilm',
905 RAR => 'ZIP',
906 RAW => 'KyoceraRaw',
907 RWZ => 'Rawzor',
908 SWF => 'Flash',
909 TAR => 0,
910 TIFF => '',
911 TXT => 'Text',
912 VRD => 'CanonVRD',
913 WMF => 0,
914 WV => 'WavPack',
915 X3F => 'SigmaRaw',
916 XCF => 'GIMP',
917 );
918  
919 113 $testLen = 1024; # number of bytes to read when testing for magic number
920  
921 # quick "magic number" file test used to avoid loading module unnecessarily:
922 # - regular expression evaluated on first $testLen bytes of file
923 # - must match beginning at first byte in file
924 # - this test must not be more stringent than module logic
925 113 %magicNumber = (
926 AA => '.{4}\x57\x90\x75\x36',
927 AAC => '\xff[\xf0\xf1]',
928 AIFF => '(FORM....AIF[FC]|AT&TFORM)',
929 ALIAS=> "book\0\0\0\0mark\0\0\0\0",
930 APE => '(MAC |APETAGEX|ID3)',
931 ASF => '\x30\x26\xb2\x75\x8e\x66\xcf\x11\xa6\xd9\x00\xaa\x00\x62\xce\x6c',
932 AVC => '\+A\+V\+C\+',
933 Torrent => 'd\d+:\w+',
934 BMP => 'BM',
935 BPG => "BPG\xfb",
936 BTF => '(II\x2b\0|MM\0\x2b)',
937 BZ2 => 'BZh[1-9]\x31\x41\x59\x26\x53\x59',
938 CHM => 'ITSF.{20}\x10\xfd\x01\x7c\xaa\x7b\xd0\x11\x9e\x0c\0\xa0\xc9\x22\xe6\xec',
939 CRW => '(II|MM).{4}HEAP(CCDR|JPGM)',
940 CZI => 'ZISRAWFILE\0{6}',
941 DCX => '\xb1\x68\xde\x3a',
942 DEX => "dex\n035\0",
943 DICOM=> '(.{128}DICM|\0[\x02\x04\x06\x08]\0[\0-\x20]|[\x02\x04\x06\x08]\0[\0-\x20]\0)',
944 DOCX => 'PK\x03\x04',
945 DPX => '(SDPX|XPDS)',
946 DR4 => 'IIII[\x04|\x05]\0\x04\0',
947 DSF => 'DSD \x1c\0{7}.{16}fmt ',
948 DSS => '(\x02dss|\x03ds2)',
949 DV => '\x1f\x07\0[\x3f\xbf]', # (not tested if extension recognized)
950 DWF => '\(DWF V\d',
951 DWG => 'AC10\d{2}\0',
952 DXF => '\s*0\s+\0?\s*SECTION\s+2\s+HEADER',
953 EPS => '(%!PS|%!Ad|\xc5\xd0\xd3\xc6)',
954 EXE => '(MZ|\xca\xfe\xba\xbe|\xfe\xed\xfa[\xce\xcf]|[\xce\xcf]\xfa\xed\xfe|Joy!peff|\x7fELF|#!\s*/\S*bin/|!<arch>\x0a)',
955 EXIF => '(II\x2a\0|MM\0\x2a)',
956 EXR => '\x76\x2f\x31\x01',
957 EXV => '\xff\x01Exiv2',
958 FITS => 'SIMPLE = {20}T',
959 FLAC => '(fLaC|ID3)',
960 FLIF => 'FLIF[0-\x6f][0-2]',
961 FLIR => '[AF]FF\0',
962 FLV => 'FLV\x01',
963 Font => '((\0\x01\0\0|OTTO|true|typ1)[\0\x01]|ttcf\0[\x01\x02]\0\0|\0[\x01\x02]|' .
964 '(.{6})?%!(PS-(AdobeFont-|Bitstream )|FontType1-)|Start(Comp|Master)?FontMetrics|wOF[F2])',
965 FPF => 'FPF Public Image Format\0',
966 FPX => '\xd0\xcf\x11\xe0\xa1\xb1\x1a\xe1',
967 GIF => 'GIF8[79]a',
968 GZIP => '\x1f\x8b\x08',
969 HDR => '#\?(RADIANCE|RGBE)\x0a',
970 HTML => '(\xef\xbb\xbf)?\s*(?i)<(!DOCTYPE\s+HTML|HTML|\?xml)', # (case insensitive)
971 ICC => '.{12}(scnr|mntr|prtr|link|spac|abst|nmcl|nkpf|cenc|mid |mlnk|mvis)(XYZ |Lab |Luv |YCbr|Yxy |RGB |GRAY|HSV |HLS |CMYK|CMY |[2-9A-F]CLR|nc..|\0{4}){2}',
972 ICO => '\0\0[\x01\x02]\0[^0]\0', # (reasonably assume that the file contains less than 256 images)
973 IND => '\x06\x06\xed\xf5\xd8\x1d\x46\xe5\xbd\x31\xef\xe7\xfe\x74\xb7\x1d',
974 # ISO => signature is at byte 32768
975 ITC => '.{4}itch',
976 JP2 => '(\0\0\0\x0cjP( |\x1a\x1a)\x0d\x0a\x87\x0a|\xff\x4f\xff\x51\0)',
977 JPEG => '\xff\xd8\xff',
978 JSON => '(\xef\xbb\xbf)?\s*(\[\s*)?\{\s*"[^"]*"\s*:',
979 JUMBF=> '.{4}jumb\0.{3}jumd',
980 JXL => '(\xff\x0a|\0\0\0\x0cJXL \x0d\x0a......ftypjxl )',
981 KVAR => '.{2}\0\0[A-Z].{31}(CHAR|BOOL|[US](8|16|32|64)|FLOAT|DOUBLE)\0',
982 LFP => '\x89LFP\x0d\x0a\x1a\x0a',
983 LIF => '\x70\0{3}.{4}\x2a.{4}<\0',
984 LNK => '(.{4}\x01\x14\x02\0{5}\xc0\0{6}\x46|\[[InternetShortcut\][\x0d\x0a])',
985 LRI => 'LELR \0',
986 M2TS => '.{0,191}?\x47(.{187}|.{191})\x47(.{187}|.{191})\x47',
987 MacOS=> '\0\x05\x16\x07\0.\0\0Mac OS X ',
988 MIE => '~[\x10\x18]\x04.0MIE',
989 MIFF => 'id=ImageMagick',
990 MKV => '\x1a\x45\xdf\xa3',
991 MOV => '.{4}(free|skip|wide|ftyp|pnot|PICT|pict|moov|mdat|junk|uuid)', # (duplicated in WriteQuickTime.pl !!)
992 # MP3 => difficult to rule out
993 MPC => '(MP\+|ID3)',
994 MOI => 'V6',
995 MPEG => '\0\0\x01[\xb0-\xbf]',
996 MRC => '.{64}[\x01\x02\x03]\0\0\0[\x01\x02\x03]\0\0\0[\x01\x02\x03]\0\0\0.{132}MAP[\0 ](\x44\x44|\x44\x41|\x11\x11)\0\0',
997 MRW => '\0MR[MI]',
998 MXF => '\x06\x0e\x2b\x34\x02\x05\x01\x01\x0d\x01\x02', # (not tested if extension recognized)
999 NKA => 'NIKONADJ',
1000 OGG => '(OggS|ID3)',
1001 ORF => '(II|MM)',
1002 PCAP => '\xa1\xb2(\xc3\xd4|\x3c\x4d)\0.\0.|(\xd4\xc3|\x4d\x3c)\xb2\xa1.\0.\0|\x0a\x0d\x0d\x0a.{4}(\x1a\x2b\x3c\x4d|\x4d\x3c\x2b\x1a)|GMBU\0\x02',
1003 # PCD => signature is at byte 2048
1004 PCX => '\x0a[\0-\x05]\x01[\x01\x02\x04\x08].{64}[\0-\x02]',
1005 PDB => '.{60}(\.pdfADBE|TEXtREAd|BVokBDIC|DB99DBOS|PNRdPPrs|DataPPrs|vIMGView|PmDBPmDB|InfoINDB|ToGoToGo|SDocSilX|JbDbJBas|JfDbJFil|DATALSdb|Mdb1Mdb1|BOOKMOBI|DataPlkr|DataSprd|SM01SMem|TEXtTlDc|InfoTlIf|DataTlMl|DataTlPt|dataTDBP|TdatTide|ToRaTRPW|zTXTGPlm|BDOCWrdS)',
1006 PDF => '\s*%PDF-\d+\.\d+',
1007 PFM => 'P[Ff]\x0a\d+ \d+\x0a[-+0-9.]+\x0a',
1008 PGF => 'PGF',
1009 PHP => '<\?php\s',
1010 PICT => '(.{10}|.{522})(\x11\x01|\x00\x11)',
1011 PLIST=> '(bplist0|\s*<|\xfe\xff\x00)',
1012 PMP => '.{8}\0{3}\x7c.{112}\xff\xd8\xff\xdb',
1013 PNG => '(\x89P|\x8aM|\x8bJ)NG\r\n\x1a\n',
1014 PPM => 'P[1-6]\s+',
1015 PS => '(%!PS|%!Ad|\xc5\xd0\xd3\xc6)',
1016 PSD => '8BPS\0[\x01\x02]',
1017 PSP => 'Paint Shop Pro Image File\x0a\x1a\0{5}',
1018 QTIF => '.{4}(idsc|idat|iicc)',
1019 R3D => '\0\0..RED(1|2)',
1020 RAF => 'FUJIFILM',
1021 RAR => 'Rar!\x1a\x07\x01?\0',
1022 RAW => '(.{25}ARECOYK|II|MM)',
1023 Real => '(\.RMF|\.ra\xfd|pnm://|rtsp://|http://)',
1024 RIFF => '(RIFF|LA0[234]|OFR |LPAC|wvpk|RF64)', # RIFF plus other variants
1025 RSRC => '(....)?\0\0\x01\0',
1026 RTF => '[\n\r]*\\{[\n\r]*\\\\rtf',
1027 RWZ => 'rawzor',
1028 SWF => '[FC]WS[^\0]',
1029 TAR => '.{257}ustar( )?\0', # (this doesn't catch old-style tar files)
1030 TNEF => '\x78\x9f\x3e\x22..\x01\x06\x90\x08\0',
1031 TXT => '(\xff\xfe|(\0\0)?\xfe\xff|(\xef\xbb\xbf)?[\x07-\x0d\x20-\x7e\x80-\xfe]*$)',
1032 TIFF => '(II|MM)', # don't test magic number (some raw formats are different)
1033 VCard=> '(?i)BEGIN:(VCARD|VCALENDAR|VNOTE)\r\n',
1034 VRD => 'CANON OPTIONAL DATA\0',
1035 WMF => '(\xd7\xcd\xc6\x9a\0\0|\x01\0\x09\0\0\x03)',
1036 WPG => '\xff\x57\x50\x43',
1037 WTV => '\xb7\xd8\x00\x20\x37\x49\xda\x11\xa6\x4e\x00\x07\xe9\x5e\xad\x8d',
1038 X3F => 'FOVb',
1039 XCF => 'gimp xcf ',
1040 XISF => 'XISF0100',
1041 XMP => '\0{0,3}(\xfe\xff|\xff\xfe|\xef\xbb\xbf)?\0{0,3}\s*<',
1042 ZIP => 'PK\x03\x04',
1043 );
1044  
1045 # file types with weak magic number recognition
1046 113 my %weakMagic = ( MP3 => 1 );
1047  
1048 # file types that are determined by the process proc when FastScan > 2
1049 # (when done, the process proc must exit after SetFileType if FastScan is > 2)
1050 113 my %processType = map { $_ => 1 } qw(JPEG TIFF XMP AIFF EXE Font PS Real VCard TXT);
1051  
1052 # Compact/XMPShorthand option settings
1053 113 my %compactOpt = (
1054 nopadding => 'NoPadding', noindent => 'NoIndent', nonewline => 'NoNewline',
1055 shorthand => 'Shorthand', onedesc => 'OneDesc',
1056 all => ['NoPadding','NoIndent','NoNewline','Shorthand','OneDesc'],
1057 allspace => ['NoPadding','NoIndent','NoNewline'], allformat => ['Shorthand','OneDesc'],
1058 # aliases to cover anticipated user typos
1059 nonewlines => 'NoNewline', nospace => 'NoIndent', nospaces => 'NoIndent',
1060 nopad => 'NoPadding', onedescr => 'OneDesc',
1061 # allow numerical settings for backward compatibility
1062 0 => 'None',
1063 1 => 'NoPadding',
1064 2 => ['NoPadding','NoIndent'],
1065 3 => ['NoPadding','NoIndent','OneDesc'],
1066 4 => ['NoPadding','NoIndent','OneDesc','NoNewline'],
1067 5 => ['NoPadding','NoIndent','OneDesc','NoNewline','Shorthand'],
1068 );
1069 113 my %xmpShorthandOpt = ( 0 => 'None', 1 => 'Shorthand', 2 => ['Shorthand','OneDesc'] );
1070  
1071 # lookup for valid character set names (keys are all lower case)
1072 113 %charsetName = (
1073 # Charset setting alias(es)
1074 # ------------------------- --------------------------------------------
1075 utf8 => 'UTF8', cp65001 => 'UTF8', 'utf-8' => 'UTF8',
1076 latin => 'Latin', cp1252 => 'Latin', latin1 => 'Latin',
1077 latin2 => 'Latin2', cp1250 => 'Latin2',
1078 cyrillic => 'Cyrillic', cp1251 => 'Cyrillic', russian => 'Cyrillic',
1079 greek => 'Greek', cp1253 => 'Greek',
1080 turkish => 'Turkish', cp1254 => 'Turkish',
1081 hebrew => 'Hebrew', cp1255 => 'Hebrew',
1082 arabic => 'Arabic', cp1256 => 'Arabic',
1083 baltic => 'Baltic', cp1257 => 'Baltic',
1084 vietnam => 'Vietnam', cp1258 => 'Vietnam',
1085 thai => 'Thai', cp874 => 'Thai',
1086 doslatinus => 'DOSLatinUS', cp437 => 'DOSLatinUS',
1087 doslatin1 => 'DOSLatin1', cp850 => 'DOSLatin1',
1088 doscyrillic => 'DOSCyrillic', cp866 => 'DOSCyrillic',
1089 macroman => 'MacRoman', cp10000 => 'MacRoman', mac => 'MacRoman', roman => 'MacRoman',
1090 maclatin2 => 'MacLatin2', cp10029 => 'MacLatin2',
1091 maccyrillic => 'MacCyrillic', cp10007 => 'MacCyrillic',
1092 macgreek => 'MacGreek', cp10006 => 'MacGreek',
1093 macturkish => 'MacTurkish', cp10081 => 'MacTurkish',
1094 macromanian => 'MacRomanian', cp10010 => 'MacRomanian',
1095 maciceland => 'MacIceland', cp10079 => 'MacIceland',
1096 maccroatian => 'MacCroatian', cp10082 => 'MacCroatian',
1097 );
1098  
1099 # list of available options
1100 # +-----------------------------------------------------+
1101 # ! DON'T FORGET!! When adding any new option, must !
1102 # ! decide how it is handled in SetNewValuesFromFile() !
1103 # +-----------------------------------------------------+
1104 # (Note: All options must exist in this lookup, even if undefined,
1105 # to facilitate case-insensitive options. 'Group#' is handled specially)
1106 # (item 3 is a flag indicating the option is undocumented)
1107 113 my @availableOptions = (
1108 [ 'Binary', undef, 'flag to extract binary values even if tag not specified' ],
1109 [ 'ByteOrder', undef, 'default byte order when creating EXIF information' ],
1110 [ 'ByteUnit', 'SI', 'units for byte conversions (SI or Binary)'],
1111 [ 'Charset', 'UTF8', 'character set for converting Unicode characters' ],
1112 [ 'CharsetEXIF', undef, 'internal EXIF "ASCII" string encoding' ],
1113 [ 'CharsetFileName', undef, 'external encoding for file names' ],
1114 [ 'CharsetID3', 'Latin','internal ID3v1 character set' ],
1115 [ 'CharsetIPTC', 'Latin','fallback IPTC character set if no CodedCharacterSet' ],
1116 [ 'CharsetPhotoshop', 'Latin','internal encoding for Photoshop resource names' ],
1117 [ 'CharsetQuickTime', 'MacRoman', 'internal QuickTime string encoding' ],
1118 [ 'CharsetRIFF', 0, 'internal RIFF string encoding (0=default to Latin)' ],
1119 [ 'Compact', { }, 'write compact XMP' ],
1120 [ 'Composite', 1, 'flag to calculate Composite tags' ],
1121 [ 'Compress', undef, 'flag to write new values as compressed if possible' ],
1122 [ 'CoordFormat', undef, 'GPS lat/long coordinate format' ],
1123 [ 'DateFormat', undef, 'format for date/time' ],
1124 [ 'Debug', undef, 'enable debugging output', 1 ], # (undocumented)
1125 [ 'Duplicates', 1, 'flag to save duplicate tag values' ],
1126 # ("require Encode" hangs on my Windows 10 virtual machine running under MacOS if
1127 # the current working directory has a long path name. This problem hasn't been
1128 # seen on other Windows systems, so I'm leaving this option undocumented for now)
1129 [ 'EncodeHangs', undef, 'flag set to avoid using Encode if it hangs on your system', 1 ], # (undocumented)
1130 [ 'Escape', undef, 'escape special characters' ],
1131 [ 'Exclude', undef, 'tags to exclude' ],
1132 [ 'ExtendedXMP', 1, 'strategy for reading extended XMP' ],
1133 [ 'ExtractEmbedded', undef, 'flag to extract information from embedded documents' ],
1134 [ 'FastScan', undef, 'flag to avoid scanning for trailer' ],
1135 [ 'Filter', undef, 'output filter for all tag values' ],
1136 [ 'FilterW', undef, 'input filter when writing tag values' ],
1137 [ 'FixBase', undef, 'fix maker notes base offsets' ],
1138 [ 'Geolocation', undef, 'generate geolocation tags' ],
1139 [ 'GeolocAltNames', 1, 'search alternate city names if available' ],
1140 [ 'GeolocFeature', undef, 'regular expression of geolocation features to match' ],
1141 [ 'GeolocMinPop', undef, 'minimum geolocation population' ],
1142 [ 'GeolocMaxDist', undef, 'maximum geolocation distance' ],
1143 [ 'GeoMaxIntSecs', 1800, 'geotag maximum interpolation time (secs)' ],
1144 [ 'GeoMaxExtSecs', 1800, 'geotag maximum extrapolation time (secs)' ],
1145 [ 'GeoMaxHDOP', undef, 'geotag maximum HDOP' ],
1146 [ 'GeoMaxPDOP', undef, 'geotag maximum PDOP' ],
1147 [ 'GeoMinSats', undef, 'geotag minimum satellites' ],
1148 [ 'GeoHPosErr', undef, 'geotag GPSHPositioningError based on $GPSDOP' ],
1149 [ 'GeoSpeedRef', undef, 'geotag GPSSpeedRef' ],
1150 [ 'GeoUserTag', undef, 'user-defined tags for geotagging' ],
1151 [ 'GlobalTimeShift', undef, 'apply time shift to all extracted date/time values' ],
1152 [ 'GPSQuadrant', undef, 'quadrant for GPS if not otherwise known' ],
1153 [ 'Group#', undef, 'return tags for specified groups in family #' ],
1154 [ 'HexTagIDs', 0, 'use hex tag ID\'s in family 7 group names' ],
1155 [ 'HtmlDump', 0, 'HTML dump (0-3, higher # = bigger limit)' ],
1156 [ 'HtmlDumpBase', undef, 'base address for HTML dump' ],
1157 [ 'IgnoreGroups', undef, 'list of groups to ignore when extracting' ],
1158 [ 'IgnoreMinorErrors',undef, 'ignore minor errors when reading/writing' ],
1159 [ 'IgnoreTags', undef, 'list of tags to ignore when extracting' ],
1160 [ 'ImageHashType', 'MD5', 'image hash algorithm' ],
1161 [ 'KeepUTCTime', undef, 'do not convert times stored as UTC' ],
1162 [ 'Lang', $defaultLang, 'localized language for descriptions etc' ],
1163 [ 'LargeFileSupport', 1, 'flag indicating support of 64-bit file offsets' ],
1164 [ 'LimitLongValues', 60, 'length limit for long values' ],
1165 [ 'List', undef, '[deprecated, use ListSplit and ListJoin instead]', 1 ],
1166 [ 'ListItem', undef, 'used to return a specific item from lists' ],
1167 [ 'ListJoin', ', ', 'join lists together with this separator' ],
1168 [ 'ListSep', ', ', '[deprecated, use ListSplit and ListJoin instead]', 1 ],
1169 [ 'ListSplit', undef, 'regex for splitting list-type tag values when writing' ],
1170 # LigoGPSScale - undocumented scale for unfuzzing LIGO GPS: 1,2,3 for standard scales (1 default), or scale value
1171 [ 'MakerNotes', undef, 'extract maker notes as a block' ],
1172 [ 'MDItemTags', undef, 'extract MacOS metadata item tags' ],
1173 [ 'MissingTagValue', undef, 'value for missing tags when expanded in expressions' ],
1174 [ 'NoMandatory', undef, 'bypass writing of mandatory EXIF tags' ],
1175 [ 'NoMultiExif', undef, 'raise error when writing multi-segment EXIF' ],
1176 [ 'NoPDFList', undef, 'flag to avoid splitting PDF List-type tag values' ],
1177 [ 'NoWarning', undef, 'regular expression for warnings to suppress' ],
1178 [ 'Password', undef, 'password for password-protected PDF documents' ],
1179 [ 'Plot', undef, 'SVG plot settings' ],
1180 [ 'PrintCSV', undef, 'flag to print CSV directly (selected metadata types only)' ],
1181 [ 'PrintConv', 1, 'flag to enable print conversion' ],
1182 [ 'QuickTimeHandler', 1, 'flag to add mdir Handler to newly created Meta box' ],
1183 [ 'QuickTimePad', undef, 'flag to preserve padding of QuickTime CR3 tags' ],
1184 [ 'QuickTimeUTC', undef, 'assume that QuickTime date/time tags are stored as UTC' ],
1185 [ 'RequestAll', undef, 'extract all tags that must be specifically requested' ],
1186 [ 'RequestTags', undef, 'extra tags to request (on top of those in the tag list)' ],
1187 [ 'SaveBin', undef, 'save binary values of tags' ],
1188 [ 'SaveFormat', undef, 'save family 6 tag TIFF format' ],
1189 [ 'SavePath', undef, 'save family 5 location path' ],
1190 [ 'ScanForXMP', undef, 'flag to scan for XMP information in all files' ],
1191 [ 'Sort', 'Input','order to sort found tags (Input, File, Tag, Descr, Group#)' ],
1192 [ 'Sort2', 'File', 'secondary sort order for tags in a group (File, Tag, Descr)' ],
1193 [ 'StrictDate', undef, 'flag to return undef for invalid date conversions' ],
1194 [ 'Struct', undef, 'return structures as hash references' ],
1195 [ 'StructFormat', undef, 'format for structure serialization when reading/writing' ],
1196 [ 'SystemTags', undef, 'extract additional File System tags' ],
1197 [ 'SystemTimeRes', 0, 'number of sub-second digits in system and epoch times' ],
1198 [ 'TextOut', \*STDOUT, 'file for Verbose/HtmlDump output' ],
1199 [ 'TimeZone', undef, 'local time zone' ],
1200 [ 'UndefTags', undef, 'leave undef tags in -if conditions when -m or -f are used' ],
1201 [ 'Unknown', 0, 'flag to get values of unknown tags (0-2)' ],
1202 [ 'UserParam', { }, 'user parameters for additional user-defined tag values' ],
1203 [ 'Validate', undef, 'perform additional validation' ],
1204 [ 'Verbose', 0, 'print verbose messages (0-5, higher # = more verbose)' ],
1205 [ 'WindowsLongPath', 0, 'enable support for long pathnames (enables WindowsWideFile)' ],
1206 [ 'WindowsWideFile', undef, 'force the use of Windows wide-character file routines' ], # (see forum15208)
1207 [ 'WriteMode', 'wcg', 'enable all write modes by default' ],
1208 [ 'XAttrTags', undef, 'extract MacOS extended attribute tags' ],
1209 [ 'XMPAutoConv', 1, 'automatic conversion of unknown XMP tag values' ],
1210 [ 'XMPShorthand', 0, '[deprecated, use Compact=Shorthand instead]', 1 ],
1211 );
1212  
1213 # default family 0 group priority for writing
1214 # (NOTE: tags in groups not specified here will not be written unless
1215 # overridden by the module or specified when writing)
1216 113 my @defaultWriteGroups = qw(
1217 EXIF IPTC XMP MakerNotes QuickTime Photoshop ICC_Profile CanonVRD Adobe
1218 );
1219  
1220 # group hash for ExifTool-generated tags
1221 113 my %allGroupsExifTool = ( 0 => 'ExifTool', 1 => 'ExifTool', 2 => 'ExifTool' );
1222 113 my %geoInfo = ( Groups => { 0 => 'ExifTool', 1 => 'ExifTool', 2 => 'Location' } );
1223  
1224 # special tag names (not used for tag info)
1225 113 %specialTags = map { $_ => 1 } qw(
1226 TABLE_NAME SHORT_NAME PROCESS_PROC WRITE_PROC CHECK_PROC
1227 GROUPS FORMAT FIRST_ENTRY TAG_PREFIX PRINT_CONV
1228 WRITABLE TABLE_DESC NOTES IS_OFFSET IS_SUBDIR
1229 EXTRACT_UNKNOWN NAMESPACE PREFERRED SRC_TABLE PRIORITY
1230 AVOID WRITE_GROUP LANG_INFO VARS DATAMEMBER
1231 SET_GROUP1 PERMANENT INIT_TABLE
1232 );
1233  
1234 # headers for various segment types
1235 113 $exifAPP1hdr = "Exif\0\0";
1236 113 $xmpAPP1hdr = "http://ns.adobe.com/xap/1.0/\0";
1237 113 $xmpExtAPP1hdr = "http://ns.adobe.com/xmp/extension/\0";
1238 113 $psAPP13hdr = "Photoshop 3.0\0";
1239 113 $psAPP13old = 'Adobe_Photoshop2.5:';
1240  
1241 777 ▶sub DummyWriteProc { return 1; }
Subroutine DummyWriteProc: called CC=1 SCAR=0.0
Pod undocumented
1242  
1243 # lookup for user lenses defined in @Image::ExifTool::UserDefined::Lenses
1244 113 %Image::ExifTool::userLens = ( );
1245  
1246 # queued plug-in tags to add to lookup
1247 113 @Image::ExifTool::pluginTags = ( );
1248 113 %Image::ExifTool::pluginTags = ( );
1249  
1250 # memory purge variables
1251 113 my $purgeFlag = 0;
1252 113 my @purgeTags;
1253  
1254 113 my %systemTagsNotes = (
1255 Notes => q{
1256 extracted only if specifically requested or the API L<SystemTags|../ExifTool.html#SystemTags> or L<RequestAll|../ExifTool.html#RequestAll>
1257 option is set
1258 },
1259 );
1260  
1261 # tag information for preview image -- this should be used for all
1262 # PreviewImage tags so they are handled properly when reading/writing
1263 113 %Image::ExifTool::previewImageTagInfo = (
1264 Name => 'PreviewImage',
1265 Writable => 'undef',
1266 # a value of 'none' is ok...
1267 WriteCheck => '$val eq "none" ? undef : $self->CheckImage(\$val)',
1268 DataTag => 'PreviewImage',
1269 # accept either scalar or scalar reference
1270 RawConv => '$self->ValidateImage(ref $val ? $val : \$val, $tag)',
1271 # we allow preview image to be set to '', but we don't want a zero-length value
1272 # in the IFD, so set it temporarily to 'none'. Note that the length is <= 4,
1273 # so this value will fit in the IFD so the preview fixup won't be generated.
1274 ValueConvInv => '$val eq "" and $val="none"; $val',
1275 );
1276  
1277 # extra tags that aren't truly EXIF tags, but are generated by the script
1278 # Note: any tag in this list with a name corresponding to a Group0 name is
1279 # used to write the entire corresponding directory as a block.
1280 %Image::ExifTool::Extra = (
1281 GROUPS => { 0 => 'File', 1 => 'File', 2 => 'Image' },
1282 VARS => { ID_FMT => 'none' }, # tag ID's aren't meaningful for these tags
1283 WRITE_PROC => \&DummyWriteProc,
1284 Error => {
1285 Priority => 0,
1286 Groups => \%allGroupsExifTool,
1287 Notes => q{
1288 returns errors that may have occurred while reading or writing a file. Any
1289 Error will prevent the file from being processed. Minor errors may be
1290 downgraded to warnings with the -m or L<IgnoreMinorErrors|../ExifTool.html#IgnoreMinorErrors> option
1291 },
1292 },
1293 Warning => {
1294 Priority => 0,
1295 Groups => \%allGroupsExifTool,
1296 Notes => q{
1297 returns warnings that may have occurred while reading or writing a file.
1298 Use the -a or L<Duplicates|../ExifTool.html#Duplicates> option to see all warnings if more than one
1299 occurred. Minor warnings may be ignored with the -m or L<IgnoreMinorErrors|../ExifTool.html#IgnoreMinorErrors>
1300 option. Minor warnings with a capital "M" in the "[Minor]" designation
1301 indicate that the processing is affected by ignoring the warning. Multiple
1302 identical warnings are indicated by a count after the warning message, eg.
1303 "[x2]" if the same warning occurred twice
1304 },
1305 },
1306 Comment => {
1307 Notes => 'comment embedded in JPEG, GIF89a or PPM/PGM/PBM image',
1308 Writable => 1,
1309 WriteGroup => 'Comment',
1310 Priority => 0, # to preserve order of JPEG COM segments
1311 },
1312 Directory => {
1313 Groups => { 1 => 'System', 2 => 'Other' },
1314 Notes => q{
1315 the directory of the file as specified in the call to ExifTool, or "." if no
1316 directory was specified. May be written to move the file to another
1317 directory that will be created if doesn't already exist
1318 },
1319 Writable => 1,
1320 WritePseudo => 1,
1321 Priority => 2,
1322 DelCheck => q{"Can't delete"},
1323 Protected => 1,
1324 RawConv => '$self->ConvertFileName($val)',
1325 # translate backslashes in directory names and add trailing '/'
1326 ValueConvInv => '$_ = $self->InverseFileName($val); m{[^/]$} and $_ .= "/"; $_',
1327 },
1328 FileName => {
1329 Groups => { 1 => 'System', 2 => 'Other' },
1330 Writable => 1,
1331 WritePseudo => 1,
1332 DelCheck => q{"Can't delete"},
1333 Protected => 1,
1334 Priority => 2,
1335 Notes => q{
1336 may be written with a full path name to set FileName and Directory in one
1337 operation. This is such a powerful feature that a TestName tag is provided
1338 to allow dry-run tests before actually writing the file name. See
1339 L<filename.html|../filename.html> for more information on writing the
1340 FileName, Directory and TestName tags
1341 },
1342 RawConv => '$self->ConvertFileName($val)',
1343 ValueConvInv => '$self->InverseFileName($val)',
1344 },
1345 BaseName => {
1346 Groups => { 1 => 'System', 2 => 'Other' },
1347 Priority => 2,
1348 Notes => q{
1349 file name without extension. Not generated unless specifically requested or
1350 the API L<RequestAll|../ExifTool.html#RequestAll> option is set
1351 },
1352 },
1353 FilePath => {
1354 Groups => { 1 => 'System', 2 => 'Other' },
1355 Notes => q{
1356 absolute path of source file. Not generated unless specifically requested or
1357 the API L<RequestAll|../ExifTool.html#RequestAll> option is set. Does not support Windows Unicode file
1358 names
1359 },
1360 },
1361 TestName => {
1362 Writable => 1,
1363 WritePseudo => 1,
1364 DelCheck => q{"Can't delete"},
1365 Protected => 1,
1366 WriteOnly => 1,
1367 Notes => q{
1368 this write-only tag may be used instead of FileName for dry-run tests of the
1369 file renaming feature. Writing this tag prints the old and new file names
1370 to the console, but does not affect the file itself
1371 },
1372 ValueConvInv => '$self->InverseFileName($val)',
1373 },
1374 FileSequence => {
1375 Groups => { 0 => 'ExifTool', 1 => 'ExifTool', 2 => 'Other' },
1376 Notes => q{
1377 sequence number for each source file when extracting or copying information,
1378 including files that fail the -if condition of the command-line application,
1379 beginning at 0 for the first file. Not generated unless specifically
1380 requested or the API L<RequestAll|../ExifTool.html#RequestAll> option is set
1381 },
1382 },
1383 FileSize => {
1384 Groups => { 1 => 'System', 2 => 'Other' },
1385 Notes => q{
1386 note that the print conversion for this tag uses SI prefixes by default: 1
1387 kB = 1000 bytes, etc. Set the API ByteUnit option to "Binary" to use binary
1388 prefixes instead: 1 KiB = 1024 bytes, etc.
1389 },
1390 PrintConv => \&ConvertFileSize,
1391 },
1392 ResourceForkSize => {
1393 Groups => { 1 => 'System', 2 => 'Other' },
1394 Notes => q{
1395 size of the file's resource fork if it contains data. Mac OS only. If this
1396 tag is generated the L<ExtractEmbedded|../ExifTool.html#ExtractEmbedded> option may be used to extract
1397 resource-fork information as a sub-document. When writing, the resource
1398 fork is preserved by default, but it may be deleted with C<-rsrc:all=> on
1399 the command line
1400 },
1401 PrintConv => \&ConvertFileSize,
1402 },
1403 ZoneIdentifier => {
1404 Groups => { 1 => 'System', 2 => 'Other' },
1405 Notes => q{
1406 Windows only. Existence indicates that the file has a Zone.Identifier
1407 alternate data stream, which is used by some Windows browsers to mark
1408 downloaded files as possibly unsafe to run. May be deleted to remove this
1409 stream. Requires Win32API::File
1410 },
1411 Writable => 1,
1412 WritePseudo => 1,
1413 Protected => 1,
1414 },
1415 FileType => {
1416 Groups => { 2 => 'Other' },
1417 Priority => 2,
1418 Notes => q{
1419 a short description of the file type. For many file types this is the just
1420 the uppercase file extension
1421 },
1422 },
1423 FileTypeExtension => {
1424 Groups => { 2 => 'Other' },
1425 Notes => q{
1426 a common lowercase extension for this file type, or uppercase with the -n
1427 option
1428 },
1429 PrintConv => 'lc $val',
1430 },
1431 FileModifyDate => {
1432 Description => 'File Modification Date/Time',
1433 Notes => q{
1434 the filesystem modification date/time. Note that ExifTool may not be able
1435 to handle filesystem dates before 1970 depending on the limitations of the
1436 system's standard libraries
1437 },
1438 Groups => { 1 => 'System', 2 => 'Time' },
1439 Writable => 1,
1440 WritePseudo => 1,
1441 DelCheck => q{"Can't delete"},
1442 # all writable pseudo-tags must be protected so -tagsfromfile fails with
1443 # unrecognized files unless a pseudo tag is specified explicitly
1444 Protected => 1,
1445 Shift => 'Time',
1446 ValueConv => 'ConvertUnixTime($val,1)',
1447 ValueConvInv => 'GetUnixTime($val,1)',
1448 PrintConv => '$self->ConvertDateTime($val)',
1449 PrintConvInv => '$self->InverseDateTime($val)',
1450 },
1451 FileAccessDate => {
1452 Description => 'File Access Date/Time',
1453 Notes => q{
1454 the date/time of last access of the file. Note that this access time is
1455 updated whenever any software, including ExifTool, reads the file
1456 },
1457 Groups => { 1 => 'System', 2 => 'Time' },
1458 ValueConv => 'ConvertUnixTime($val,1)',
1459 PrintConv => '$self->ConvertDateTime($val)',
1460 },
1461 FileCreateDate => {
1462 Description => 'File Creation Date/Time',
1463 Notes => q{
1464 the filesystem creation date/time. Windows/Mac/Linux only. In Windows, the
1465 file creation date/time is preserved by default when writing if
1466 Win32API::File and Win32::API are available. On Mac, this tag is extracted
1467 only if it or the MacOS group is specifically requested or the API
1468 L<RequestAll|../ExifTool.html#RequestAll> option is set to 2 or higher. On
1469 Linux, this tag is read-only and extracted only if the filesystem supports
1470 btime and "File::StatX" is available. Requires "setfile" for writing on
1471 Mac, which may be installed by typing C<xcode-select --install> in the
1472 Terminal
1473 },
1474 Groups => { 1 => 'System', 2 => 'Time' },
1475 Writable => 1,
1476 WritePseudo => 1,
1477 DelCheck => q{"Can't delete"},
1478 Protected => 1, # all writable pseudo-tags must be protected!
1479 Shift => 'Time',
1480 ValueConv => '$^O eq "darwin" ? $val : ConvertUnixTime($val,1)',
1481 ValueConvInv => q{
1482 return GetUnixTime($val,1) if $^O eq 'MSWin32';
1483 return $val if $^O eq 'darwin';
1484 warn "This tag is Windows/Mac only\n";
1485 return undef;
1486 },
1487 PrintConv => '$self->ConvertDateTime($val)',
1488 PrintConvInv => '$self->InverseDateTime($val)',
1489 },
1490 FileInodeChangeDate => {
1491 Description => 'File Inode Change Date/Time',
1492 Notes => q{
1493 the date/time when the file's directory information was last changed.
1494 Non-Windows systems only
1495 },
1496 Groups => { 1 => 'System', 2 => 'Time' },
1497 ValueConv => 'ConvertUnixTime($val,1)',
1498 PrintConv => '$self->ConvertDateTime($val)',
1499 },
1500 FilePermissions => {
1501 Groups => { 1 => 'System', 2 => 'Other' },
1502 Notes => q{
1503 r=read, w=write and x=execute permissions for the file owner, group and
1504 others. The ValueConv value is an octal number so bit test operations on
1505 this value should be done in octal, eg. 'oct($filePermissions#) & 0200'
1506 },
1507 Writable => 1,
1508 WritePseudo => 1,
1509 DelCheck => q{"Can't delete"},
1510 Protected => 1, # all writable pseudo-tags must be protected!
1511 ValueConv => 'sprintf("%.3o", $val)',
1512 ValueConvInv => 'oct($val & 07777)',
1513 275 ▶ PrintConv => sub {
Subroutine __ANON__: called CC=5 SCAR=16.1
1514 275 my ($mask, $val) = (0400, oct(shift));
1515 275 my %types = (
1516 0010000 => 'p', # FIFO
1517 0020000 => 'c', # character special file
1518 0040000 => 'd', # directory
1519 0060000 => 'b', # block special file
1520 0120000 => 'l', # sym link
1521 0140000 => 's', # socket link
1522 );
1523 275 ▶ my $str = $types{$val & 0170000} || '-';
Condition50%1/2
$types{$val & 61440} || '-'
l!l
0275
MC/DC0%0/1
$types{$val & 61440} || '-'
$types{$val & 61440}
Truth table50%1/2
A
A= $types{$val & 61440}
Aresult
11
00
1524 275 ▶ while ($mask) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mask) 825 275 1100
1525 825 foreach (qw(r w x)) {
1526 2475 ▶ $str .= $val & $mask ? $_ : '-';
Branch: 1 branch
BranchTrueFalseTotal
$val & $mask ? : 1121 1354 2475
1527 2475 $mask >>= 1;
1528 }
1529 }
1530 275 return $str;
1531 },
1532 0 ▶ PrintConvInv => sub {
Subroutine __ANON__: not called CC=6 SCAR=37.4
1533 0 my ($bit, $val, $str) = (8, 0, shift);
1534 0 ▶ $str = substr($str, 1) if length($str) == 10;
Branch: 1 branch
BranchTrueFalseTotal
if length $str == 10 0 0 0
1535 0 ▶ return undef if length($str) != 9;
Branch: 1 branch
BranchTrueFalseTotal
if length $str != 9 0 0 0
1536 0 ▶ while ($bit >= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bit >= 0) 0 0 0
1537 0 foreach (qw(r w x)) {
1538 0 ▶ $val |= (1 << $bit) if substr($str, 8-$bit, 1) eq $_;
Branch: 1 branch
BranchTrueFalseTotal
if substr($str, 8 - $bit, 1) eq $_ 0 0 0
1539 0 --$bit;
1540 }
1541 }
1542 0 return sprintf('%.3o', $val);
1543 },
1544 },
1545 113 FileAttributes => {
1546 Groups => { 1 => 'System', 2 => 'Other' },
1547 Notes => q{
1548 extracted only if specifically requested or the API L<SystemTags|../ExifTool.html#SystemTags> or L<RequestAll|../ExifTool.html#RequestAll>
1549 option is set. 2 or 3 values: 0. File type, 1. Attribute bits, 2. Windows
1550 attribute bits if Win32API::File is available
1551 },
1552 PrintHex => 1,
1553 PrintConvColumns => 2,
1554 PrintConv => [{ # stat device types (bitmask 0xf000)
1555 0x0000 => 'Unknown',
1556 0x1000 => 'FIFO',
1557 0x2000 => 'Character',
1558 0x3000 => 'Mux Character',
1559 0x4000 => 'Directory',
1560 0x5000 => 'XENIX Named',
1561 0x6000 => 'Block',
1562 0x7000 => 'Mux Block',
1563 0x8000 => 'Regular',
1564 0x9000 => 'VxFS Compressed',
1565 0xa000 => 'Symbolic Link',
1566 0xb000 => 'Solaris Shadow Inode',
1567 0xc000 => 'Socket',
1568 0xd000 => 'Solaris Door',
1569 0xe000 => 'BSD Whiteout',
1570 },{ BITMASK => { # stat attribute bits (bitmask 0x0e00)
1571 9 => 'Sticky',
1572 10 => 'Set Group ID',
1573 11 => 'Set User ID',
1574 }},{ BITMASK => { # Windows attribute bits
1575 0 => 'Read Only',
1576 1 => 'Hidden',
1577 2 => 'System',
1578 3 => 'Volume Label',
1579 4 => 'Directory',
1580 5 => 'Archive',
1581 6 => 'Device',
1582 7 => 'Normal',
1583 8 => 'Temporary',
1584 9 => 'Sparse File',
1585 10 => 'Reparse Point',
1586 11 => 'Compressed',
1587 12 => 'Offline',
1588 13 => 'Not Content Indexed',
1589 14 => 'Encrypted',
1590 }}],
1591 },
1592 FileDeviceID => {
1593 Groups => { 1 => 'System', 2 => 'Other' },
1594 %systemTagsNotes,
1595 PrintConv => '(($val >> 24) & 0xff) . "." . ($val & 0xffffff)', # (major.minor)
1596 },
1597 FileDeviceNumber => { Groups => { 1 => 'System', 2 => 'Other' }, %systemTagsNotes },
1598 FileInodeNumber => { Groups => { 1 => 'System', 2 => 'Other' }, %systemTagsNotes },
1599 FileHardLinks => { Groups => { 1 => 'System', 2 => 'Other' }, %systemTagsNotes },
1600 FileUserID => {
1601 Groups => { 1 => 'System', 2 => 'Other' },
1602 Notes => q{
1603 extracted only if specifically requested or the API L<SystemTags|../ExifTool.html#SystemTags> or L<RequestAll|../ExifTool.html#RequestAll>
1604 option is set. Returns user ID number with the -n option, or name
1605 otherwise. May be written with either user name or number
1606 },
1607 Writable => 1,
1608 WritePseudo => 1,
1609 DelCheck => q{"Can't delete"},
1610 Protected => 1, # all writable pseudo-tags must be protected!
1611 PrintConv => 'eval { getpwuid($val) } || $val',
1612 PrintConvInv => 'eval { getpwnam($val) } || ($val=~/[^0-9]/ ? undef : $val)',
1613 },
1614 FileGroupID => {
1615 Groups => { 1 => 'System', 2 => 'Other' },
1616 Notes => q{
1617 extracted only if specifically requested or the API L<SystemTags|../ExifTool.html#SystemTags> or L<RequestAll|../ExifTool.html#RequestAll>
1618 option is set. Returns group ID number with the -n option, or name
1619 otherwise. May be written with either group name or number
1620 },
1621 Writable => 1,
1622 WritePseudo => 1,
1623 DelCheck => q{"Can't delete"},
1624 Protected => 1, # all writable pseudo-tags must be protected!
1625 PrintConv => 'eval { getgrgid($val) } || $val',
1626 PrintConvInv => 'eval { getgrnam($val) } || ($val=~/[^0-9]/ ? undef : $val)',
1627 },
1628 FileBlockSize => { Groups => { 1 => 'System', 2 => 'Other' }, %systemTagsNotes },
1629 FileBlockCount => { Groups => { 1 => 'System', 2 => 'Other' }, %systemTagsNotes },
1630 HardLink => {
1631 Writable => 1,
1632 DelCheck => q{"Can't delete"},
1633 WriteOnly => 1,
1634 WritePseudo => 1,
1635 Protected => 1,
1636 Notes => q{
1637 this write-only tag is used to create a hard link with the specified name to
1638 the source file. If the source file is edited, copied, renamed or moved in
1639 the same operation as writing HardLink, then the link is made to the updated
1640 file. Note that subsequent editing of either hard-linked file by exiftool
1641 will break the link unless the -overwrite_original_in_place option is used
1642 },
1643 ValueConvInv => '$val=~tr/\\\\/\//; $val',
1644 },
1645 SymLink => {
1646 Writable => 1,
1647 DelCheck => q{"Can't delete"},
1648 WriteOnly => 1,
1649 WritePseudo => 1,
1650 Protected => 1,
1651 Notes => q{
1652 this write-only tag is used to create a symbolic link with the specified
1653 name to the source file. If the source file is edited, copied, renamed or
1654 moved in the same operation as writing SymLink, then the link is made to the
1655 updated file. The link uses an absolute path unless it is created in the
1656 current working directory. Valid only for file systems that support
1657 symbolic links. Note that subsequent editing of the file via the symbolic
1658 link by exiftool will cause the link to be replaced by the edited file
1659 without changing the original unless the -overwrite_original_in_place option
1660 is used
1661 },
1662 ValueConvInv => '$val=~tr/\\\\/\//; $val',
1663 },
1664 MIMEType => { Notes => 'the MIME type of the source file', Groups => { 2 => 'Other' } },
1665 ImageWidth => { Notes => 'the width of the image in number of pixels' },
1666 ImageHeight => { Notes => 'the height of the image in number of pixels' },
1667 XResolution => { Notes => 'the horizontal pixel resolution' },
1668 YResolution => { Notes => 'the vertical pixel resolution' },
1669 NumPlanes => { Notes => 'number of color planes' },
1670 MaxVal => { Notes => 'maximum pixel value in PPM or PGM image' },
1671 EXIF => {
1672 Notes => q{
1673 the full EXIF data block from JPEG, PNG, JP2, MIE and MIFF images. This tag
1674 is generated only if specifically requested
1675 },
1676 Groups => { 0 => 'EXIF', 1 => 'EXIF' },
1677 Flags => ['Writable' ,'Protected', 'Binary', 'DelGroup'],
1678 WriteCheck => q{
1679 return undef if $val =~ /^(II\x2a\0|MM\0\x2a)/;
1680 return 'Invalid EXIF data';
1681 },
1682 },
1683 IPTC => {
1684 Notes => q{
1685 the full IPTC data block. This tag is generated only if specifically
1686 requested
1687 },
1688 Groups => { 0 => 'IPTC', 1 => 'IPTC' },
1689 Flags => ['Writable', 'Protected', 'Binary', 'DelGroup'],
1690 Priority => 0, # so main IPTC (which hopefully comes first) takes priority
1691 WriteCheck => q{
1692 return undef if $val =~ /^(\x1c|\0+$)/;
1693 return 'Invalid IPTC data';
1694 },
1695 },
1696 XMP => {
1697 Notes => q{
1698 the XMP data block, but note that extended XMP in JPEG images may be split
1699 into multiple blocks. This tag is generated only if specifically requested
1700 },
1701 Groups => { 0 => 'XMP', 1 => 'XMP' },
1702 Flags => ['Writable', 'Protected', 'Binary', 'DelGroup'],
1703 Priority => 0, # so main xmp (which usually comes first) takes priority
1704 WriteCheck => q{
1705 require Image::ExifTool::XMP;
1706 return Image::ExifTool::XMP::CheckXMP($self, $tagInfo, \$val);
1707 },
1708 },
1709 XML => {
1710 Notes => 'the XML data block, extracted for some file types',
1711 Groups => { 0 => 'XML', 1 => 'XML' },
1712 Binary => 1,
1713 },
1714 JUMBF => {
1715 Notes => 'the C2PA JUMBF data block, extracted only if specifically requested',
1716 Groups => { 0 => 'JUMBF', 1 => 'JUMBF' },
1717 Binary => 1,
1718 },
1719 ICC_Profile => {
1720 Notes => q{
1721 the full ICC_Profile data block. This tag is generated only if specifically
1722 requested
1723 },
1724 Groups => { 0 => 'ICC_Profile', 1 => 'ICC_Profile' },
1725 Flags => ['Writable' ,'Protected', 'Binary', 'DelGroup'],
1726 WriteCheck => q{
1727 require Image::ExifTool::ICC_Profile;
1728 return Image::ExifTool::ICC_Profile::ValidateICC(\$val);
1729 },
1730 },
1731 CanonVRD => {
1732 Notes => q{
1733 the full Canon DPP VRD trailer block. This tag is generated only if
1734 specifically requested
1735 },
1736 Groups => { 0 => 'CanonVRD', 1 => 'CanonVRD' },
1737 Flags => ['Writable' ,'Protected', 'Binary', 'DelGroup'],
1738 Permanent => 0, # (this is 1 by default for MakerNotes tags)
1739 WriteCheck => q{
1740 return undef if $val =~ /^CANON OPTIONAL DATA\0/;
1741 return 'Invalid CanonVRD data';
1742 },
1743 },
1744 CanonDR4 => {
1745 Notes => q{
1746 the full Canon DPP version 4 DR4 block. This tag is generated only if
1747 specifically requested
1748 },
1749 Groups => { 0 => 'CanonVRD', 1 => 'CanonVRD' },
1750 Flags => ['Writable' ,'Protected', 'Binary'],
1751 Permanent => 0, # (this is 1 by default for MakerNotes tags)
1752 WriteCheck => q{
1753 return undef if $val =~ /^IIII[\x04|\x05]\0\x04\0/;
1754 return 'Invalid CanonDR4 data';
1755 },
1756 },
1757 Adobe => {
1758 Notes => q{
1759 the JPEG APP14 Adobe segment. Extracted only if specified. See the
1760 L<JPEG Adobe Tags|JPEG.html#Adobe> for more information
1761 },
1762 Groups => { 0 => 'APP14', 1 => 'Adobe' },
1763 WriteGroup => 'Adobe',
1764 Flags => ['Writable' ,'Protected', 'Binary'],
1765 },
1766 CurrentIPTCDigest => {
1767 Notes => q{
1768 MD5 digest of existing IPTC data. All zeros if IPTC exists but Digest::MD5
1769 is not installed. Only calculated for IPTC in the standard location as
1770 specified by the L<MWG|http://www.metadataworkinggroup.org/>. ExifTool
1771 automates the handling of this tag in the MWG module -- see the
1772 L<MWG Composite Tags|MWG.html> for details
1773 },
1774 ValueConv => 'unpack("H*", $val)',
1775 },
1776 PreviewImage => {
1777 Notes => 'JPEG-format embedded preview image',
1778 Groups => { 2 => 'Preview' },
1779 Writable => 1,
1780 WriteCheck => '$self->CheckImage(\$val)',
1781 WriteGroup => 'All',
1782 # can't delete, so set to empty string and return no error
1783 DelCheck => '$val = ""; return undef',
1784 # accept either scalar or scalar reference
1785 RawConv => '$self->ValidateImage(ref $val ? $val : \$val, $tag)',
1786 },
1787 ThumbnailImage => {
1788 Groups => { 2 => 'Preview' },
1789 Notes => 'JPEG-format embedded thumbnail image',
1790 RawConv => '$self->ValidateImage(ref $val ? $val : \$val, $tag)',
1791 },
1792 OtherImage => {
1793 Groups => { 2 => 'Preview' },
1794 Notes => 'other JPEG-format embedded image',
1795 RawConv => '$self->ValidateImage(ref $val ? $val : \$val, $tag)',
1796 },
1797 PreviewPNG => {
1798 Groups => { 2 => 'Preview' },
1799 Notes => 'PNG-format embedded preview image',
1800 Binary => 1,
1801 },
1802 PreviewWMF => {
1803 Groups => { 2 => 'Preview' },
1804 Notes => 'WMF-format embedded preview image',
1805 Binary => 1,
1806 },
1807 PreviewTIFF => {
1808 Groups => { 2 => 'Preview' },
1809 Notes => 'TIFF-format embedded preview image',
1810 Binary => 1,
1811 },
1812 PreviewPDF => {
1813 Groups => { 2 => 'Preview' },
1814 Notes => 'PDF-format embedded preview image',
1815 Binary => 1,
1816 },
1817 PreviewJXL => {
1818 Groups => { 2 => 'Preview' },
1819 Notes => 'JXL-format embedded preview image',
1820 Binary => 1,
1821 },
1822 ExifByteOrder => {
1823 Writable => 1,
1824 DelCheck => q{"Can't delete"},
1825 Notes => q{
1826 represents the byte order of EXIF information. May be written to set the
1827 byte order only for newly created EXIF segments
1828 },
1829 PrintConv => {
1830 II => 'Little-endian (Intel, II)',
1831 MM => 'Big-endian (Motorola, MM)',
1832 },
1833 },
1834 MakerNoteByteOrder => {
1835 Notes => 'byte order of maker notes. Generated only if different from ExifByteOrder',
1836 PrintConv => {
1837 II => 'Little-endian (Intel, II)',
1838 MM => 'Big-endian (Motorola, MM)',
1839 },
1840 },
1841 ExifUnicodeByteOrder => {
1842 Writable => 1,
1843 WriteOnly => 1,
1844 DelCheck => q{"Can't delete"},
1845 Notes => q{
1846 specifies the byte order to use when writing EXIF Unicode text. The EXIF
1847 specification is particularly vague about this byte ordering, and different
1848 applications use different conventions. By default ExifTool writes Unicode
1849 text in EXIF byte order, but this write-only tag may be used to force a
1850 specific order. Applies to the EXIF UserComment tag when writing special
1851 characters
1852 },
1853 PrintConv => {
1854 II => 'Little-endian (Intel, II)',
1855 MM => 'Big-endian (Motorola, MM)',
1856 },
1857 },
1858 ExifToolVersion => {
1859 Description => 'ExifTool Version Number',
1860 Groups => \%allGroupsExifTool,
1861 Notes => 'the version of ExifTool currently running',
1862 },
1863 ProcessingTime => {
1864 Groups => { 0 => 'ExifTool', 1 => 'ExifTool', 2 => 'Other' },
1865 Notes => q{
1866 the clock time in seconds taken by ExifTool to extract information from this
1867 file. Not generated unless specifically requested or the API L<RequestAll|../ExifTool.html#RequestAll>
1868 option is set. Requires Time::HiRes
1869 },
1870 PrintConv => 'sprintf("%.3g s", $val)',
1871 },
1872 RAFVersion => { Notes => 'RAF file version number' },
1873 RAFCompression => { PrintConv => { 0 => 'Uncompressed', 2 => 'Compressed' } }, # 1 maybe lossy?
1874 JPEGDigest => {
1875 Notes => q{
1876 an MD5 digest of the JPEG quantization tables is combined with the component
1877 sub-sampling values to generate the value of this tag. The result is
1878 compared to known values in an attempt to deduce the originating software
1879 based only on the JPEG image data. For performance reasons, this tag is
1880 generated only if specifically requested or the API L<RequestAll|../ExifTool.html#RequestAll> option is set
1881 to 3 or higher
1882 },
1883 },
1884 JPEGQualityEstimate => {
1885 Notes => q{
1886 an estimate of the IJG JPEG quality setting for the image, calculated from
1887 the quantization tables. For performance reasons, this tag is generated
1888 only if specifically requested or the API L<RequestAll|../ExifTool.html#RequestAll> option is set to 3 or
1889 higher
1890 },
1891 },
1892 JPEGImageLength => {
1893 Notes => q{
1894 byte length of JPEG image without metadata. For performance reasons, this
1895 tag is generated only if specifically requested or the API L<RequestAll|../ExifTool.html#RequestAll> option
1896 is set to 3 or higher
1897 },
1898 },
1899 # Validate (added from Validate.pm)
1900 Now => {
1901 Groups => { 0 => 'ExifTool', 1 => 'ExifTool', 2 => 'Time' },
1902 Notes => q{
1903 the current date/time. Useful when setting the tag values, eg.
1904 C<"-modifydate<now">. Not generated unless specifically requested or the
1905 API L<RequestAll|../ExifTool.html#RequestAll> option is set
1906 },
1907 PrintConv => '$self->ConvertDateTime($val)',
1908 },
1909 NewGUID => {
1910 Groups => { 0 => 'ExifTool', 1 => 'ExifTool', 2 => 'Other' },
1911 Notes => q{
1912 generates a new, random GUID with format
1913 YYYYmmdd-HHMM-SSNN-PPPP-RRRRRRRRRRRR, where Y=year, m=month, d=day, H=hour,
1914 M=minute, S=second, N=file sequence number in hex, P=process ID in hex, and
1915 R=random hex number; without dashes with the -n option. Not generated
1916 unless specifically requested or the API L<RequestAll|../ExifTool.html#RequestAll> option is set
1917 },
1918 PrintConv => '$val =~ s/(.{8})(.{4})(.{4})(.{4})/$1-$2-$3-$4-/; $val',
1919 },
1920 ID3Size => { Notes => 'size of the ID3 data block' },
1921 Geotag => {
1922 Writable => 1,
1923 WriteOnly => 1,
1924 WriteNothing => 1,
1925 AllowGroup => '(exif|gps|xmp|xmp-exif)',
1926 Notes => q{
1927 this write-only tag is used to define the GPS track log data or track log
1928 file name. Currently supported track log formats are GPX, NMEA RMC/GGA/GLL,
1929 KML, IGC, Garmin XML and TCX, Magellan PMGNTRK, Honeywell PTNTHPR, Winplus
1930 Beacon text, Bramor gEO, Google Takeout JSON, and CSV log files. May be set
1931 to the special value of "DATETIMEONLY" (all caps) to set GPS date/time tags
1932 if no input track points are available. See L<geotag.html|../geotag.html>
1933 for details
1934 },
1935 DelCheck => q{
1936 require Image::ExifTool::Geotag;
1937 # delete associated tags
1938 Image::ExifTool::Geotag::SetGeoValues($self, undef, $wantGroup);
1939 },
1940 ValueConvInv => q{
1941 require Image::ExifTool::Geotag;
1942 # always warn because this tag is never set (warning is "\n" on success)
1943 my $result = Image::ExifTool::Geotag::LoadTrackLog($self, $val);
1944 return '' if not defined $result; # deleting geo tags
1945 return $result if ref $result; # geotag data hash reference
1946 warn "$result\n"; # error string
1947 },
1948 },
1949 Geotime => {
1950 Writable => 1,
1951 WriteOnly => 1,
1952 AllowGroup => '(exif|gps|xmp|xmp-exif|quicktime|keys|itemlist|userdata)',
1953 Notes => q{
1954 this write-only tag is used to define a date/time for interpolating a
1955 position in the GPS track specified by the Geotag tag. Writing this tag
1956 causes GPS information to be written into the EXIF or XMP of the target
1957 files. The local system timezone is assumed if the date/time value does not
1958 contain a timezone. May be deleted to delete associated GPS tags. A group
1959 name of "EXIF" or "XMP" may be specified to write or delete only EXIF or XMP
1960 GPS tags
1961 },
1962 DelCheck => q{
1963 require Image::ExifTool::Geotag;
1964 # delete associated tags
1965 Image::ExifTool::Geotag::SetGeoValues($self, undef, $wantGroup);
1966 },
1967 ValueConvInv => q{
1968 require Image::ExifTool::Geotag;
1969 warn Image::ExifTool::Geotag::SetGeoValues($self, $val, $wantGroup) . "\n";
1970 return undef;
1971 },
1972 },
1973 Geosync => {
1974 Writable => 1,
1975 WriteOnly => 1,
1976 WriteNothing => 1,
1977 AllowGroup => '(exif|gps|xmp|xmp-exif)',
1978 Shift => 'Time', # enables "+=" syntax as well as "=+"
1979 Notes => q{
1980 this write-only tag specifies a time difference to add to Geotime for
1981 synchronization with the GPS clock. For example, set this to "-12" if the
1982 camera clock is 12 seconds faster than GPS time. Input format is
1983 "[+-][[[DD ]HH:]MM:]SS[.ss]". Additional features allow calculation of time
1984 differences and time drifts, and extraction of synchronization times from
1985 image files. See the L<geotagging documentation|../geotag.html> for details
1986 },
1987 ValueConvInv => q{
1988 require Image::ExifTool::Geotag;
1989 return Image::ExifTool::Geotag::ConvertGeosync($self, $val);
1990 },
1991 },
1992 ForceWrite => {
1993 Groups => { 0 => '*', 1 => '*', 2 => '*' },
1994 Writable => 1,
1995 WriteOnly => 1,
1996 Notes => q{
1997 write-only tag used to force metadata in a file to be rewritten even if no
1998 tag values are changed. May be set to "EXIF", "IPTC", "XMP" or "PNG" to
1999 force the corresponding metadata type to be rewritten, "FixBase" to cause
2000 EXIF to be rewritten only if the MakerNotes offset base was fixed, or "All"
2001 to rewrite all of these metadata types. Values are case insensitive, and
2002 multiple values may be separated with commas, eg. C<-ForceWrite=exif,xmp>
2003 },
2004 },
2005 EmbeddedVideo => { Groups => { 0 => 'Trailer', 2 => 'Video' } },
2006 Trailer => {
2007 Groups => { 0 => 'Trailer' },
2008 Notes => q{
2009 the full JPEG trailer data block. Extracted only if specifically requested
2010 or the API L<RequestAll|../ExifTool.html#RequestAll> option is set to 3 or higher
2011 },
2012 Writable => 1,
2013 Protected => 1,
2014 },
2015 PageCount => { Notes => 'the number of pages in a multi-page TIFF document' },
2016 SphericalVideoXML => {
2017 Groups => { 0 => 'QuickTime', 1 => 'GSpherical', 2 => 'Video' },
2018 # (group 1 is 'GSpherical' to trigger creation of this tag when writing,
2019 # but when reading the family 1 group is the track number)
2020 Flags => [ 'Writable', 'Binary', 'Protected' ],
2021 Notes => q{
2022 the SphericalVideoXML block from MP4/MOV videos. This tag is generated only
2023 if specifically requested
2024 },
2025 },
2026 ImageDataHash => {
2027 Notes => q{
2028 Hash of image data. Generated only if specifically requested for JPEG, TIFF,
2029 PNG, CRW, CR3, MRW, RAF, X3F, IIQ, JP2, JXL, HEIC and AVIF images, MOV/MP4
2030 videos, and some RIFF-based files such as AVI, WAV and WEBP. The hash
2031 algorithm is set by the API L<ImageHashType|../ExifTool.html#ImageHashType> option, and is 'MD5' by default.
2032 The hash includes the main image data, plus JpgFromRaw/OtherImage for some
2033 formats, but does not include ThumbnailImage or PreviewImage. Includes
2034 video and audio data for MOV/MP4. The L<XMP-et:OriginalImageHash and
2035 XMP-et:OriginalImageHashType tags|XMP.html#ExifTool> provide a way to store
2036 the this hash value and the hash type in the file.
2037 },
2038 },
2039 Geolocate => {
2040 Writable => 1,
2041 WriteOnly => 1,
2042 WriteNothing => 1,
2043 AllowGroup => '(exif|gps|xmp|xmp-exif|xmp-iptcext|xmp-iptccore|xmp-photoshop|iptc|quicktime|itemlist|keys|userdata)',
2044 Notes => q{
2045 this write-only tag may be used to write geolocation city, region, country
2046 code and country based in input GPS coordinates, or to write GPS
2047 coordinates based on geolocation name. See the
2048 L<Writing section of the Geolocation page|../geolocation.html#Write> for
2049 details. This tag is writable regardless of the API L<Geolocation|../ExifTool.html#Geolocation>
2050 option setting
2051 },
2052 DelCheck => q{
2053 my @tags = $self->GetGeolocateTags($wantGroup);
2054 $self->SetNewValue($_) foreach @tags;
2055 return '';
2056 },
2057 ValueConvInv => q{
2058 require Image::ExifTool::Geolocation;
2059 # write this tag later if geotagging
2060 return $val if $val =~ /\bgeotag\b/i;
2061 $val .= ',both';
2062 my $opts = $$self{OPTIONS};
2063 my ($cities, $dist) = Image::ExifTool::Geolocation::Geolocate($self->Encode($val,'UTF8'), $opts);
2064 return '' unless $cities;
2065 if (@$cities > 1 and $self->Warn('Multiple matching cities found',2)) {
2066 warn "$$self{VALUE}{Warning}\n";
2067 return '';
2068 }
2069 my @geo = Image::ExifTool::Geolocation::GetEntry($$cities[0], $$opts{Lang});
2070 my @tags = $self->GetGeolocateTags($wantGroup, $dist ? 0 : 1);
2071 my %geoNum = ( City => 0, Province => 1, State => 1, Code => 3, Country => 4,
2072 Coordinates => 89, Latitude => 8, Longitude => 9 );
2073 my ($tag, $value);
2074 foreach $tag (@tags) {
2075 if ($tag =~ /GPS(Coordinates|Latitude|Longitude)?/) {
2076 $value = $geoNum{$1} == 89 ? "$geo[8],$geo[9]" : $geo[$geoNum{$1}];
2077 } elsif ($tag =~ /(Code)/ or $tag =~ /(City|Province|State|Country)/) {
2078 $value = $geo[$geoNum{$1}];
2079 next unless defined $value;
2080 $value = $self->Decode($value,'UTF8');
2081 $value .= ' ' if $tag eq 'iptc:Country-PrimaryLocationCode'; # (IPTC requires 3-char code)
2082 } elsif ($tag =~ /LocationName/) {
2083 $value = $geo[0] or next;
2084 $value .= ', ' . $geo[1] if $geo[1];
2085 $value .= ', ' . $geo[4] if $geo[4];
2086 $value = $self->Decode($value, 'UTF8');
2087 } else {
2088 next; # (shouldn't happen)
2089 }
2090 $self->SetNewValue($tag => $value, Type => 'PrintConv');
2091 }
2092 return '';
2093 },
2094 PrintConvInv => q{
2095 my @args = split /\s*,\s*/, $val;
2096 my $lat = 1;
2097 foreach (@args) {
2098 next unless /^[-+]?\d/;
2099 my @reals = /\.\d+/g;
2100 next if @reals > 1; # (allow floating "lat lon" format)
2101 require Image::ExifTool::GPS;
2102 $_ = Image::ExifTool::GPS::ToDegrees($_, 1, $lat ? 'lat' : 'lon');
2103 $lat ^= 1;
2104 }
2105 return join(',', @args);
2106 },
2107 },
2108 GeolocationBearing => { %geoInfo,
2109 Notes => q{
2110 compass bearing to GeolocationCity center. Geolocation tags are
2111 generated only if API L<Geolocation|../ExifTool.html#Geolocation> option is set
2112 },
2113 },
2114 GeolocationCity => { %geoInfo, Notes => 'name of city nearest to the current GPS coordinates', ValueConv => '$self->Decode($val,"UTF8")' },
2115 GeolocationRegion => { %geoInfo, Notes => 'geolocation state, province or region', ValueConv => '$self->Decode($val,"UTF8")' },
2116 GeolocationSubregion=> { %geoInfo, Notes => 'geolocation county or subregion', ValueConv => '$self->Decode($val,"UTF8")' },
2117 GeolocationCountry => { %geoInfo, Notes => 'geolocation country name', ValueConv => '$self->Decode($val,"UTF8")' },
2118 GeolocationCountryCode=>{%geoInfo, Notes => 'geolocation country code' },
2119 GeolocationTimeZone => { %geoInfo, Notes => 'geolocation time zone ID' },
2120 GeolocationFeatureCode=>{%geoInfo, Notes => 'geolocation feature code, see L<http://www.geonames.org/export/codes.html#P>' },
2121 GeolocationFeatureType=>{%geoInfo, Notes => 'geolocation feature type' },
2122 GeolocationPopulation=>{ %geoInfo, Notes => 'city population rounded to 2 significant digits' },
2123 GeolocationDistance => { %geoInfo, Notes => 'distance in km from current GPS to city', PrintConv => '"$val km"' },
2124 GeolocationPosition => { %geoInfo, Notes => 'approximate GPS coordinates of city',
2125 PrintConv => '$val =~ s/ /, /; $val',
2126 },
2127 GeolocationWarning => { %geoInfo },
2128 );
2129  
2130 # tags defined by UserParam option (added at runtime)
2131 113 %Image::ExifTool::UserParam = (
2132 GROUPS => { 0 => 'UserParam', 1 => 'UserParam', 2 => 'Other' },
2133 PRIORITY => 0,
2134 );
2135  
2136 # YCbCrSubSampling values (used by JPEG SOF, EXIF and XMP)
2137 113 %Image::ExifTool::JPEG::yCbCrSubSampling = (
2138 '1 1' => 'YCbCr4:4:4 (1 1)', #PH
2139 '2 1' => 'YCbCr4:2:2 (2 1)', #14 in Exif.pm
2140 '2 2' => 'YCbCr4:2:0 (2 2)', #14 in Exif.pm
2141 '4 1' => 'YCbCr4:1:1 (4 1)', #14 in Exif.pm
2142 '4 2' => 'YCbCr4:1:0 (4 2)', #PH
2143 '1 2' => 'YCbCr4:4:0 (1 2)', #PH
2144 '1 4' => 'YCbCr4:4:1 (1 4)', #JD
2145 '2 4' => 'YCbCr4:2:1 (2 4)', #JD
2146 );
2147  
2148 # define common JPEG segments here to avoid overhead of loading JPEG module
2149  
2150 # JPEG SOF (start of frame) tags
2151 # (ref http://www.w3.org/Graphics/JPEG/itu-t81.pdf)
2152 113 %Image::ExifTool::JPEG::SOF = (
2153 GROUPS => { 0 => 'File', 1 => 'File', 2 => 'Image' },
2154 NOTES => 'This information is extracted from the JPEG Start Of Frame segment.',
2155 VARS => { ID_FMT => 'none' }, # tag ID's aren't meaningful for these tags
2156 EncodingProcess => {
2157 PrintHex => 1,
2158 PrintConv => {
2159 0x0 => 'Baseline DCT, Huffman coding',
2160 0x1 => 'Extended sequential DCT, Huffman coding',
2161 0x2 => 'Progressive DCT, Huffman coding',
2162 0x3 => 'Lossless, Huffman coding',
2163 0x5 => 'Sequential DCT, differential Huffman coding',
2164 0x6 => 'Progressive DCT, differential Huffman coding',
2165 0x7 => 'Lossless, Differential Huffman coding',
2166 0x9 => 'Extended sequential DCT, arithmetic coding',
2167 0xa => 'Progressive DCT, arithmetic coding',
2168 0xb => 'Lossless, arithmetic coding',
2169 0xd => 'Sequential DCT, differential arithmetic coding',
2170 0xe => 'Progressive DCT, differential arithmetic coding',
2171 0xf => 'Lossless, differential arithmetic coding',
2172 }
2173 },
2174 BitsPerSample => { },
2175 ImageHeight => { },
2176 ImageWidth => { },
2177 ColorComponents => { },
2178 YCbCrSubSampling => {
2179 Notes => 'calculated from components table',
2180 PrintConv => \%Image::ExifTool::JPEG::yCbCrSubSampling,
2181 },
2182 );
2183  
2184 # JPEG JFIF APP0 definitions
2185 %Image::ExifTool::JFIF::Main = (
2186 PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
2187 WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
2188 CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
2189 GROUPS => { 0 => 'JFIF', 1 => 'JFIF', 2 => 'Image' },
2190 DATAMEMBER => [ 2, 3, 5 ],
2191 0 => {
2192 Name => 'JFIFVersion',
2193 Format => 'int8u[2]',
2194 PrintConv => 'sprintf("%d.%.2d", split(" ",$val))',
2195 Mandatory => 1,
2196 },
2197 2 => {
2198 Name => 'ResolutionUnit',
2199 Writable => 1,
2200 RawConv => '$$self{JFIFResolutionUnit} = $val',
2201 PrintConv => {
2202 0 => 'None',
2203 1 => 'inches',
2204 2 => 'cm',
2205 },
2206 Priority => -1,
2207 Mandatory => 1,
2208 },
2209 3 => {
2210 Name => 'XResolution',
2211 Format => 'int16u',
2212 Writable => 1,
2213 Priority => -1,
2214 RawConv => '$$self{JFIFXResolution} = $val',
2215 Mandatory => 1,
2216 },
2217 5 => {
2218 Name => 'YResolution',
2219 Format => 'int16u',
2220 Writable => 1,
2221 Priority => -1,
2222 RawConv => '$$self{JFIFYResolution} = $val',
2223 Mandatory => 1,
2224 },
2225 7 => {
2226 Name => 'ThumbnailWidth',
2227 RawConv => '$val ? $$self{JFIFThumbnailWidth} = $val : undef',
2228 },
2229 8 => {
2230 Name => 'ThumbnailHeight',
2231 RawConv => '$val ? $$self{JFIFThumbnailHeight} = $val : undef',
2232 },
2233 9 => {
2234 Name => 'ThumbnailTIFF',
2235 Groups => { 2 => 'Preview' },
2236 Format => 'undef[3*($val{7}||0)*($val{8}||0)]',
2237 Notes => 'raw RGB thumbnail data, extracted as a TIFF image',
2238 RawConv => 'length($val) ? $val : undef',
2239 0 ▶ ValueConv => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
2240 0 my ($val, $et) = @_;
2241 0 my $len = length $val;
2242 0 ▶ return \ "Binary data $len bytes" unless $et->Options('Binary');
Branch: 1 branch
BranchTrueFalseTotal
unless $et->Options("Binary") 0 0 0
2243 0 my $img = MakeTiffHeader($$et{JFIFThumbnailWidth},$$et{JFIFThumbnailHeight},3,8) . $val;
2244 0 return \$img;
2245 },
2246 },
2247 113 );
2248 %Image::ExifTool::JFIF::Extension = (
2249 GROUPS => { 0 => 'JFIF', 1 => 'JFXX', 2 => 'Image' },
2250 NOTES => 'Thumbnail images extracted from the JFXX segment.',
2251 0x10 => {
2252 Name => 'ThumbnailImage',
2253 Groups => { 2 => 'Preview' },
2254 Notes => 'JPEG-format thumbnail image',
2255 RawConv => '$self->ValidateImage(\$val,$tag)',
2256 },
2257 0x11 => { # (untested)
2258 Name => 'ThumbnailTIFF',
2259 Groups => { 2 => 'Preview' },
2260 Notes => 'raw palette-color thumbnail data, extracted as a TIFF image',
2261 RawConv => '(length $val > 770 and $val !~ /^\0\0/) ? $val : undef',
2262 0 ▶ ValueConv => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
2263 0 my ($val, $et) = @_;
2264 0 my $len = length $val;
2265 0 ▶ return \ "Binary data $len bytes" unless $et->Options('Binary');
Branch: 1 branch
BranchTrueFalseTotal
unless $et->Options("Binary") 0 0 0
2266 0 my ($w, $h) = unpack('CC', $val);
2267 0 my $img = MakeTiffHeader($w,$h,1,8,undef,substr($val,2,768)) . substr($val,770);
2268 0 return \$img;
2269 },
2270 },
2271 0x13 => {
2272 Name => 'ThumbnailTIFF',
2273 Groups => { 2 => 'Preview' },
2274 Notes => 'raw RGB thumbnail data, extracted as a TIFF image',
2275 RawConv => '(length $val > 2 and $val !~ /^\0\0/) ? $val : undef',
2276 0 ▶ ValueConv => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
2277 0 my ($val, $et) = @_;
2278 0 my $len = length $val;
2279 0 ▶ return \ "Binary data $len bytes" unless $et->Options('Binary');
Branch: 1 branch
BranchTrueFalseTotal
unless $et->Options("Binary") 0 0 0
2280 0 my ($w, $h) = unpack('CC', $val);
2281 0 my $img = MakeTiffHeader($w,$h,3,8) . substr($val,2);
2282 0 return \$img;
2283 },
2284 },
2285 # Apple may add "AMPF" to the end of the JFIF record,
2286 # possibly indicating the existence of MPF images (ref forum12677)
2287 113 );
2288  
2289 # Composite tags (accumulation of all Composite tag tables)
2290 113 %Image::ExifTool::Composite = (
2291 GROUPS => { 0 => 'Composite', 1 => 'Composite' },
2292 TABLE_NAME => 'Image::ExifTool::Composite',
2293 SHORT_NAME => 'Composite',
2294 VARS => { ID_FMT => 'none' }, # want empty tagID's for Composite tags
2295 WRITE_PROC => \&DummyWriteProc,
2296 );
2297  
2298 113 my %compositeID; # lookup for new ID's of Composite tags based on original ID
2299  
2300 # static private ExifTool variables
2301  
2302 113 %allTables = ( ); # list of all tables loaded (except Composite tags)
2303 113 @tableOrder = ( ); # order the tables were loaded
2304  
2305 #------------------------------------------------------------------------------
2306 # Warning handler routines (warning string stored in $evalWarning)
2307 #
2308 # Set warning message
2309 # Inputs: 0) warning string (undef to reset warning)
2310 41 ▶sub SetWarning($) { $evalWarning = $_[0]; }
Subroutine SetWarning: called CC=1 SCAR=0.0
Pod undocumented
2311  
2312 # Get warning message
2313 17 ▶sub GetWarning() { return $evalWarning; }
Subroutine GetWarning: called CC=1 SCAR=0.0
Pod undocumented
2314  
2315 # Clean unnecessary information (line number, LF) from warning
2316 # Inputs: 0) warning string or undef to use $evalWarning
2317 # Returns: cleaned warning
2318 sub CleanWarning(;$)
2319 226 ▶{
Subroutine CleanWarning: called CC=4 SCAR=14.0
Pod undocumented
2320 226 my $str = shift;
2321 226 ▶ unless (defined $str) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $str) 226 0 226
2322 226 ▶ return undef unless defined $evalWarning;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $Image::ExifTool::evalWarning 0 226 226
2323 226 $str = $evalWarning;
2324 }
2325 # truncate at first " at " for warnings like "syntax error at (eval 80) line 1, at EOF"
2326 226 ▶ $str = $1 if $str =~ /(.*?) at /s;
Branch: 1 branch
BranchTrueFalseTotal
if $str =~ /(.*?) at /s 206 20 226
2327 226 $str =~ s/\s+$//s;
2328 226 return $str;
2329 }
2330  
2331 #==============================================================================
2332 # New - create new ExifTool object
2333 # Inputs: 0) reference to exiftool object or ExifTool class name
2334 # Returns: blessed ExifTool object ref
2335 sub new
2336 508 ▶{
Subroutine new: called CC=3 SCAR=11.1
Pod documented
2337 508 local $_;
2338 508 my $that = shift;
2339 508 ▶ my $class = ref($that) || $that || 'Image::ExifTool';
Condition40%2/5
ref $that || $that || 'Image::ExifTool'
l!l
5080
ref $that or $that
l!l&&r!l&&!r
05080
MC/DC0%0/2
ref $that || $that || 'Image::ExifTool'
ref $that $that
Truth table33%1/3
A or B
A= ref $thatB= $that
ABresult
1X1
011
000
2340 508 my $self = bless {}, $class;
2341  
2342 # make sure our main Exif tag table has been loaded
2343 508 GetTagTable("Image::ExifTool::Exif::Main");
2344  
2345 508 $self->ClearOptions(); # create default options hash
2346 508 $$self{VALUE} = { }; # must initialize this for warning messages
2347 508 $$self{PATH} = [ ]; # (this too)
2348 508 $$self{DEL_GROUP} = { }; # lookup for groups to delete when writing
2349 508 $$self{SAVE_COUNT} = 0; # count calls to SaveNewValues()
2350 508 $$self{NV_COUNT} = 0; # count of NEW_VALUE entries
2351 508 $$self{FILE_SEQUENCE} = 0; # sequence number for files when reading
2352 508 $$self{FILES_WRITTEN} = 0; # count of files successfully written
2353 508 $$self{INDENT2} = ''; # indentation of verbose messages from SetNewValue
2354 508 $$self{ALT_EXIFTOOL} = { }; # alternate exiftool objects
2355  
2356 # initialize our new groups for writing
2357 508 $self->SetNewGroups(@defaultWriteGroups);
2358  
2359 508 return $self;
2360 }
2361  
2362 #------------------------------------------------------------------------------
2363 # ImageInfo - return specified information from image file
2364 # Inputs: 0) [optional] ExifTool object reference
2365 # 1) filename, file reference, or scalar data reference
2366 # 2-N) list of tag names to find (or tag list reference or options reference)
2367 # Returns: reference to hash of tag/value pairs (with "Error" entry on error)
2368 # Notes:
2369 # - if no tags names are specified, the values of all tags are returned
2370 # - tags may be specified with leading '-' to exclude, or trailing '#' for ValueConv
2371 # - can pass a reference to list of tags to find, in which case the list will
2372 # be updated with the tags found in the proper case and in the specified order.
2373 # - can pass reference to hash specifying options
2374 # - returned tag values may be scalar references indicating binary data
2375 # - see ClearOptions() below for a list of options and their default values
2376 # Examples:
2377 # use Image::ExifTool 'ImageInfo';
2378 # my $info = ImageInfo($file, 'DateTimeOriginal', 'ImageSize');
2379 # - or -
2380 # my $et = Image::ExifTool->new;
2381 # my $info = $et->ImageInfo($file, \@tagList, {Sort=>'Group0'} );
2382 sub ImageInfo($;@)
2383 539 ▶{
Subroutine ImageInfo: called CC=3 SCAR=11.0
Pod documented
2384 539 local $_;
2385 # get our ExifTool object ($self) or create one if necessary
2386 539 my $self;
2387 539 ▶ if (ref $_[0] and UNIVERSAL::isa($_[0],'Image::ExifTool')) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] and UNIVERSAL::isa($_[0], 'Image::ExifTool')) { } 530 9 539
Condition100%3/3
ref $_[0] and UNIVERSAL::isa($_[0], "Image::ExifTool")
!ll&&!rl&&r
54530
MC/DC100%2/2
ref $_[0] and UNIVERSAL::isa($_[0], "Image::ExifTool")
ref $_[0] UNIVERSAL::isa($_[0], "Image::ExifTool")
Truth table100%3/3
A and B
A= ref $_[0]B= UNIVERSAL::isa($_[0], "Image::ExifTool")
ABresult
0X0
100
111
2388 530 $self = shift;
2389 } else {
2390 9 $self = Image::ExifTool->new;
2391 }
2392 539 my %saveOptions = %{$$self{OPTIONS}}; # save original options
2393  
2394 # initialize file information
2395 539 $$self{FILENAME} = $$self{RAF} = undef;
2396  
2397 539 $self->ParseArguments(@_); # parse our function arguments
2398 539 $self->ExtractInfo(undef); # extract meta information from image
2399 539 my $info = $self->GetInfo(undef); # get requested information
2400  
2401 539 $$self{OPTIONS} = \%saveOptions; # restore original options
2402  
2403 539 return $info; # return requested information
2404 }
2405  
2406 #------------------------------------------------------------------------------
2407 # Get/set ExifTool options
2408 # Inputs: 0) ExifTool object reference,
2409 # 1) Parameter name (case insensitive), 2) Value to set the option
2410 # 3-N) More parameter/value pairs
2411 # Returns: original value of last option specified
2412 sub Options($$;@)
2413 23371 ▶{
Subroutine Options: called CC=105 SCAR=67.9
Pod documented
2414 23371 local $_;
2415 23371 my $self = shift;
2416 23371 my $options = $$self{OPTIONS};
2417 23371 my $oldVal;
2418  
2419 23371 ▶ while (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 23884 5624 29508
2420 23884 my $param = shift;
2421 23884 my $plus;
2422 # fix parameter case if necessary
2423 23884 ▶ unless (exists $$options{$param}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $options->{$param}) 535 23349 23884
2424 535 $plus = $param =~ s/\+$//;
2425 535 my ($fixed) = grep /^$param$/i, keys %$options;
2426 535 ▶ if ($fixed) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fixed) { } 0 535 535
2427 0 $param = $fixed;
2428 } else {
2429 535 $param =~ s/^Group(\d*)$/Group$1/i;
2430 }
2431 }
2432 23884 $oldVal = $$options{$param};
2433 23884 ▶ if (ref $oldVal eq 'HASH' and ($param eq 'Compact' or $param eq 'XMPShorthand')) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $oldVal eq "HASH" and $param eq "Compact" || $param eq "XMPShorthand") 0 23884 23884
Condition50%3/6
ref $oldVal eq "HASH" and $param eq "Compact" || $param eq "XMPShorthand"
!ll&&!rl&&r
23825590
$param eq "Compact" or $param eq "XMPShorthand"
l!l&&r!l&&!r
0059
MC/DC0%0/3
ref $oldVal eq "HASH" and $param eq "Compact" || $param eq "XMPShorthand"
ref $oldVal eq "HASH" $param eq "Compact" $param eq "XMPShorthand"
Truth table50%2/4
A and B or C
A= ref $oldVal eq "HASH"B= $param eq "Compact"C= $param eq "XMPShorthand"
ABCresult
0XX0
1000
11X1
1011
2434 # get previous Compact/XMPShorthand setting
2435 0 $oldVal = $$oldVal{$param};
2436 }
2437 23884 ▶ last unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 17747 6137 23884
2438 6137 my $newVal = shift;
2439 6137 ▶ if ($param eq 'Lang') {
Branch: 16 branches
BranchTrueFalseTotal
if ($param eq 'Lang') { } 78 6059 6137
elsif ($param eq 'Exclude' and defined $newVal) { } 8 6051 6059
elsif ($param =~ /^Charset/ or $param eq 'IPTCCharset') { } 364 5687 6051
elsif ($param eq 'UserParam') { } 59 5628 5687
elsif ($param eq 'RequestTags') { } 102 5526 5628
elsif ($param =~ /^(IgnoreTags|IgnoreGroups)$/) { } 118 5408 5526
elsif ($param eq 'ListJoin') { } 12 5396 5408
elsif ($param eq 'List') { } 78 5318 5396
elsif ($param eq 'Compact' or $param eq 'XMPShorthand') { } 1 5317 5318
elsif ($param eq 'NoWarning') { } 59 5258 5317
elsif ($param eq 'ImageHashType') { } 59 5199 5258
elsif ($param eq 'StructFormat') { } 59 5140 5199
elsif ($param eq 'ByteUnit') { } 59 5081 5140
elsif ($param eq 'Plot') { } 0 5081 5081
elsif ($param eq 'KeepUTCTime' or $param eq 'SystemTimeRes') { } 118 4963 5081
elsif (lc $param eq 'geodir') { } 0 4963 4963
2440 # allow this to be set to undef to select the default language
2441 78 ▶ $newVal = $defaultLang unless defined $newVal;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $newVal 0 78 78
2442 78 ▶ if ($newVal eq $defaultLang) {
Branch: 1 branch
BranchTrueFalseTotal
if ($newVal eq $Image::ExifTool::defaultLang) { } 59 19 78
2443 59 $$options{$param} = $newVal;
2444 59 delete $$self{CUR_LANG};
2445 # make sure the language is available
2446 } else {
2447 19 my %langs = map { $_ => 1 } @langs;
2448 19 ▶ if ($langs{$newVal} and eval "require Image::ExifTool::Lang::$newVal") {
Branch: 1 branch
BranchTrueFalseTotal
if ($langs{$newVal} and eval "require Image::ExifTool::Lang::$newVal") 19 0 19
Condition33%1/3
$langs{$newVal} and eval "require Image::ExifTool::Lang::$newVal"
!ll&&!rl&&r
0019
MC/DC0%0/2
$langs{$newVal} and eval "require Image::ExifTool::Lang::$newVal"
$langs{$newVal} eval "require Image::ExifTool::Lang::$newVal"
Truth table33%1/3
A and B
A= $langs{$newVal}B= eval "require Image::ExifTool::Lang::$newVal"
ABresult
0X0
100
111
2449 19 my $xlat = "Image::ExifTool::Lang::${newVal}::Translate";
2450 113 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
2451 19 ▶ if (%$xlat) {
Branch: 1 branch
BranchTrueFalseTotal
if (%$xlat) 19 0 19
2452 19 $$self{CUR_LANG} = \%$xlat;
2453 19 $$options{$param} = $newVal;
2454 }
2455 }
2456 } # else don't change Lang
2457 ▶ } elsif ($param eq 'Exclude' and defined $newVal) {
Condition66%2/3
$param eq "Exclude" and defined $newVal
!ll&&!rl&&r
605108
MC/DC50%1/2
$param eq "Exclude" and defined $newVal
$param eq "Exclude" defined $newVal
Truth table66%2/3
A and B
A= $param eq "Exclude"B= defined $newVal
ABresult
0X0
100
111
2458 # clone Exclude list and expand shortcuts
2459 8 my @exclude;
2460 8 ▶ if (ref $newVal eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $newVal eq 'ARRAY') { } 7 1 8
2461 7 @exclude = @$newVal;
2462 } else {
2463 1 @exclude = ($newVal);
2464 }
2465 8 ExpandShortcuts(\@exclude, 1); # (also remove '#' suffix)
2466 8 $$options{$param} = \@exclude;
2467 ▶ } elsif ($param =~ /^Charset/ or $param eq 'IPTCCharset') {
Condition100%3/3
$param =~ /^Charset/ or $param eq "IPTCCharset"
l!l&&r!l&&!r
36315687
MC/DC100%2/2
$param =~ /^Charset/ or $param eq "IPTCCharset"
$param =~ /^Charset/ $param eq "IPTCCharset"
Truth table100%3/3
A or B
A= $param =~ /^Charset/B= $param eq "IPTCCharset"
ABresult
1X1
011
000
2468 # only allow valid character sets to be set
2469 364 ▶ if ($newVal) {
Branch: 3 branches
BranchTrueFalseTotal
if ($newVal) { } 245 119 364
elsif ($param eq 'CharsetEXIF' or $param eq 'CharsetFileName' or $param eq 'CharsetRIFF') { } 119 0 119
elsif ($param eq 'CharsetQuickTime') { } 0 0 0
2470 245 my $charset = $charsetName{lc $newVal};
2471 245 ▶ if ($charset) {
Branch: 1 branch
BranchTrueFalseTotal
if ($charset) { } 245 0 245
2472 245 $$options{$param} = $charset;
2473 # maintain backward-compatibility with old IPTCCharset option
2474 245 ▶ $$options{CharsetIPTC} = $charset if $param eq 'IPTCCharset';
Branch: 1 branch
BranchTrueFalseTotal
if $param eq "IPTCCharset" 1 244 245
2475 } else {
2476 0 warn "Invalid Charset $newVal\n";
2477 }
2478 ▶ } elsif ($param eq 'CharsetEXIF' or $param eq 'CharsetFileName' or $param eq 'CharsetRIFF') {
Condition50%3/6
$param eq "CharsetEXIF" or $param eq "CharsetFileName" or $param eq "CharsetRIFF"
l!l&&r!l&&!r
11900
$param eq "CharsetEXIF" or $param eq "CharsetFileName"
l!l&&r!l&&!r
60590
MC/DC0%0/3
$param eq "CharsetEXIF" or $param eq "CharsetFileName" or $param eq "CharsetRIFF"
$param eq "CharsetEXIF" $param eq "CharsetFileName" $param eq "CharsetRIFF"
Truth table50%2/4
A or B or C
A= $param eq "CharsetEXIF"B= $param eq "CharsetFileName"C= $param eq "CharsetRIFF"
ABCresult
1XX1
01X1
0011
0000
2479 119 $$options{$param} = $newVal; # only these may be set to a false value
2480 } elsif ($param eq 'CharsetQuickTime') {
2481 0 $$options{$param} = 'MacRoman'; # QuickTime defaults to MacRoman
2482 } else {
2483 0 $$options{$param} = 'Latin'; # all others default to Latin
2484 }
2485 } elsif ($param eq 'UserParam') {
2486 # clear options if $newVal is undef
2487 59 ▶ defined $newVal or $$options{$param} = {}, next;
Branch: 1 branch
BranchTrueFalseTotal
defined $newVal or $options->{$param} = {}, next 59 0 59
2488 59 my $table = GetTagTable('Image::ExifTool::UserParam');
2489 # allow initialization of entire UserParam hash
2490 59 ▶ if (ref $newVal eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $newVal eq "HASH") 59 0 59
2491 59 my %newParams;
2492 59 foreach (sort keys %$newVal) {
2493 0 my $lcTag = lc $_;
2494 0 $newParams{$lcTag} = $$newVal{$_};
2495 0 delete $$table{$lcTag};
2496 0 AddTagToTable($table, $lcTag, $_);
2497 }
2498 59 $$options{$param} = \%newParams;
2499 59 next;
2500 }
2501 0 my ($force, $paramName);
2502 # set/reset single UserParam parameter
2503 0 ▶ if ($newVal =~ /(.*?)=(.*)/s) {
Branch: 1 branch
BranchTrueFalseTotal
if ($newVal =~ /(.*?)=(.*)/s) { } 0 0 0
2504 0 $paramName = $1;
2505 0 $newVal = $2;
2506 0 ▶ $force = 1 if $paramName =~ s/\^$//;
Branch: 1 branch
BranchTrueFalseTotal
if $paramName =~ s/\^$// 0 0 0
2507 0 $paramName =~ tr/-_a-zA-Z0-9#//dc;
2508 0 $param = lc $paramName;
2509 } else {
2510 0 ($param = lc $newVal) =~ tr/-_a-zA-Z0-9#//dc;
2511 0 undef $newVal;
2512 }
2513 0 delete $$table{$param};
2514 0 $oldVal = $$options{UserParam}{$param};
2515 0 ▶ if (defined $newVal) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $newVal) 0 0 0
2516 0 ▶ if (length $newVal or $force) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $newVal or $force) { } 0 0 0
Condition0%0/3
length $newVal or $force
l!l&&r!l&&!r
000
MC/DC0%0/2
length $newVal or $force
length $newVal $force
Truth table0%0/3
A or B
A= length $newValB= $force
ABresult
1X1
011
000
2517 0 $$options{UserParam}{$param} = $newVal;
2518 0 AddTagToTable($table, $param, $paramName);
2519 } else {
2520 0 delete $$options{UserParam}{$param};
2521 }
2522 }
2523 # remove alternate version of tag
2524 0 ▶ $param .= '#' unless $param =~ s/#$//;
Branch: 1 branch
BranchTrueFalseTotal
unless $param =~ s/#$// 0 0 0
2525 0 delete $$table{$param};
2526 0 delete $$options{UserParam}{$param};
2527 } elsif ($param eq 'RequestTags') {
2528 102 ▶ if (defined $newVal) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $newVal) { } 43 59 102
2529 # parse list from delimited string if necessary
2530 43 ▶ my @reqList = (ref $newVal eq 'ARRAY') ? @$newVal : ($newVal =~ /[-\w?*:]+/g);
Branch: 1 branch
BranchTrueFalseTotal
ref $newVal eq 'ARRAY' ? : 43 0 43
2531 43 ExpandShortcuts(\@reqList);
2532 # add to existing list
2533 43 ▶ $$options{$param} or $$options{$param} = [ ];
Branch: 1 branch
BranchTrueFalseTotal
$options->{$param} or $options->{$param} = [] 0 43 43
2534 43 foreach (@reqList) {
2535 65 ▶ /^(.*:)?([-\w?*]*)#?$/ or next;
Branch: 1 branch
BranchTrueFalseTotal
/^(.*:)?([-\w?*]*)#?$/ or next 65 0 65
2536 65 ▶ push @{$$options{$param}}, lc($2) if $2;
Branch: 1 branch
BranchTrueFalseTotal
if $2 65 0 65
2537 65 ▶ next unless $1;
Branch: 1 branch
BranchTrueFalseTotal
unless $1 65 0 65
2538 # add requested groups with trailing colon
2539 0 push @{$$options{$param}}, lc($_).':' foreach split /:/, $1;
2540 }
2541 } else {
2542 59 $$options{$param} = undef; # clear the list
2543 }
2544 } elsif ($param =~ /^(IgnoreTags|IgnoreGroups)$/) {
2545 118 ▶ if (defined $newVal) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $newVal) { } 0 118 118
2546 0 ▶ ref $newVal eq 'HASH' and $$options{$param} = $newVal, next;
Branch: 1 branch
BranchTrueFalseTotal
ref $newVal eq "HASH" and $options->{$param} = $newVal, next 0 0 0
2547 # parse list from delimited string if necessary
2548 0 ▶ my @ignoreList = (ref $newVal eq 'ARRAY') ? @$newVal : ($newVal =~ /[-\w?*:#]+/g);
Branch: 1 branch
BranchTrueFalseTotal
ref $newVal eq 'ARRAY' ? : 0 0 0
2549 0 ▶ ExpandShortcuts(\@ignoreList) if $param eq 'IgnoreTags';
Branch: 1 branch
BranchTrueFalseTotal
if $param eq "IgnoreTags" 0 0 0
2550 # add to existing tags/groups to ignore
2551 0 ▶ $$options{$param} or $$options{$param} = { };
Branch: 1 branch
BranchTrueFalseTotal
$options->{$param} or $options->{$param} = {} 0 0 0
2552 0 foreach (@ignoreList) {
2553 0 ▶ /^(.*:)?([-\w?*]+)#?$/ or next;
Branch: 1 branch
BranchTrueFalseTotal
/^(.*:)?([-\w?*]+)#?$/ or next 0 0 0
2554 0 $$options{$param}{lc $2} = 1;
2555 }
2556 } else {
2557 118 $$options{$param} = undef; # clear the option
2558 }
2559 } elsif ($param eq 'ListJoin') {
2560 12 $$options{$param} = $newVal;
2561 # set the old List and ListSep options for backward compatibility
2562 12 ▶ if (defined $newVal) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $newVal) { } 4 8 12
2563 4 $$options{List} = 0;
2564 4 $$options{ListSep} = $newVal;
2565 } else {
2566 8 $$options{List} = 1;
2567 # (ListSep must be defined)
2568 }
2569 } elsif ($param eq 'List') {
2570 78 $$options{$param} = $newVal;
2571 # set the new ListJoin option for forward compatibility
2572 78 ▶ $$options{ListJoin} = $newVal ? undef : $$options{ListSep};
Branch: 1 branch
BranchTrueFalseTotal
$newVal ? : 78 0 78
2573 ▶ } elsif ($param eq 'Compact' or $param eq 'XMPShorthand') {
Condition66%2/3
$param eq "Compact" or $param eq "XMPShorthand"
l!l&&r!l&&!r
015317
MC/DC50%1/2
$param eq "Compact" or $param eq "XMPShorthand"
$param eq "Compact" $param eq "XMPShorthand"
Truth table66%2/3
A or B
A= $param eq "Compact"B= $param eq "XMPShorthand"
ABresult
1X1
011
000
2574 # set Compact and XMPShorthand options, preserving backward compatibility
2575 1 my ($p, %compact);
2576 1 foreach $p ('Compact','XMPShorthand') {
2577 # (allow setting from a HASH (undocumented)
2578 0 ▶ ref $newVal eq 'HASH' and %compact = %{$newVal}, next;
Branch: 1 branch
BranchTrueFalseTotal
ref $newVal eq "HASH" and %compact = %{$newVal;}, next 0 2 2
2579 2 ▶ my $val = $param eq $p ? $newVal : $$options{Compact}{$p};
Branch: 1 branch
BranchTrueFalseTotal
$param eq $p ? : 1 1 2
2580 2 ▶ if (defined $val) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $val) 1 1 2
2581 1 my @v = ($val =~ /\w+/g);
2582 1 ▶ my $opt = ($p eq 'Compact') ? \%compactOpt : \%xmpShorthandOpt;
Branch: 1 branch
BranchTrueFalseTotal
$p eq 'Compact' ? : 0 1 1
2583 1 foreach (@v) {
2584 1 ▶ my $set = $$opt{lc $_} or warn("Invalid $p setting '${_}'\n"), return $oldVal;
Branch: 1 branch
BranchTrueFalseTotal
my $set = $$opt{lc $_} or warn("Invalid $p setting '${_}'\n"), (return $oldVal) 1 0 1
2585 1 ▶ ref $set or $compact{$set} = 1, next;
Branch: 1 branch
BranchTrueFalseTotal
ref $set or $compact{$set} = 1, next 0 1 1
2586 0 $compact{$_} = 1 foreach @$set;
2587 }
2588 }
2589 2 $compact{$p} = $val; # preserve most recent setting
2590 }
2591 1 $$options{Compact} = $$options{XMPShorthand} = \%compact;
2592 } elsif ($param eq 'NoWarning') {
2593 # validate regular expression
2594 59 undef $evalWarning;
2595 59 ▶ if (defined $newVal) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $newVal) 0 59 59
2596 0 local $SIG{'__WARN__'} = \&SetWarning;
2597 0 eval { $param =~ /$newVal/ };
2598 0 ▶ $@ and $evalWarning = $@;
Branch: 1 branch
BranchTrueFalseTotal
$@ and $Image::ExifTool::evalWarning = $@ 0 0 0
2599 }
2600 59 ▶ if ($evalWarning) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Image::ExifTool::evalWarning) 0 59 59
2601 0 warn 'NoWarning: ' . CleanWarning() . "\n";
2602 0 next;
2603 }
2604 # add to existing expression if specified
2605 59 ▶ if ($plus and defined $oldVal) {
Branch: 1 branch
BranchTrueFalseTotal
if ($plus and defined $oldVal) 0 59 59
Condition33%1/3
$plus and defined $oldVal
!ll&&!rl&&r
5900
MC/DC0%0/2
$plus and defined $oldVal
$plus defined $oldVal
Truth table33%1/3
A and B
A= $plusB= defined $oldVal
ABresult
0X0
100
111
2606 0 ▶ $newVal = defined $newVal ? "$oldVal|$newVal" : $oldVal;
Branch: 1 branch
BranchTrueFalseTotal
defined $newVal ? : 0 0 0
2607 }
2608 59 $$options{$param} = $newVal;
2609 } elsif ($param eq 'ImageHashType') {
2610 59 ▶ if (not defined $newVal) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $newVal) { } 0 59 59
elsif ($newVal =~ /^(MD5|SHA256|SHA512)$/i) { } 59 0 59
2611 0 warn("Can't set $param to undef\n");
2612 } elsif ($newVal =~ /^(MD5|SHA256|SHA512)$/i) {
2613 59 $$options{$param} = uc($newVal);
2614 } else {
2615 0 warn("Invalid $param setting '${newVal}'\n");
2616 }
2617 } elsif ($param eq 'StructFormat') {
2618 59 ▶ if (defined $newVal) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $newVal) 0 59 59
2619 0 ▶ $newVal =~ /^(JSON|JSONQ)$/i or warn("Invalid $param setting '${newVal}'\n"), next;
Branch: 1 branch
BranchTrueFalseTotal
$newVal =~ /^(JSON|JSONQ)$/i or warn("Invalid $param setting '${newVal}'\n"), next 0 0 0
2620 0 $newVal = uc($newVal);
2621 }
2622 59 $$options{$param} = $newVal;
2623 } elsif ($param eq 'ByteUnit') {
2624 59 ▶ if (defined $newVal) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $newVal) { } 59 0 59
2625 # (allow "Metric" or "SI" for SI, and "IT" or "Binary" for Binary)
2626 59 ▶ my $goodVal = ($newVal =~ /^S|M/i ? 'SI' : ($newVal =~ /^I|B/i ? 'Binary' : undef));
Branch: 2 branches
BranchTrueFalseTotal
$newVal =~ /^S|M/i ? : 59 0 59
$newVal =~ /^I|B/i ? : 0 0 0
2627 59 ▶ $goodVal or warn("Invalid $param setting '${newVal}'\n"), next;
Branch: 1 branch
BranchTrueFalseTotal
$goodVal or warn("Invalid $param setting '${newVal}'\n"), next 59 0 59
2628 59 $$options{$param} = $goodVal;
2629 } else {
2630 0 warn("Can't set $param to undef\n");
2631 }
2632 } elsif ($param eq 'Plot') {
2633 # add to existing plot settings
2634 0 ▶ $newVal = "$oldVal,$newVal" if defined $oldVal and defined $newVal;
Branch: 1 branch
BranchTrueFalseTotal
if defined $oldVal and defined $newVal 0 0 0
Condition0%0/3
defined $oldVal and defined $newVal
!ll&&!rl&&r
000
MC/DC0%0/2
defined $oldVal and defined $newVal
defined $oldVal defined $newVal
Truth table0%0/3
A and B
A= defined $oldValB= defined $newVal
ABresult
0X0
100
111
2635 0 $$options{$param} = $newVal;
2636 ▶ } elsif ($param eq 'KeepUTCTime' or $param eq 'SystemTimeRes') {
Condition100%3/3
$param eq "KeepUTCTime" or $param eq "SystemTimeRes"
l!l&&r!l&&!r
59594963
MC/DC100%2/2
$param eq "KeepUTCTime" or $param eq "SystemTimeRes"
$param eq "KeepUTCTime" $param eq "SystemTimeRes"
Truth table100%3/3
A or B
A= $param eq "KeepUTCTime"B= $param eq "SystemTimeRes"
ABresult
1X1
011
000
2637 118 $$options{$param} = $static_vars{$param} = $newVal;
2638 } elsif (lc $param eq 'geodir') {
2639 0 $Image::ExifTool::Geolocation::geoDir = $newVal;
2640 } else {
2641 4963 ▶ if ($param eq 'Escape') {
Branch: 4 branches
BranchTrueFalseTotal
if ($param eq 'Escape') { } 65 4898 4963
elsif ($param eq 'GlobalTimeShift') { } 60 4838 4898
elsif ($param eq 'TimeZone' and defined $newVal and length $newVal) { } 0 4838 4838
elsif ($param eq 'Validate') { } 60 4778 4838
2642 # set ESCAPE_PROC
2643 65 ▶ if (defined $newVal and $newVal eq 'XML') {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $newVal and $newVal eq 'XML') { } 0 65 65
elsif (defined $newVal and $newVal eq 'HTML') { } 5 60 65
Condition66%2/3
defined $newVal and $newVal eq "XML"
!ll&&!rl&&r
6050
MC/DC0%0/2
defined $newVal and $newVal eq "XML"
defined $newVal $newVal eq "XML"
Truth table66%2/3
A and B
A= defined $newValB= $newVal eq "XML"
ABresult
0X0
100
111
2644 0 require Image::ExifTool::XMP;
2645 0 $$self{ESCAPE_PROC} = \&Image::ExifTool::XMP::EscapeXML;
2646 ▶ } elsif (defined $newVal and $newVal eq 'HTML') {
Condition66%2/3
defined $newVal and $newVal eq "HTML"
!ll&&!rl&&r
6005
MC/DC50%1/2
defined $newVal and $newVal eq "HTML"
defined $newVal $newVal eq "HTML"
Truth table66%2/3
A and B
A= defined $newValB= $newVal eq "HTML"
ABresult
0X0
100
111
2647 5 require Image::ExifTool::HTML;
2648 5 $$self{ESCAPE_PROC} = \&Image::ExifTool::HTML::EscapeHTML;
2649 } else {
2650 60 delete $$self{ESCAPE_PROC};
2651 }
2652 # must forget saved values since they depend on Escape method
2653 65 $$self{BOTH} = { };
2654 } elsif ($param eq 'GlobalTimeShift') {
2655 60 delete $$self{GLOBAL_TIME_OFFSET}; # reset our calculated offset
2656 ▶ } elsif ($param eq 'TimeZone' and defined $newVal and length $newVal) {
Condition50%3/6
$param eq "TimeZone" and defined $newVal and length $newVal
!ll&&!rl&&r
483800
$param eq "TimeZone" and defined $newVal
!ll&&!rl&&r
4779590
MC/DC0%0/3
$param eq "TimeZone" and defined $newVal and length $newVal
$param eq "TimeZone" defined $newVal length $newVal
Truth table50%2/4
A and B and C
A= $param eq "TimeZone"B= defined $newValC= length $newVal
ABCresult
0XX0
10X0
1100
1111
2657 0 $ENV{TZ} = $newVal;
2658 0 ▶ if ($^O eq 'MSWin32') {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq 'MSWin32') { } 0 0 0
2659 0 ▶ if (eval { require Time::Piece }) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval { do { require Time::Piece } }) { } 0 0 0
2660 0 eval { Time::Piece::_tzset() };
2661 } else {
2662 0 warn("Install Time::Piece to set time zone in Windows\n");
2663 }
2664 } else {
2665 0 eval { require POSIX; POSIX::tzset() };
2666 }
2667 } elsif ($param eq 'Validate') {
2668 # load Validate module if Validate option enabled
2669 60 ▶ $newVal and require Image::ExifTool::Validate;
Branch: 1 branch
BranchTrueFalseTotal
$newVal and require Image::ExifTool::Validate 1 59 60
2670 }
2671 4963 $$options{$param} = $newVal;
2672 }
2673 }
2674 23371 return $oldVal;
2675 }
2676  
2677 #------------------------------------------------------------------------------
2678 # ClearOptions - set options to default values
2679 # Inputs: 0) ExifTool object reference
2680 sub ClearOptions($)
2681 508 ▶{
Subroutine ClearOptions: called CC=6 SCAR=20.9
Pod documented
2682 508 local $_;
2683 508 my $self = shift;
2684 508 my $opts = $$self{OPTIONS} = { }; # clear all options
2685  
2686 # load default options
2687 508 $$opts{$$_[0]} = $$_[1] foreach @availableOptions;
2688  
2689 # enable WindowsLongPath if Win32::API is available
2690 0 ▶ $$opts{WindowsLongPath} = 1 if $^O eq 'MSWin32' and eval { require Win32::API };
Branch: 1 branch
BranchTrueFalseTotal
if $^O eq "MSWin32" and eval { do { require Win32::API } } 0 508 508
Condition33%1/3
$^O eq "MSWin32" and eval { do { require Win32::API } }
!ll&&!rl&&r
50800
MC/DC0%0/2
$^O eq "MSWin32" and eval { do { require Win32::API } }
$^O eq "MSWin32" eval { do { require Win32::API } }
Truth table33%1/3
A and B
A= $^O eq "MSWin32"B= eval { do { require Win32::API } }
ABresult
0X0
100
111
2691  
2692 # keep necessary member variables in sync with options
2693 508 delete $$self{CUR_LANG};
2694 508 delete $$self{ESCAPE_PROC};
2695  
2696 # load user-defined default options
2697 508 ▶ if (%Image::ExifTool::UserDefined::Options) {
Branch: 1 branch
BranchTrueFalseTotal
if (%Image::ExifTool::UserDefined::Options) 0 508 508
2698 0 foreach (keys %Image::ExifTool::UserDefined::Options) {
2699 0 $self->Options($_, $Image::ExifTool::UserDefined::Options{$_});
2700 }
2701 }
2702 }
2703  
2704 #------------------------------------------------------------------------------
2705 # Extract meta information from image
2706 # Inputs: 0) ExifTool object reference
2707 # 1-N) Same as ImageInfo()
2708 # Returns: 1 if this was a valid image, 0 otherwise
2709 # Notes: pass an undefined value to avoid parsing arguments
2710 # Internal 'ReEntry' option allows this routine to be called recursively
2711 sub ExtractInfo($;@)
2712 552 ▶{
Subroutine ExtractInfo: called CC=225 SCAR=85.6
Pod documented
2713 552 local $_;
2714 552 my $self = shift;
2715 552 my $options = $$self{OPTIONS}; # pointer to current options
2716 552 ▶ my $fast = $$options{FastScan} || 0;
Condition100%2/2
$options->{'FastScan'} || 0
l!l
2550
MC/DC100%1/1
$options->{'FastScan'} || 0
$options->{'FastScan'}
Truth table100%2/2
A
A= $options->{'FastScan'}
Aresult
11
00
2717 552 my $req = $$self{REQ_TAG_LOOKUP};
2718 552 ▶ my $reqAll = $$options{RequestAll} || 0;
Condition100%2/2
$options->{'RequestAll'} || 0
l!l
61491
MC/DC100%1/1
$options->{'RequestAll'} || 0
$options->{'RequestAll'}
Truth table100%2/2
A
A= $options->{'RequestAll'}
Aresult
11
00
2719 552 my (%saveOptions, $reEntry, $rsize, $zid, $type, @startTime, $saveOrder, $isDir, $i);
2720  
2721 # check for internal ReEntry option to allow recursive calls to ExtractInfo
2722 552 ▶ if (ref $_[1] eq 'HASH' and $_[1]{ReEntry} and
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[1] eq 'HASH' and $_[1]{'ReEntry'} and ref $_[0] eq 'SCALAR' || ref $_[0] eq 'GLOB') { } 2 550 552
Condition66%6/9
ref $_[1] eq "HASH" and $_[1]{"ReEntry"} and ref $_[0] eq "SCALAR" || ref $_[0] eq "GLOB"
!ll&&!rl&&r
55002
ref $_[1] eq "HASH" and $_[1]{"ReEntry"}
!ll&&!rl&&r
54912
ref $_[0] eq "SCALAR" or ref $_[0] eq "GLOB"
l!l&&r!l&&!r
200
MC/DC50%2/4
ref $_[1] eq "HASH" and $_[1]{"ReEntry"} and ref $_[0] eq "SCALAR" || ref $_[0] eq "GLOB"
ref $_[1] eq "HASH" $_[1]{"ReEntry"} ref $_[0] eq "SCALAR" ref $_[0] eq "GLOB"
Truth table60%3/5
A and B and C or D
A= ref $_[1] eq "HASH"B= $_[1]{"ReEntry"}C= ref $_[0] eq "SCALAR"D= ref $_[0] eq "GLOB"
ABCDresult
0XXX0
10XX0
11000
111X1
11011
2723 (ref $_[0] eq 'SCALAR' or ref $_[0] eq 'GLOB'))
2724 {
2725 # save necessary members for restoring later
2726 $reEntry = {
2727 RAF => $$self{RAF},
2728 PROCESSED => $$self{PROCESSED},
2729 EXIF_DATA => $$self{EXIF_DATA},
2730 EXIF_POS => $$self{EXIF_POS},
2731 FILE_TYPE => $$self{FILE_TYPE},
2732 2 };
2733 $saveOrder = GetByteOrder(),
2734 2 $$self{RAF} = File::RandomAccess->new($_[0]);
2735 2 $$self{PROCESSED} = { };
2736 2 delete $$self{EXIF_DATA};
2737 2 delete $$self{EXIF_POS};
2738 } else {
2739 550 ▶ if (defined $_[0] or $$options{HtmlDump} or $$req{validate}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0] or $options->{"HtmlDump"} or $req->{"validate"}) 12 538 550
Condition83%5/6
defined $_[0] or $options->{"HtmlDump"} or $req->{"validate"}
l!l&&r!l&&!r
111538
defined $_[0] or $options->{"HtmlDump"}
l!l&&r!l&&!r
110539
MC/DC66%2/3
defined $_[0] or $options->{"HtmlDump"} or $req->{"validate"}
defined $_[0] $options->{"HtmlDump"} $req->{"validate"}
Truth table75%3/4
A or B or C
A= defined $_[0]B= $options->{"HtmlDump"}C= $req->{"validate"}
ABCresult
1XX1
01X1
0011
0000
2740 12 %saveOptions = %$options; # save original options
2741  
2742 # require duplicates for html dump
2743 12 ▶ $self->Options(Duplicates => 1) if $$options{HtmlDump};
Branch: 1 branch
BranchTrueFalseTotal
if $options->{"HtmlDump"} 0 12 12
2744 # enable Validate option if Validate tag is requested
2745 12 ▶ $self->Options(Validate => 1) if $$req{validate};
Branch: 1 branch
BranchTrueFalseTotal
if $req->{"validate"} 1 11 12
2746 12 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 11 1 12
2747 # only initialize filename if called with arguments
2748 11 $$self{FILENAME} = undef; # name of file (or '' if we didn't open it)
2749 11 $$self{RAF} = undef; # RandomAccess object reference
2750  
2751 11 $self->ParseArguments(@_); # initialize from our arguments
2752 }
2753 }
2754 # ignore all tags and set ExtractEmbedded if outputting CSV directly
2755 550 ▶ if ($self->Options('PrintCSV')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->Options("PrintCSV")) 0 550 550
2756 0 $$self{OPTIONS}{IgnoreTags} = { all => 1 };
2757 0 $self->Options(ExtractEmbedded => 1);
2758 }
2759 # initialize ExifTool object members
2760 550 $self->Init();
2761 550 $$self{InExtract} = 1; # set flag indicating we are inside ExtractInfo
2762  
2763 550 delete $$self{MAKER_NOTE_FIXUP}; # fixup information for extracted maker notes
2764 550 delete $$self{MAKER_NOTE_BYTE_ORDER};
2765  
2766 # return our version number
2767 550 $self->FoundTag('ExifToolVersion', "$VERSION$RELEASE");
2768 550 ▶ $self->FoundTag('Now', $self->TimeNow()) if $$req{now} or $reqAll;
Branch: 1 branch
BranchTrueFalseTotal
if $req->{"now"} or $reqAll 61 489 550
Condition66%2/3
$req->{"now"} or $reqAll
l!l&&r!l&&!r
061489
MC/DC50%1/2
$req->{"now"} or $reqAll
$req->{"now"} $reqAll
Truth table66%2/3
A or B
A= $req->{"now"}B= $reqAll
ABresult
1X1
011
000
2769 550 ▶ $self->FoundTag('NewGUID', NewGUID()) if $$req{newguid} or $reqAll;
Branch: 1 branch
BranchTrueFalseTotal
if $req->{"newguid"} or $reqAll 61 489 550
Condition66%2/3
$req->{"newguid"} or $reqAll
l!l&&r!l&&!r
061489
MC/DC50%1/2
$req->{"newguid"} or $reqAll
$req->{"newguid"} $reqAll
Truth table66%2/3
A or B
A= $req->{"newguid"}B= $reqAll
ABresult
1X1
011
000
2770 # generate sequence number if necessary
2771 550 ▶ $self->FoundTag('FileSequence', $$self{FILE_SEQUENCE}) if $$req{filesequence} or $reqAll;
Branch: 1 branch
BranchTrueFalseTotal
if $req->{"filesequence"} or $reqAll 61 489 550
Condition66%2/3
$req->{"filesequence"} or $reqAll
l!l&&r!l&&!r
061489
MC/DC50%1/2
$req->{"filesequence"} or $reqAll
$req->{"filesequence"} $reqAll
Truth table66%2/3
A or B
A= $req->{"filesequence"}B= $reqAll
ABresult
1X1
011
000
2772  
2773 550 ▶ if ($$req{processingtime} or $reqAll) {
Branch: 1 branch
BranchTrueFalseTotal
if ($req->{"processingtime"} or $reqAll) 61 489 550
Condition66%2/3
$req->{"processingtime"} or $reqAll
l!l&&r!l&&!r
061489
MC/DC50%1/2
$req->{"processingtime"} or $reqAll
$req->{"processingtime"} $reqAll
Truth table66%2/3
A or B
A= $req->{"processingtime"}B= $reqAll
ABresult
1X1
011
000
2774 61 eval { require Time::HiRes; @startTime = Time::HiRes::gettimeofday() };
2775 61 ▶ if (not @startTime and $$req{processingtime}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not @startTime and $req->{"processingtime"}) 0 61 61
Condition33%1/3
not @startTime and $req->{"processingtime"}
!ll&&!rl&&r
6100
MC/DC0%0/2
not @startTime and $req->{"processingtime"}
not @startTime $req->{"processingtime"}
Truth table33%1/3
not(A) and B
A= not @startTimeB= $req->{"processingtime"}
ABresult
0X0
100
111
2776 0 $self->Warn('Install Time::HiRes to generate ProcessingTime');
2777 }
2778 }
2779  
2780 # create Hash object if ImageDataHash is requested
2781 550 ▶ if ($$req{imagedatahash} and not $$self{ImageDataHash}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($req->{"imagedatahash"} and not $self->{"ImageDataHash"}) 0 550 550
Condition33%1/3
$req->{"imagedatahash"} and not $self->{"ImageDataHash"}
!ll&&!rl&&r
55000
MC/DC0%0/2
$req->{"imagedatahash"} and not $self->{"ImageDataHash"}
$req->{"imagedatahash"} not $self->{"ImageDataHash"}
Truth table33%1/3
A and not(B)
A= $req->{"imagedatahash"}B= not $self->{"ImageDataHash"}
ABresult
0X0
100
111
2782 0 my $imageHashType = $self->Options('ImageHashType');
2783 0 ▶ if ($imageHashType =~ /^SHA(256|512)$/i) {
Branch: 2 branches
BranchTrueFalseTotal
if ($imageHashType =~ /^SHA(256|512)$/i) { } 0 0 0
elsif (require Digest::MD5) { } 0 0 0
2784 0 ▶ if (require Digest::SHA) {
Branch: 1 branch
BranchTrueFalseTotal
if (require Digest::SHA) { } 0 0 0
2785 0 $$self{ImageDataHash} = Digest::SHA->new($1);
2786 } else {
2787 0 $self->Warn("Install Digest::SHA to calculate image data SHA$1");
2788 }
2789 } elsif (require Digest::MD5) {
2790 0 $$self{ImageDataHash} = Digest::MD5->new;
2791 } else {
2792 0 $self->Warn('Install Digest::MD5 to calculate image data MD5');
2793 }
2794 }
2795 550 ++$$self{FILE_SEQUENCE}; # count files read
2796 }
2797  
2798 552 my $filename = $$self{FILENAME}; # image file name ('' if already open)
2799 552 my $raf = $$self{RAF}; # RandomAccess object
2800  
2801 552 local *EXIFTOOL_FILE; # avoid clashes with global namespace
2802  
2803 552 my $realname = $filename;
2804 552 ▶ unless ($raf) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($raf) 505 47 552
2805 # save file name
2806 505 ▶ if (defined $filename and $filename ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $filename and $filename ne '') { } 505 0 505
Condition33%1/3
defined $filename and $filename ne ""
!ll&&!rl&&r
00505
MC/DC0%0/2
defined $filename and $filename ne ""
defined $filename $filename ne ""
Truth table33%1/3
A and B
A= defined $filenameB= $filename ne ""
ABresult
0X0
100
111
2807 505 ▶ unless ($filename eq '-') {
Branch: 1 branch
BranchTrueFalseTotal
unless ($filename eq "-") 505 0 505
2808 # extract file name from pipe if necessary
2809 505 ▶ $realname =~ /\|$/ and $realname =~ s/^.*?"(.*?)".*/$1/s;
Branch: 1 branch
BranchTrueFalseTotal
$realname =~ /\|$/ and $realname =~ s/^.*?"(.*?)".*/$1/s 0 505 505
2810 505 my ($dir, $name) = SplitFileName($realname);
2811 505 $self->FoundTag('FileName', $name);
2812 505 ▶ if ($$req{basename} or
Branch: 1 branch
BranchTrueFalseTotal
if ($req->{"basename"} or $reqAll and not $self->{"EXCL_TAG_LOOKUP"}{"basename"}) 61 444 505
Condition66%4/6
$req->{"basename"} or $reqAll and not $self->{"EXCL_TAG_LOOKUP"}{"basename"}
l!l&&r!l&&!r
061444
$reqAll and not $self->{"EXCL_TAG_LOOKUP"}{"basename"}
!ll&&!rl&&r
444061
MC/DC33%1/3
$req->{"basename"} or $reqAll and not $self->{"EXCL_TAG_LOOKUP"}{"basename"}
$req->{"basename"} $reqAll not $self->{"EXCL_TAG_LOOKUP"}{"basename"}
Truth table50%2/4
A or B and not(C)
A= $req->{"basename"}B= $reqAllC= not $self->{"EXCL_TAG_LOOKUP"}{"basename"}
ABCresult
1XX1
0111
00X0
0100
2813 ($reqAll and not $$self{EXCL_TAG_LOOKUP}{basename}))
2814 {
2815 61 ▶ $self->FoundTag('BaseName', $name =~ /(.*)\./ ? $1 : $name);
Branch: 1 branch
BranchTrueFalseTotal
$name =~ /(.*)\./ ? : 61 0 61
2816 }
2817 505 ▶ $self->FoundTag('Directory', $dir) if defined $dir and length $dir;
Branch: 1 branch
BranchTrueFalseTotal
if defined $dir and length $dir 505 0 505
Condition33%1/3
defined $dir and length $dir
!ll&&!rl&&r
00505
MC/DC0%0/2
defined $dir and length $dir
defined $dir length $dir
Truth table33%1/3
A and B
A= defined $dirB= length $dir
ABresult
0X0
100
111
2818 505 ▶ if ($$req{filepath} or
Branch: 1 branch
BranchTrueFalseTotal
if ($req->{"filepath"} or $reqAll and not $self->{"EXCL_TAG_LOOKUP"}{"filepath"}) 61 444 505
Condition66%4/6
$req->{"filepath"} or $reqAll and not $self->{"EXCL_TAG_LOOKUP"}{"filepath"}
l!l&&r!l&&!r
061444
$reqAll and not $self->{"EXCL_TAG_LOOKUP"}{"filepath"}
!ll&&!rl&&r
444061
MC/DC33%1/3
$req->{"filepath"} or $reqAll and not $self->{"EXCL_TAG_LOOKUP"}{"filepath"}
$req->{"filepath"} $reqAll not $self->{"EXCL_TAG_LOOKUP"}{"filepath"}
Truth table50%2/4
A or B and not(C)
A= $req->{"filepath"}B= $reqAllC= not $self->{"EXCL_TAG_LOOKUP"}{"filepath"}
ABCresult
1XX1
0111
00X0
0100
2819 ($reqAll and not $$self{EXCL_TAG_LOOKUP}{filepath}))
2820 {
2821 61 my $path;
2822 61 local $SIG{'__WARN__'} = \&SetWarning;
2823 61 ▶ if ($^O eq 'MSWin32' and $$options{WindowsLongPath}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($^O eq 'MSWin32' and $options->{'WindowsLongPath'}) { } 0 61 61
elsif (eval { do { require Cwd } }) { } 61 0 61
Condition33%1/3
$^O eq "MSWin32" and $options->{"WindowsLongPath"}
!ll&&!rl&&r
6100
MC/DC0%0/2
$^O eq "MSWin32" and $options->{"WindowsLongPath"}
$^O eq "MSWin32" $options->{"WindowsLongPath"}
Truth table33%1/3
A and B
A= $^O eq "MSWin32"B= $options->{"WindowsLongPath"}
ABresult
0X0
100
111
2824 0 $path = $self->WindowsLongPath($filename);
2825 61 } elsif (eval { require Cwd }) {
2826 61 $path = eval { Cwd::abs_path($filename) };
2827 }
2828 61 ▶ if (defined $path) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $path) { } 61 0 61
elsif ($req->{'filepath'}) { } 0 0 0
2829 61 ▶ $path =~ tr/\\/\// if $^O eq 'MSWin32'; # return forward slashes
Branch: 1 branch
BranchTrueFalseTotal
if $^O eq "MSWin32" 0 61 61
2830 61 $self->FoundTag('FilePath', $path);
2831 } elsif ($$req{filepath}) {
2832 0 $self->Warn('The Perl Cwd module must be installed to use FilePath');
2833 }
2834 }
2835 # get size of resource fork on Mac OS
2836 505 ▶ $rsize = -s "$filename/..namedfork/rsrc" if $^O eq 'darwin' and not $$self{IN_RESOURCE};
Branch: 1 branch
BranchTrueFalseTotal
if $^O eq "darwin" and not $self->{"IN_RESOURCE"} 0 505 505
Condition33%1/3
$^O eq "darwin" and not $self->{"IN_RESOURCE"}
!ll&&!rl&&r
50500
MC/DC0%0/2
$^O eq "darwin" and not $self->{"IN_RESOURCE"}
$^O eq "darwin" not $self->{"IN_RESOURCE"}
Truth table33%1/3
A and not(B)
A= $^O eq "darwin"B= not $self->{"IN_RESOURCE"}
ABresult
0X0
100
111
2837 # check to see if Zone.Identifier file exists in Windows
2838 0 ▶ if ($^O eq 'MSWin32' and eval { require Win32API::File }) {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq "MSWin32" and eval { do { require Win32API::File } }) 0 505 505
Condition33%1/3
$^O eq "MSWin32" and eval { do { require Win32API::File } }
!ll&&!rl&&r
50500
MC/DC0%0/2
$^O eq "MSWin32" and eval { do { require Win32API::File } }
$^O eq "MSWin32" eval { do { require Win32API::File } }
Truth table33%1/3
A and B
A= $^O eq "MSWin32"B= eval { do { require Win32API::File } }
ABresult
0X0
100
111
2839 0 my $wattr;
2840 0 my $zfile = "${filename}:Zone.Identifier";
2841 0 ▶ if ($self->EncodeFileName($zfile)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->EncodeFileName($zfile)) { } 0 0 0
2842 0 $wattr = eval { Win32API::File::GetFileAttributesW($zfile) };
2843 } else {
2844 0 $wattr = eval { Win32API::File::GetFileAttributes($zfile) };
2845 }
2846 0 ▶ $zid = 1 unless $wattr == Win32API::File::INVALID_FILE_ATTRIBUTES();
Branch: 1 branch
BranchTrueFalseTotal
unless $wattr == Win32API::File::INVALID_FILE_ATTRIBUTES() 0 0 0
2847 }
2848 }
2849 # open the file
2850 505 ▶ if ($self->Open(\*EXIFTOOL_FILE, $filename)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->Open(\*EXIFTOOL_FILE, $filename)) { } 505 0 505
elsif ($self->IsDirectory($filename)) { } 0 0 0
2851 # create random access file object
2852 505 $raf = File::RandomAccess->new(\*EXIFTOOL_FILE);
2853 # patch to force pipe to be buffered because seek returns success
2854 # in Windows cmd shell pipe even though it really failed
2855 505 ▶ $$raf{TESTED} = -1 if $filename eq '-' or $filename =~ /\|$/;
Branch: 1 branch
BranchTrueFalseTotal
if $filename eq "-" or $filename =~ /\|$/ 0 505 505
Condition33%1/3
$filename eq "-" or $filename =~ /\|$/
l!l&&r!l&&!r
00505
MC/DC0%0/2
$filename eq "-" or $filename =~ /\|$/
$filename eq "-" $filename =~ /\|$/
Truth table33%1/3
A or B
A= $filename eq "-"B= $filename =~ /\|$/
ABresult
1X1
011
000
2856 505 $$self{RAF} = $raf;
2857 } elsif ($self->IsDirectory($filename)) {
2858 0 $isDir = 1;
2859 } else {
2860 0 $self->Error('Error opening file');
2861 # continue to process alt files if necessary
2862 0 ▶ $self->DoneExtract() if $$self{ALT_EXIFTOOL};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"ALT_EXIFTOOL"} 0 0 0
2863 }
2864 } else {
2865 0 $self->Error('No file specified');
2866 }
2867 }
2868  
2869 552 ▶ while ($raf or $isDir) {
Branch: 1 branch
BranchTrueFalseTotal
if ($raf or $isDir) 552 0 552
Condition33%1/3
$raf or $isDir
l!l&&r!l&&!r
55200
MC/DC0%0/2
$raf or $isDir
$raf $isDir
Truth table33%1/3
A or B
A= $rafB= $isDir
ABresult
1X1
011
000
2870 552 my (@stat, $plainFile);
2871 552 ▶ if ($reEntry) {
Branch: 4 branches
BranchTrueFalseTotal
if ($reEntry) { } 2 550 552
elsif (not $raf) { } 0 550 550
elsif (not $raf->{'FILE_PT'}) { } 25 525 550
elsif (-f $raf->{'FILE_PT'}) { } 525 0 525
2872 # we already set these tags
2873 } elsif (not $raf) {
2874 0 @stat = stat $filename;
2875 } elsif (not $$raf{FILE_PT}) {
2876 # get file size from image in memory
2877 25 $self->FoundTag('FileSize', length ${$$raf{BUFF_PT}});
2878 } elsif (-f $$raf{FILE_PT}) {
2879 # get file tags if this is a plain file
2880 525 @stat = stat _;
2881 525 $plainFile = 1;
2882 # hack to patch Windows daylight savings time bug
2883 525 ▶ @stat[8,9,10] = $self->GetFileTime($$raf{FILE_PT}) if $^O eq 'MSWin32';
Branch: 1 branch
BranchTrueFalseTotal
if $^O eq "MSWin32" 0 525 525
2884 } else {
2885 # (note that Windows directories will still show the
2886 # daylight savings time bug -- should fix this sometime)
2887 0 @stat = stat $$raf{FILE_PT};
2888 0 ▶ $stat[7] = undef if -p $$raf{FILE_PT}; # (pipe buffer size isn't useful)
Branch: 1 branch
BranchTrueFalseTotal
if -p $raf->{"FILE_PT"} 0 0 0
2889 }
2890 552 my $fileSize = $stat[7];
2891 552 ▶ $self->FoundTag('FileSize', $stat[7]) if defined $stat[7];
Branch: 1 branch
BranchTrueFalseTotal
if defined $stat[7] 525 27 552
2892 552 ▶ $self->FoundTag('ResourceForkSize', $rsize) if $rsize;
Branch: 1 branch
BranchTrueFalseTotal
if $rsize 0 552 552
2893 552 ▶ $self->FoundTag('ZoneIdentifier', 'Exists') if $zid;
Branch: 1 branch
BranchTrueFalseTotal
if $zid 0 552 552
2894 552 ▶ $self->FoundTag('FileModifyDate', $stat[9]) if defined $stat[9];
Branch: 1 branch
BranchTrueFalseTotal
if defined $stat[9] 525 27 552
2895 552 ▶ $self->FoundTag('FileAccessDate', $stat[8]) if defined $stat[8];
Branch: 1 branch
BranchTrueFalseTotal
if defined $stat[8] 525 27 552
2896 552 ▶ my $cTag = $^O eq 'MSWin32' ? 'FileCreateDate' : 'FileInodeChangeDate';
Branch: 1 branch
BranchTrueFalseTotal
$^O eq 'MSWin32' ? : 0 552 552
2897 552 ▶ $self->FoundTag($cTag, $stat[10]) if defined $stat[10];
Branch: 1 branch
BranchTrueFalseTotal
if defined $stat[10] 525 27 552
2898 552 ▶ if ($^O eq 'linux' and @stat and eval { require File::StatX }) {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq "linux" and @stat and eval { do { require File::StatX } }) 0 552 552
Condition66%4/6
$^O eq "linux" and @stat and eval { do { require File::StatX } }
!ll&&!rl&&r
275250
$^O eq "linux" and @stat
!ll&&!rl&&r
027525
MC/DC0%0/3
$^O eq "linux" and @stat and eval { do { require File::StatX } }
$^O eq "linux" @stat eval { do { require File::StatX } }
Truth table50%2/4
A and B and C
A= $^O eq "linux"B= @statC= eval { do { require File::StatX } }
ABCresult
0XX0
10X0
1100
1111
2899 0 my $stat;
2900 0 local $SIG{'__WARN__'} = \&SetWarning;
2901 0 ▶ if ($raf) {
Branch: 1 branch
BranchTrueFalseTotal
if ($raf) { } 0 0 0
2902 0 eval { $stat=File::StatX::fstatx($$raf{FILE_PT}, 0, File::StatX::STATX_BTIME()) };
2903 } else {
2904 0 eval { $stat=File::StatX::statx($filename, 0, File::StatX::STATX_BTIME()) };
2905 }
2906 0 ▶ $self->FoundTag('FileCreateDate', $stat->btime) if $stat and $stat->btime;
Branch: 1 branch
BranchTrueFalseTotal
if $stat and $stat->btime 0 0 0
Condition0%0/3
$stat and $stat->btime
!ll&&!rl&&r
000
MC/DC0%0/2
$stat and $stat->btime
$stat $stat->btime
Truth table0%0/3
A and B
A= $statB= $stat->btime
ABresult
0X0
100
111
2907 }
2908 552 ▶ $self->FoundTag('FilePermissions', $stat[2]) if defined $stat[2];
Branch: 1 branch
BranchTrueFalseTotal
if defined $stat[2] 525 27 552
2909 # extract more system info if SystemTags option is set
2910 552 ▶ if (@stat) {
Branch: 1 branch
BranchTrueFalseTotal
if (@stat) 525 27 552
2911 525 ▶ my $sys = $$options{SystemTags} || ($reqAll and not defined $$options{SystemTags});
Condition66%4/6
$options->{'SystemTags'} || $reqAll && !defined($options->{'SystemTags'})
l!l&&r!l&&!r
061464
$reqAll and not defined $options->{"SystemTags"}
!ll&&!rl&&r
464061
MC/DC33%1/3
$options->{'SystemTags'} || $reqAll && !defined($options->{'SystemTags'})
$options->{'SystemTags'} $reqAll not defined $options->{"SystemTags"}
Truth table50%2/4
A || B and not(C)
A= $options->{'SystemTags'}B= $reqAllC= not defined $options->{"SystemTags"}
ABCresult
1XX1
0111
00X0
0100
2912 525 ▶ if ($sys or $$req{fileattributes}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sys or $req->{"fileattributes"}) 61 464 525
Condition66%2/3
$sys or $req->{"fileattributes"}
l!l&&r!l&&!r
610464
MC/DC50%1/2
$sys or $req->{"fileattributes"}
$sys $req->{"fileattributes"}
Truth table66%2/3
A or B
A= $sysB= $req->{"fileattributes"}
ABresult
1X1
011
000
2913 61 my @attr = ($stat[2] & 0xf000, $stat[2] & 0x0e00);
2914 # add Windows file attributes if available
2915 61 ▶ if ($^O eq 'MSWin32' and defined $filename and $filename ne '' and $filename ne '-') {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq "MSWin32" and defined $filename and $filename ne "" and $filename ne "-") 0 61 61
Condition33%3/9
$^O eq "MSWin32" and defined $filename and $filename ne "" and $filename ne "-"
!ll&&!rl&&r
6100
$^O eq "MSWin32" and defined $filename and $filename ne ""
!ll&&!rl&&r
6100
$^O eq "MSWin32" and defined $filename
!ll&&!rl&&r
6100
MC/DC0%0/4
$^O eq "MSWin32" and defined $filename and $filename ne "" and $filename ne "-"
$^O eq "MSWin32" defined $filename $filename ne "" $filename ne "-"
Truth table20%1/5
A and B and C and D
A= $^O eq "MSWin32"B= defined $filenameC= $filename ne ""D= $filename ne "-"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
2916 0 local $SIG{'__WARN__'} = \&SetWarning;
2917 0 ▶ if (eval { require Win32API::File }) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval { do { require Win32API::File } }) 0 0 0
2918 0 my $wattr;
2919 0 my $file = $filename;
2920 0 ▶ if ($self->EncodeFileName($file)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->EncodeFileName($file)) { } 0 0 0
2921 0 $wattr = eval { Win32API::File::GetFileAttributesW($file) };
2922 } else {
2923 0 $wattr = eval { Win32API::File::GetFileAttributes($file) };
2924 }
2925 0 ▶ push @attr, $wattr if defined $wattr and $wattr != 0xffffffff;
Branch: 1 branch
BranchTrueFalseTotal
if defined $wattr and $wattr != 4294967295 0 0 0
Condition0%0/3
defined $wattr and $wattr != 4294967295
!ll&&!rl&&r
000
MC/DC0%0/2
defined $wattr and $wattr != 4294967295
defined $wattr $wattr != 4294967295
Truth table0%0/3
A and B
A= defined $wattrB= $wattr != 4294967295
ABresult
0X0
100
111
2926 }
2927 }
2928 61 $self->FoundTag('FileAttributes', "@attr");
2929 }
2930 525 ▶ $self->FoundTag('FileDeviceNumber', $stat[0]) if $sys or $$req{filedevicenumber};
Branch: 1 branch
BranchTrueFalseTotal
if $sys or $req->{"filedevicenumber"} 61 464 525
Condition66%2/3
$sys or $req->{"filedevicenumber"}
l!l&&r!l&&!r
610464
MC/DC50%1/2
$sys or $req->{"filedevicenumber"}
$sys $req->{"filedevicenumber"}
Truth table66%2/3
A or B
A= $sysB= $req->{"filedevicenumber"}
ABresult
1X1
011
000
2931 525 ▶ $self->FoundTag('FileInodeNumber', $stat[1]) if $sys or $$req{fileinodenumber};
Branch: 1 branch
BranchTrueFalseTotal
if $sys or $req->{"fileinodenumber"} 61 464 525
Condition66%2/3
$sys or $req->{"fileinodenumber"}
l!l&&r!l&&!r
610464
MC/DC50%1/2
$sys or $req->{"fileinodenumber"}
$sys $req->{"fileinodenumber"}
Truth table66%2/3
A or B
A= $sysB= $req->{"fileinodenumber"}
ABresult
1X1
011
000
2932 525 ▶ $self->FoundTag('FileHardLinks', $stat[3]) if $sys or $$req{filehardlinks};
Branch: 1 branch
BranchTrueFalseTotal
if $sys or $req->{"filehardlinks"} 61 464 525
Condition66%2/3
$sys or $req->{"filehardlinks"}
l!l&&r!l&&!r
610464
MC/DC50%1/2
$sys or $req->{"filehardlinks"}
$sys $req->{"filehardlinks"}
Truth table66%2/3
A or B
A= $sysB= $req->{"filehardlinks"}
ABresult
1X1
011
000
2933 525 ▶ $self->FoundTag('FileUserID', $stat[4]) if $sys or $$req{fileuserid};
Branch: 1 branch
BranchTrueFalseTotal
if $sys or $req->{"fileuserid"} 61 464 525
Condition66%2/3
$sys or $req->{"fileuserid"}
l!l&&r!l&&!r
610464
MC/DC50%1/2
$sys or $req->{"fileuserid"}
$sys $req->{"fileuserid"}
Truth table66%2/3
A or B
A= $sysB= $req->{"fileuserid"}
ABresult
1X1
011
000
2934 525 ▶ $self->FoundTag('FileGroupID', $stat[5]) if $sys or $$req{filegroupid};
Branch: 1 branch
BranchTrueFalseTotal
if $sys or $req->{"filegroupid"} 61 464 525
Condition66%2/3
$sys or $req->{"filegroupid"}
l!l&&r!l&&!r
610464
MC/DC50%1/2
$sys or $req->{"filegroupid"}
$sys $req->{"filegroupid"}
Truth table66%2/3
A or B
A= $sysB= $req->{"filegroupid"}
ABresult
1X1
011
000
2935 525 ▶ $self->FoundTag('FileDeviceID', $stat[6]) if $sys or $$req{filedeviceid};
Branch: 1 branch
BranchTrueFalseTotal
if $sys or $req->{"filedeviceid"} 61 464 525
Condition66%2/3
$sys or $req->{"filedeviceid"}
l!l&&r!l&&!r
610464
MC/DC50%1/2
$sys or $req->{"filedeviceid"}
$sys $req->{"filedeviceid"}
Truth table66%2/3
A or B
A= $sysB= $req->{"filedeviceid"}
ABresult
1X1
011
000
2936 525 ▶ $self->FoundTag('FileBlockSize', $stat[11]) if $sys or $$req{fileblocksize};
Branch: 1 branch
BranchTrueFalseTotal
if $sys or $req->{"fileblocksize"} 61 464 525
Condition66%2/3
$sys or $req->{"fileblocksize"}
l!l&&r!l&&!r
610464
MC/DC50%1/2
$sys or $req->{"fileblocksize"}
$sys $req->{"fileblocksize"}
Truth table66%2/3
A or B
A= $sysB= $req->{"fileblocksize"}
ABresult
1X1
011
000
2937 525 ▶ $self->FoundTag('FileBlockCount', $stat[12]) if $sys or $$req{fileblockcount};
Branch: 1 branch
BranchTrueFalseTotal
if $sys or $req->{"fileblockcount"} 61 464 525
Condition66%2/3
$sys or $req->{"fileblockcount"}
l!l&&r!l&&!r
610464
MC/DC50%1/2
$sys or $req->{"fileblockcount"}
$sys $req->{"fileblockcount"}
Truth table66%2/3
A or B
A= $sysB= $req->{"fileblockcount"}
ABresult
1X1
011
000
2938 }
2939 # extract MDItem tags if requested (only on plain files)
2940 552 ▶ if ($^O eq 'darwin' and defined $filename and $filename ne '' and defined $fileSize) {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq "darwin" and defined $filename and $filename ne "" and defined $fileSize) 0 552 552
Condition33%3/9
$^O eq "darwin" and defined $filename and $filename ne "" and defined $fileSize
!ll&&!rl&&r
55200
$^O eq "darwin" and defined $filename and $filename ne ""
!ll&&!rl&&r
55200
$^O eq "darwin" and defined $filename
!ll&&!rl&&r
55200
MC/DC0%0/4
$^O eq "darwin" and defined $filename and $filename ne "" and defined $fileSize
$^O eq "darwin" defined $filename $filename ne "" defined $fileSize
Truth table20%1/5
A and B and C and D
A= $^O eq "darwin"B= defined $filenameC= $filename ne ""D= defined $fileSize
ABCDresult
0XXX0
10XX0
110X0
11100
11111
2941 0 ▶ my $reqMacOS = ($reqAll > 1 or $$req{'macos:'});
Condition0%0/3
$reqAll > 1 || $req->{'macos:'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$reqAll > 1 || $req->{'macos:'}
$reqAll > 1 $req->{'macos:'}
Truth table0%0/3
A || B
A= $reqAll > 1B= $req->{'macos:'}
ABresult
1X1
011
000
2942 0 ▶ my $crDate = ($reqMacOS || $$req{filecreatedate});
Condition0%0/3
$reqMacOS || $req->{'filecreatedate'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$reqMacOS || $req->{'filecreatedate'}
$reqMacOS $req->{'filecreatedate'}
Truth table0%0/3
A || B
A= $reqMacOSB= $req->{'filecreatedate'}
ABresult
1X1
011
000
2943 0 ▶ my $mdItem = ($reqMacOS || $$options{MDItemTags} || grep /^mditem/, keys %$req);
Condition0%0/6
$reqMacOS || $options->{'MDItemTags'} || grep(/^mditem/, keys %$req)
l!l&&r!l&&!r
000
$reqMacOS or $options->{"MDItemTags"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$reqMacOS || $options->{'MDItemTags'} || grep(/^mditem/, keys %$req)
$reqMacOS $options->{"MDItemTags"} grep(/^mditem/, keys %$req)
Truth table0%0/4
A or B || C
A= $reqMacOSB= $options->{"MDItemTags"}C= grep(/^mditem/, keys %$req)
ABCresult
1XX1
01X1
0011
0000
2944 0 ▶ my $xattr = ($reqMacOS || $$options{XAttrTags} || grep /^xattr/, keys %$req);
Condition0%0/6
$reqMacOS || $options->{'XAttrTags'} || grep(/^xattr/, keys %$req)
l!l&&r!l&&!r
000
$reqMacOS or $options->{"XAttrTags"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$reqMacOS || $options->{'XAttrTags'} || grep(/^xattr/, keys %$req)
$reqMacOS $options->{"XAttrTags"} grep(/^xattr/, keys %$req)
Truth table0%0/4
A or B || C
A= $reqMacOSB= $options->{"XAttrTags"}C= grep(/^xattr/, keys %$req)
ABCresult
1XX1
01X1
0011
0000
2945 0 ▶ if ($crDate or $mdItem or $xattr) {
Branch: 1 branch
BranchTrueFalseTotal
if ($crDate or $mdItem or $xattr) 0 0 0
Condition0%0/6
$crDate or $mdItem or $xattr
l!l&&r!l&&!r
000
$crDate or $mdItem
l!l&&r!l&&!r
000
MC/DC0%0/3
$crDate or $mdItem or $xattr
$crDate $mdItem $xattr
Truth table0%0/4
A or B or C
A= $crDateB= $mdItemC= $xattr
ABCresult
1XX1
01X1
0011
0000
2946 0 require Image::ExifTool::MacOS;
2947 0 ▶ Image::ExifTool::MacOS::GetFileCreateDate($self, $filename) if $crDate;
Branch: 1 branch
BranchTrueFalseTotal
if $crDate 0 0 0
2948 0 ▶ Image::ExifTool::MacOS::ExtractMDItemTags($self, $filename) if $mdItem and $plainFile;
Branch: 1 branch
BranchTrueFalseTotal
if $mdItem and $plainFile 0 0 0
Condition0%0/3
$mdItem and $plainFile
!ll&&!rl&&r
000
MC/DC0%0/2
$mdItem and $plainFile
$mdItem $plainFile
Truth table0%0/3
A and B
A= $mdItemB= $plainFile
ABresult
0X0
100
111
2949 0 ▶ Image::ExifTool::MacOS::ExtractXAttrTags($self, $filename) if $xattr;
Branch: 1 branch
BranchTrueFalseTotal
if $xattr 0 0 0
2950 }
2951 }
2952 # do whatever else we can with directories, then return
2953 552 ▶ if ($isDir or (defined $stat[2] and ($stat[2] & 0170000) == 0040000)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($isDir or defined $stat[2] and ($stat[2] & 61440) == 16384) 0 552 552
Condition50%3/6
$isDir or defined $stat[2] and ($stat[2] & 61440) == 16384
l!l&&r!l&&!r
00552
defined $stat[2] and ($stat[2] & 61440) == 16384
!ll&&!rl&&r
275250
MC/DC0%0/3
$isDir or defined $stat[2] and ($stat[2] & 61440) == 16384
$isDir defined $stat[2] ($stat[2] & 61440) == 16384
Truth table50%2/4
A or B and C
A= $isDirB= defined $stat[2]C= ($stat[2] & 61440) == 16384
ABCresult
1XX1
0111
00X0
0100
2954 0 $self->FoundTag('FileType', 'DIR');
2955 0 $self->FoundTag('FileTypeExtension', '');
2956 0 $self->DoneExtract();
2957 0 ▶ $raf->Close() if $raf;
Branch: 1 branch
BranchTrueFalseTotal
if $raf 0 0 0
2958 0 ▶ %saveOptions and $$self{OPTIONS} = \%saveOptions;
Branch: 1 branch
BranchTrueFalseTotal
%saveOptions and $self->{"OPTIONS"} = \%saveOptions 0 0 0
2959 0 ▶ delete $$self{InExtract} unless $reEntry;
Branch: 1 branch
BranchTrueFalseTotal
unless $reEntry 0 0 0
2960 0 return 1;
2961 }
2962 # get list of file types to check
2963 552 my ($tiffType, %noMagic, $recognizedExt);
2964 552 my $ext = $$self{FILE_EXT} = GetFileExtension($realname);
2965 # set $recognizedExt if this file type is recognized by extension only
2966 $recognizedExt = $ext if defined $ext and not defined $magicNumber{$ext} and
2967 552 ▶ defined $moduleName{$ext} and not $moduleName{$ext};
Branch: 1 branch
BranchTrueFalseTotal
if defined $ext and not defined $Image::ExifTool::magicNumber{$ext} and defined $moduleName{$ext} and not $moduleName{$ext} 0 552 552
Condition88%8/9
defined $ext and not defined $Image::ExifTool::magicNumber{$ext} and defined $moduleName{$ext} and not $moduleName{$ext}
!ll&&!rl&&r
55020
defined $ext and not defined $Image::ExifTool::magicNumber{$ext} and defined $moduleName{$ext}
!ll&&!rl&&r
2403102
defined $ext and not defined $Image::ExifTool::magicNumber{$ext}
!ll&&!rl&&r
45195312
MC/DC0%0/4
defined $ext and not defined $Image::ExifTool::magicNumber{$ext} and defined $moduleName{$ext} and not $moduleName{$ext}
defined $ext not defined $Image::ExifTool::magicNumber{$ext} defined $moduleName{$ext} not $moduleName{$ext}
Truth table80%4/5
A and not(B) and C and not(D)
A= defined $extB= not defined $Image::ExifTool::magicNumber{$ext}C= defined $moduleName{$ext}D= not $moduleName{$ext}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
2968 552 my @fileTypeList = GetFileType($realname);
2969 552 ▶ if ($fast >= 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fast >= 4) 0 552 552
2970 0 ▶ if (@fileTypeList) {
Branch: 1 branch
BranchTrueFalseTotal
if (@fileTypeList) { } 0 0 0
2971 0 $type = shift @fileTypeList;
2972 0 $self->SetFileType($$self{FILE_TYPE} = $type);
2973 } else {
2974 0 $self->Error('Unknown file type');
2975 }
2976 0 $self->DoneExtract();
2977 0 last; # don't read the file
2978 }
2979 552 ▶ if (@fileTypeList) {
Branch: 1 branch
BranchTrueFalseTotal
if (@fileTypeList) { } 502 50 552
2980 # add remaining types to end of list so we test them all
2981 502 my $pat = join '|', @fileTypeList;
2982 502 push @fileTypeList, grep(!/^($pat)$/, @fileTypes);
2983 502 $tiffType = $$self{FILE_EXT};
2984 502 ▶ unless ($fast == 3) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($fast == 3) 501 1 502
2985 501 $noMagic{MXF} = 1; # don't do magic number test on MXF or DV files
2986 501 $noMagic{DV} = 1;
2987 }
2988 } else {
2989 # scan through all recognized file types
2990 50 @fileTypeList = @fileTypes;
2991 50 $tiffType = 'TIFF';
2992 }
2993 552 push @fileTypeList, ''; # end of list marker
2994 # initialize the input file for seeking in binary data
2995 552 $raf->BinMode(); # set binary mode before we start reading
2996 552 my $pos = $raf->Tell(); # get file position so we can rewind
2997 # loop through list of file types to test
2998 552 my ($buff, $err);
2999 552 my %dirInfo = ( RAF => $raf, Base => $pos, TestBuff => \$buff );
3000 # read start of file for testing
3001 552 ▶ if ($raf->Read($buff, $testLen)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($raf->Read($buff, $Image::ExifTool::testLen)) { } 549 3 552
3002 549 ▶ $raf->Seek($pos, 0) or $err = 'Error seeking in file';
Branch: 1 branch
BranchTrueFalseTotal
$raf->Seek($pos, 0) or $err = "Error seeking in file" 549 0 549
3003 } else {
3004 3 $err = $$raf{ERROR};
3005 3 $buff = '';
3006 }
3007 552 ▶ until ($err) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($err) 2383 0 2383
3008 2383 my $unkHeader;
3009 2383 $type = shift @fileTypeList;
3010 2383 ▶ if ($type) {
Branch: 3 branches
BranchTrueFalseTotal
if ($type) { } 2377 6 2383
elsif (not defined $type) { } 3 3 6
elsif ($recognizedExt) { } 0 3 3
3011 2377 ▶ if ($magicNumber{$type}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Image::ExifTool::magicNumber{$type}) { } 2301 76 2377
3012 # do quick test for this file type to avoid loading module unnecessarily
3013 2301 ▶ next if $buff !~ /^$magicNumber{$type}/s and not $noMagic{$type};
Branch: 1 branch
BranchTrueFalseTotal
unless $buff =~ /^$Image::ExifTool::magicNumber{$type}/s or $noMagic{$type} 1745 556 2301
Condition100%3/3
$buff =~ /^$Image::ExifTool::magicNumber{$type}/s or $noMagic{$type}
l!l&&r!l&&!r
55421745
MC/DC100%2/2
$buff =~ /^$Image::ExifTool::magicNumber{$type}/s or $noMagic{$type}
$buff =~ /^$Image::ExifTool::magicNumber{$type}/s $noMagic{$type}
Truth table100%3/3
A or B
A= $buff =~ /^$Image::ExifTool::magicNumber{$type}/sB= $noMagic{$type}
ABresult
1X1
011
000
3014 } else {
3015 # keep checking for other types if we recognize this file only by extension
3016 76 ▶ next if defined $moduleName{$type} and not $moduleName{$type};
Branch: 1 branch
BranchTrueFalseTotal
if defined $moduleName{$type} and not $moduleName{$type} 0 76 76
Condition66%2/3
defined $moduleName{$type} and not $moduleName{$type}
!ll&&!rl&&r
26500
MC/DC0%0/2
defined $moduleName{$type} and not $moduleName{$type}
defined $moduleName{$type} not $moduleName{$type}
Truth table66%2/3
A and not(B)
A= defined $moduleName{$type}B= not $moduleName{$type}
ABresult
0X0
100
111
3017 76 ▶ next if $fast > 2; # keep checking if we aren't processing the file
Branch: 1 branch
BranchTrueFalseTotal
if $fast > 2 0 76 76
3018 }
3019 632 ▶ next if $weakMagic{$type} and defined $recognizedExt;
Branch: 1 branch
BranchTrueFalseTotal
if $weakMagic{$type} and defined $recognizedExt 0 632 632
Condition66%2/3
$weakMagic{$type} and defined $recognizedExt
!ll&&!rl&&r
620120
MC/DC0%0/2
$weakMagic{$type} and defined $recognizedExt
$weakMagic{$type} defined $recognizedExt
Truth table66%2/3
A and B
A= $weakMagic{$type}B= defined $recognizedExt
ABresult
0X0
100
111
3020 } elsif (not defined $type) {
3021 3 last;
3022 } elsif ($recognizedExt) {
3023 0 $type = $recognizedExt; # set type from recognized file extension only
3024 } else {
3025 # last ditch effort to scan past unknown header for JPEG/TIFF
3026 3 ▶ next unless $buff =~ /(\xff\xd8\xff|MM\0\x2a|II\x2a\0)/g;
Branch: 1 branch
BranchTrueFalseTotal
unless $buff =~ /(\xff\xd8\xff|MM\0\x2a|II\x2a\0)/g 3 0 3
3027 0 ▶ $type = ($1 eq "\xff\xd8\xff") ? 'JPEG' : 'TIFF';
Branch: 1 branch
BranchTrueFalseTotal
$1 eq "\377\330\377" ? : 0 0 0
3028 0 my $skip = pos($buff) - length($1);
3029 0 $dirInfo{Base} = $pos + $skip;
3030 0 ▶ $raf->Seek($pos + $skip, 0) or $err = 'Error seeking in file', last;
Branch: 1 branch
BranchTrueFalseTotal
$raf->Seek($pos + $skip, 0) or $err = "Error seeking in file", last 0 0 0
3031 0 $self->Warn("Processing $type-like data after unknown $skip-byte header");
3032 0 ▶ $unkHeader = 1 unless $$self{DOC_NUM};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"DOC_NUM"} 0 0 0
3033 }
3034 # save file type in member variable
3035 632 $$self{FILE_TYPE} = $type;
3036 632 ▶ $dirInfo{Parent} = ($type eq 'TIFF') ? $tiffType : $type;
Branch: 1 branch
BranchTrueFalseTotal
$type eq 'TIFF' ? : 25 607 632
3037 # don't process the file when FastScan > 2
3038 632 ▶ if ($fast > 2 and not $processType{$type}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fast > 2 and not $processType{$type}) 0 632 632
Condition66%2/3
$fast > 2 and not $processType{$type}
!ll&&!rl&&r
63110
MC/DC0%0/2
$fast > 2 and not $processType{$type}
$fast > 2 not $processType{$type}
Truth table66%2/3
A and not(B)
A= $fast > 2B= not $processType{$type}
ABresult
0X0
100
111
3039 0 ▶ unless ($weakMagic{$type} and (not $ext or $ext ne $type)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($weakMagic{$type} and !$ext || $ext ne $type) 0 0 0
Condition0%0/6
$weakMagic{$type} and !$ext || $ext ne $type
!ll&&!rl&&r
000
not $ext or $ext ne $type
l!l&&r!l&&!r
000
MC/DC0%0/3
$weakMagic{$type} and !$ext || $ext ne $type
$weakMagic{$type} not $ext $ext ne $type
Truth table0%0/4
A and not(B) or C
A= $weakMagic{$type}B= not $extC= $ext ne $type
ABCresult
0XX0
1000
11X1
1011
3040 0 $self->SetFileType($dirInfo{Parent});
3041 }
3042 0 last;
3043 }
3044 632 my $module = $moduleName{$type};
3045 632 ▶ $module = $type unless defined $module;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $module 205 427 632
3046 632 my $func = "Process$type";
3047  
3048 # load module if necessary
3049 632 ▶ if ($module) {
Branch: 2 branches
BranchTrueFalseTotal
if ($module) { } 362 270 632
elsif ($module eq '0') { } 0 270 270
3050 362 require "Image/ExifTool/$module.pm";
3051 362 $func = "Image::ExifTool::${module}::$func";
3052 } elsif ($module eq '0') {
3053 0 $self->SetFileType();
3054 0 $self->Warn('Unsupported file type');
3055 0 last;
3056 }
3057 632 push @{$$self{PATH}}, $type; # save file type in metadata PATH
3058  
3059 # process the file
3060 113 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
3061 632 my $result = &$func($self, \%dirInfo);
3062 113 ▶ use strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
3063  
3064 632 pop @{$$self{PATH}};
3065  
3066 632 ▶ if ($result) { # all done if successful
Branch: 1 branch
BranchTrueFalseTotal
if ($result) 549 83 632
3067 549 ▶ if ($unkHeader) {
Branch: 1 branch
BranchTrueFalseTotal
if ($unkHeader) 0 549 549
3068 0 $self->DeleteTag('FileType');
3069 0 $self->DeleteTag('FileTypeExtension');
3070 0 $self->DeleteTag('MIMEType');
3071 0 $self->VPrint(0,"Reset file type due to unknown header\n");
3072 }
3073 549 last;
3074 }
3075 # seek back to try again from the same position in the file
3076 83 ▶ $raf->Seek($pos, 0) or $err = 'Error seeking in file';
Branch: 1 branch
BranchTrueFalseTotal
$raf->Seek($pos, 0) or $err = "Error seeking in file" 83 0 83
3077 }
3078 552 ▶ if (not $err and not defined $type and not $$self{DOC_NUM}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($err or defined $type or $self->{"DOC_NUM"}) 3 549 552
Condition66%4/6
$err or defined $type or $self->{"DOC_NUM"}
l!l&&r!l&&!r
54903
$err or defined $type
l!l&&r!l&&!r
05493
MC/DC33%1/3
$err or defined $type or $self->{"DOC_NUM"}
$err defined $type $self->{"DOC_NUM"}
Truth table50%2/4
A or B or C
A= $errB= defined $typeC= $self->{"DOC_NUM"}
ABCresult
1XX1
01X1
0011
0000
3079 # if we were given a single image with a known type there
3080 # must be a format error since we couldn't read it, otherwise
3081 # it is likely we don't support images of this type
3082 3 ▶ my $fileType = GetFileType($realname) || '';
Condition50%1/2
&GetFileType($realname) || ''
l!l
03
MC/DC0%0/1
&GetFileType($realname) || ''
&GetFileType($realname)
Truth table50%1/2
A
A= &GetFileType($realname)
Aresult
11
00
3083 3 ▶ if (not length $buff) {
Branch: 1 branch
BranchTrueFalseTotal
if (not length $buff) { } 3 0 3
3084 3 $err = 'File is empty';
3085 } else {
3086 0 my $ch = substr($buff, 0, 1);
3087 0 ▶ if (length $buff < 16 or $buff =~ /[^\Q$ch\E]/) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $buff < 16 or $buff =~ /[^\Q$ch\E]/) { } 0 0 0
Condition0%0/3
length $buff < 16 or $buff =~ /[^\Q$ch\E]/
l!l&&r!l&&!r
000
MC/DC0%0/2
length $buff < 16 or $buff =~ /[^\Q$ch\E]/
length $buff < 16 $buff =~ /[^\Q$ch\E]/
Truth table0%0/3
A or B
A= length $buff < 16B= $buff =~ /[^\Q$ch\E]/
ABresult
1X1
011
000
3088 0 ▶ if ($fileType eq 'RAW') {
Branch: 2 branches
BranchTrueFalseTotal
if ($fileType eq 'RAW') { } 0 0 0
elsif ($fileType) { } 0 0 0
3089 0 $err = 'Unsupported RAW file type';
3090 } elsif ($fileType) {
3091 0 $err = 'File format error';
3092 } else {
3093 0 $err = 'Unknown file type';
3094 }
3095 } else {
3096 # provide some insight into the content of some corrupted files
3097 0 ▶ if ($$self{OPTIONS}{FastScan}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'OPTIONS'}{'FastScan'}) { } 0 0 0
3098 0 $err = 'File header is all';
3099 } else {
3100 0 my $num = 0;
3101 0 for (;;) {
3102 0 ▶ $raf->Read($buff, 65536) or undef($num), last;
Branch: 1 branch
BranchTrueFalseTotal
$raf->Read($buff, 65536) or undef $num, last 0 0 0
3103 0 ▶ $buff =~ /[^\Q$ch\E]/g and $num += pos($buff) - 1, last;
Branch: 1 branch
BranchTrueFalseTotal
$buff =~ /[^\Q$ch\E]/g and $num += pos($buff) - 1, last 0 0 0
3104 0 $num += length($buff);
3105 }
3106 0 ▶ if ($num) {
Branch: 1 branch
BranchTrueFalseTotal
if ($num) { } 0 0 0
3107 0 $err = 'First ' . ConvertFileSize($num) . ' of file is';
3108 } else {
3109 0 $err = 'Entire file is';
3110 }
3111 }
3112 0 ▶ if ($ch eq "\0") {
Branch: 3 branches
BranchTrueFalseTotal
if ($ch eq "\000") { } 0 0 0
elsif ($ch eq ' ') { } 0 0 0
elsif ($ch =~ /[a-zA-Z0-9]/) { } 0 0 0
3113 0 $err .= ' binary zeros';
3114 } elsif ($ch eq ' ') {
3115 0 $err .= ' ASCII spaces';
3116 } elsif ($ch =~ /[a-zA-Z0-9]/) {
3117 0 $err .= " ASCII '${ch}' characters";
3118 } else {
3119 0 $err .= sprintf(" binary 0x%.2x's", ord $ch);
3120 }
3121 }
3122 }
3123 }
3124 552 ▶ if ($err) {
Branch: 2 branches
BranchTrueFalseTotal
if ($err) { } 3 549 552
elsif ($self->Options('ScanForXMP') and not defined $type && ($fast || $self->{'FoundXMP'})) { } 0 1098 1098
3125 3 $self->Error($err);
3126 ▶ } elsif ($self->Options('ScanForXMP') and (not defined $type or
Condition11%1/9
$self->Options("ScanForXMP") and not defined $type && ($fast || $self->{"FoundXMP"})
!ll&&!rl&&r
54900
defined $type && ($fast || $self->{'FoundXMP'})
!ll&&!rl&&r
000
$fast or $self->{"FoundXMP"}
l!l&&r!l&&!r
000
MC/DC0%0/4
$self->Options("ScanForXMP") and not defined $type && ($fast || $self->{"FoundXMP"})
$self->Options("ScanForXMP") defined $type $fast $self->{"FoundXMP"}
Truth table20%1/5
A and not(B && C or D)
A= $self->Options("ScanForXMP")B= defined $typeC= $fastD= $self->{"FoundXMP"}
ABCDresult
0XXX0
111X0
11010
10XX1
11001
3127 (not $fast and not $$self{FoundXMP})))
3128 {
3129 # scan for XMP
3130 0 $raf->Seek($pos, 0);
3131 0 require Image::ExifTool::XMP;
3132 0 ▶ Image::ExifTool::XMP::ScanForXMP($self, $raf) and $type = '';
Branch: 1 branch
BranchTrueFalseTotal
Image::ExifTool::XMP::ScanForXMP($self, $raf) and $type = "" 0 0 0
3133 }
3134 # extract binary EXIF data block only if requested
3135 552 ▶ if (defined $$self{EXIF_DATA} and length $$self{EXIF_DATA} > 16 and
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"EXIF_DATA"} and length $self->{"EXIF_DATA"} > 16 and $req->{"exif"} || $self->{"TAGS_FROM_FILE"} && !$self->{"EXCL_TAG_LOOKUP"}{"exif"}) 37 515 552
Condition91%11/12
defined $self->{"EXIF_DATA"} and length $self->{"EXIF_DATA"} > 16 and $req->{"exif"} || $self->{"TAGS_FROM_FILE"} && !$self->{"EXCL_TAG_LOOKUP"}{"exif"}
!ll&&!rl&&r
29721837
defined $self->{"EXIF_DATA"} and length $self->{"EXIF_DATA"} > 16
!ll&&!rl&&r
27225255
$req->{"exif"} or $self->{"TAGS_FROM_FILE"} and not $self->{"EXCL_TAG_LOOKUP"}{"exif"}
l!l&&r!l&&!r
136218
$self->{"TAGS_FROM_FILE"} and not $self->{"EXCL_TAG_LOOKUP"}{"exif"}
!ll&&!rl&&r
218036
MC/DC80%4/5
defined $self->{"EXIF_DATA"} and length $self->{"EXIF_DATA"} > 16 and $req->{"exif"} || $self->{"TAGS_FROM_FILE"} && !$self->{"EXCL_TAG_LOOKUP"}{"exif"}
defined $self->{"EXIF_DATA"} length $self->{"EXIF_DATA"} > 16 $req->{"exif"} $self->{"TAGS_FROM_FILE"} not $self->{"EXCL_TAG_LOOKUP"}{"exif"}
Truth table83%5/6
A and B and C or D and not(E)
A= defined $self->{"EXIF_DATA"}B= length $self->{"EXIF_DATA"} > 16C= $req->{"exif"}D= $self->{"TAGS_FROM_FILE"}E= not $self->{"EXCL_TAG_LOOKUP"}{"exif"}
ABCDEresult
0XXXX0
10XXX0
1100X0
110100
111XX1
110111
3136 ($$req{exif} or
3137 # (not extracted normally, so check TAGS_FROM_FILE)
3138 ($$self{TAGS_FROM_FILE} and not $$self{EXCL_TAG_LOOKUP}{exif})))
3139 {
3140 37 $self->FoundTag('EXIF', $$self{EXIF_DATA});
3141 }
3142 552 ▶ unless ($reEntry) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($reEntry) 550 2 552
3143 550 $$self{PATH} = [ ]; # reset PATH
3144 550 $self->DoneExtract();
3145 # do our HTML dump if requested
3146 550 ▶ if ($$self{HTML_DUMP}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"HTML_DUMP"}) 0 550 550
3147 0 $raf->Seek(0, 2); # seek to end of file
3148 0 $$self{HTML_DUMP}->FinishTiffDump($self, $raf->Tell());
3149 0 my $pos = $$options{HtmlDumpBase};
3150 0 ▶ $pos = ($$self{FIRST_EXIF_POS} || 0) unless defined $pos;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $pos 0 0 0
Condition0%0/2
$self->{'FIRST_EXIF_POS'} || 0
l!l
00
MC/DC0%0/1
$self->{'FIRST_EXIF_POS'} || 0
$self->{'FIRST_EXIF_POS'}
Truth table0%0/2
A
A= $self->{'FIRST_EXIF_POS'}
Aresult
11
00
3151 0 ▶ my $dataPt = defined $$self{EXIF_DATA} ? \$$self{EXIF_DATA} : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'EXIF_DATA'} ? : 0 0 0
3152 0 ▶ undef $dataPt if defined $$self{EXIF_POS} and $pos != $$self{EXIF_POS};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"EXIF_POS"} and $pos != $self->{"EXIF_POS"} 0 0 0
Condition0%0/3
defined $self->{"EXIF_POS"} and $pos != $self->{"EXIF_POS"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{"EXIF_POS"} and $pos != $self->{"EXIF_POS"}
defined $self->{"EXIF_POS"} $pos != $self->{"EXIF_POS"}
Truth table0%0/3
A and B
A= defined $self->{"EXIF_POS"}B= $pos != $self->{"EXIF_POS"}
ABresult
0X0
100
111
3153 0 ▶ undef $dataPt if $$self{ExtendedEXIF}; # can't use EXIF block if not contiguous
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"ExtendedEXIF"} 0 0 0
3154 my $success = $$self{HTML_DUMP}->Print($raf, $dataPt, $pos,
3155 $$options{TextOut}, $$options{HtmlDump},
3156 0 ▶ $$self{FILENAME} ? "HTML Dump ($$self{FILENAME})" : 'HTML Dump');
Branch: 1 branch
BranchTrueFalseTotal
$self->{'FILENAME'} ? : 0 0 0
3157 0 ▶ $self->Warn("Error reading $$self{HTML_DUMP}{ERROR}") if $success < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $success < 0 0 0 0
3158 }
3159 }
3160 552 ▶ if ($filename) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename) 507 45 552
3161 507 $raf->Close(); # close the file if we opened it
3162 # process the resource fork as an embedded file on Mac filesystems
3163 507 ▶ if ($rsize and $$options{ExtractEmbedded}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rsize and $options->{"ExtractEmbedded"}) 0 507 507
Condition33%1/3
$rsize and $options->{"ExtractEmbedded"}
!ll&&!rl&&r
50700
MC/DC0%0/2
$rsize and $options->{"ExtractEmbedded"}
$rsize $options->{"ExtractEmbedded"}
Truth table33%1/3
A and B
A= $rsizeB= $options->{"ExtractEmbedded"}
ABresult
0X0
100
111
3164 0 local *RESOURCE_FILE;
3165 0 ▶ if ($self->Open(\*RESOURCE_FILE, "$filename/..namedfork/rsrc")) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->Open(\*RESOURCE_FILE, "$filename/..namedfork/rsrc")) { } 0 0 0
3166 0 $$self{DOC_NUM} = $$self{DOC_COUNT} + 1;
3167 0 $$self{IN_RESOURCE} = 1;
3168 0 $self->ExtractInfo(\*RESOURCE_FILE, { ReEntry => 1 });
3169 0 close RESOURCE_FILE;
3170 0 delete $$self{IN_RESOURCE};
3171 } else {
3172 0 $self->Warn('Error opening resource fork');
3173 }
3174 }
3175 }
3176 552 last; # (loop was a cheap "goto")
3177 }
3178  
3179 # Note: This should be the only tag generated after BuildCompositeTags,
3180 # and as such it can't be used in user-defined Composite tags
3181 552 ▶ @startTime and $self->FoundTag('ProcessingTime', Time::HiRes::tv_interval(\@startTime));
Branch: 1 branch
BranchTrueFalseTotal
@startTime and $self->FoundTag("ProcessingTime", Time::HiRes::tv_interval(\@startTime)) 61 491 552
3182  
3183 # add numbers to warnings with multiple occurrences
3184 552 ▶ if (%{$$self{WAS_WARNED}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (%{$self->{"WAS_WARNED"};}) 46 506 552
3185 46 my ($tag, $val) = ( 'Warning', $$self{VALUE} );
3186 46 ▶ for ($i=1; $$val{$tag}; ++$i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($val->{$tag}) 56 46 102
3187 56 my $n = $$self{WAS_WARNED}{$$val{$tag}};
3188 56 ▶ $$val{$tag} .= " [x$n]" if $n and $n > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $n and $n > 1 4 52 56
Condition66%2/3
$n and $n > 1
!ll&&!rl&&r
0524
MC/DC50%1/2
$n and $n > 1
$n $n > 1
Truth table66%2/3
A and B
A= $nB= $n > 1
ABresult
0X0
100
111
3189 56 $tag = "Warning ($i)";
3190 }
3191 }
3192 # restore original options
3193 552 ▶ %saveOptions and $$self{OPTIONS} = \%saveOptions;
Branch: 1 branch
BranchTrueFalseTotal
%saveOptions and $self->{"OPTIONS"} = \%saveOptions 12 540 552
3194  
3195 552 ▶ if ($reEntry) {
Branch: 1 branch
BranchTrueFalseTotal
if ($reEntry) { } 2 550 552
3196 # restore necessary members when exiting re-entrant code
3197 2 $$self{$_} = $$reEntry{$_} foreach keys %$reEntry;
3198 2 SetByteOrder($saveOrder);
3199 } else {
3200 # call cleanup routines if necessary
3201 550 ▶ if ($$self{Cleanup}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"Cleanup"}) 0 550 550
3202 0 &$_($self) foreach @{$$self{Cleanup}};
3203 0 delete $$self{Cleanup};
3204 }
3205 550 delete $$self{InExtract};
3206 }
3207  
3208 # ($type may be undef without an Error when processing sub-documents)
3209 552 ▶ return 0 if not defined $type or exists $$self{VALUE}{Error};
Branch: 1 branch
BranchTrueFalseTotal
if not defined $type or exists $self->{"VALUE"}{"Error"} 3 549 552
Condition66%2/3
not defined $type or exists $self->{"VALUE"}{"Error"}
l!l&&r!l&&!r
30549
MC/DC50%1/2
not defined $type or exists $self->{"VALUE"}{"Error"}
not defined $type exists $self->{"VALUE"}{"Error"}
Truth table66%2/3
not(A) or B
A= not defined $typeB= exists $self->{"VALUE"}{"Error"}
ABresult
1X1
011
000
3210 549 return 1;
3211 }
3212  
3213 #------------------------------------------------------------------------------
3214 # Get hash of extracted meta information
3215 # Inputs: 0) ExifTool object reference
3216 # 1-N) options hash reference, tag list reference or tag names
3217 # Returns: Reference to information hash
3218 # Notes: - pass an undefined value to avoid parsing arguments
3219 # - If groups are specified, first groups take precedence if duplicate
3220 # tags found but Duplicates option not set.
3221 # - tag names may end in '#' to extract ValueConv value
3222 sub GetInfo($;@)
3223 714 ▶{
Subroutine GetInfo: called CC=32 SCAR=34.7
Pod documented
3224 714 local $_;
3225 714 my $self = shift;
3226 714 my (%saveOptions, @saveMembers, @savedMembers);
3227  
3228 # save necessary members to allow GetInfo to be called from within ExtractInfo
3229 714 ▶ if ($$self{InExtract}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"InExtract"}) 4 710 714
3230 4 @saveMembers = qw(REQUESTED_TAGS REQ_TAG_LOOKUP IO_TAG_LIST);
3231 4 @savedMembers = @$self{@saveMembers};
3232 }
3233 714 ▶ unless (@_ and not defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@_ and not defined $_[0]) 175 539 714
Condition66%2/3
@_ and not defined $_[0]
!ll&&!rl&&r
0175539
MC/DC50%1/2
@_ and not defined $_[0]
@_ not defined $_[0]
Truth table66%2/3
A and not(B)
A= @_B= not defined $_[0]
ABresult
0X0
100
111
3234 175 %saveOptions = %{$$self{OPTIONS}}; # save original options
3235 # must set FILENAME so it isn't parsed from the arguments
3236 175 ▶ $$self{FILENAME} = '' unless defined $$self{FILENAME};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"FILENAME"} 125 50 175
3237 175 $self->ParseArguments(@_);
3238 }
3239  
3240 # get reference to list of tags for which we will return info
3241 714 my ($rtnTags, $byValue, $wildTags) = $self->SetFoundTags();
3242  
3243 # build hash of tag information
3244 714 my (%info, %ignored);
3245 714 ▶ my $conv = $$self{OPTIONS}{PrintConv} ? 'PrintConv' : 'ValueConv';
Branch: 1 branch
BranchTrueFalseTotal
$self->{'OPTIONS'}{'PrintConv'} ? : 665 49 714
3246 714 foreach (@$rtnTags) {
3247 36335 my $val = $self->GetValue($_, $conv);
3248 36335 ▶ defined $val or $ignored{$_} = 1, next;
Branch: 1 branch
BranchTrueFalseTotal
defined $val or $ignored{$_} = 1, next 35277 1058 36335
3249 35277 $info{$_} = $val;
3250 }
3251  
3252 # override specified tags with ValueConv value if necessary
3253 714 ▶ if (@$byValue) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$byValue) 4 710 714
3254 # first determine the number of times each non-ValueConv value is used
3255 4 my %nonVal;
3256 4 ▶ $nonVal{$_} = ($nonVal{$_} || 0) + 1 foreach @$rtnTags;
Condition100%2/2
$nonVal{$_} || 0
l!l
235
MC/DC100%1/1
$nonVal{$_} || 0
$nonVal{$_}
Truth table100%2/2
A
A= $nonVal{$_}
Aresult
11
00
3257 4 --$nonVal{$$rtnTags[$_]} foreach @$byValue;
3258 # loop through ValueConv tags, updating tag keys and returned values
3259 4 foreach (@$byValue) {
3260 25 my $tag = $$rtnTags[$_];
3261 25 my $val = $self->GetValue($tag, 'ValueConv');
3262 25 ▶ next unless defined $val;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $val 9 16 25
3263 16 my $vtag = $tag;
3264 # generate a new tag key like "Tag #" or "Tag #(1)"
3265 16 $vtag =~ s/( |$)/ #/;
3266 16 ▶ unless (defined $$self{VALUE}{$vtag}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"VALUE"}{$vtag}) 16 0 16
3267 16 $$self{VALUE}{$vtag} = $$self{VALUE}{$tag};
3268 16 $$self{TAG_INFO}{$vtag} = $$self{TAG_INFO}{$tag};
3269 16 $$self{TAG_EXTRA}{$vtag} = $$self{TAG_EXTRA}{$tag};
3270 16 $$self{FILE_ORDER}{$vtag} = $$self{FILE_ORDER}{$tag};
3271 # remove existing PrintConv entry unless we are using it too
3272 16 ▶ delete $info{$tag} unless $nonVal{$tag};
Branch: 1 branch
BranchTrueFalseTotal
unless $nonVal{$tag} 14 2 16
3273 }
3274 16 $$rtnTags[$_] = $vtag; # store ValueConv value with new tag key
3275 16 $info{$vtag} = $val; # return ValueConv value
3276 }
3277 }
3278  
3279 # remove ignored tags from the list
3280 714 ▶ my $reqTags = $$self{REQUESTED_TAGS} || [ ];
Condition50%1/2
$self->{'REQUESTED_TAGS'} || []
l!l
7140
MC/DC0%0/1
$self->{'REQUESTED_TAGS'} || []
$self->{'REQUESTED_TAGS'}
Truth table50%1/2
A
A= $self->{'REQUESTED_TAGS'}
Aresult
11
00
3281 714 ▶ if (%ignored) {
Branch: 1 branch
BranchTrueFalseTotal
if (%ignored) 427 287 714
3282 427 ▶ if (not @$reqTags) {
Branch: 2 branches
BranchTrueFalseTotal
if (not @$reqTags) { } 197 230 427
elsif (@$wildTags) { } 42 188 230
3283 197 my @goodTags;
3284 197 foreach (@$rtnTags) {
3285 22982 ▶ push @goodTags, $_ unless $ignored{$_};
Branch: 1 branch
BranchTrueFalseTotal
unless $ignored{$_} 22456 526 22982
3286 }
3287 197 $rtnTags = $$self{FOUND_TAGS} = \@goodTags;
3288 } elsif (@$wildTags) {
3289 # only remove tags specified by wildcard
3290 42 my @goodTags;
3291 42 my $i = 0;
3292 42 foreach (@$rtnTags) {
3293 392 ▶ if (@$wildTags and $i == $$wildTags[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$wildTags and $i == $wildTags->[0]) { } 231 161 392
Condition100%3/3
@$wildTags and $i == $wildTags->[0]
!ll&&!rl&&r
11051231
MC/DC100%2/2
@$wildTags and $i == $wildTags->[0]
@$wildTags $i == $wildTags->[0]
Truth table100%3/3
A and B
A= @$wildTagsB= $i == $wildTags->[0]
ABresult
0X0
100
111
3294 231 shift @$wildTags;
3295 231 ▶ push @goodTags, $_ unless $ignored{$_};
Branch: 1 branch
BranchTrueFalseTotal
unless $ignored{$_} 231 0 231
3296 } else {
3297 161 push @goodTags, $_;
3298 }
3299 392 ++$i;
3300 }
3301 42 $rtnTags = $$self{FOUND_TAGS} = \@goodTags;
3302 }
3303 }
3304  
3305 # return sorted tag list if provided with a list reference
3306 714 ▶ if ($$self{IO_TAG_LIST}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"IO_TAG_LIST"}) 10 704 714
3307 # use file order by default if no tags specified
3308 # (no such thing as 'Input' order in this case)
3309 10 my $sort = $$self{OPTIONS}{Sort};
3310 10 ▶ $sort = 'File' unless @$reqTags or ($sort and $sort ne 'Input');
Branch: 1 branch
BranchTrueFalseTotal
unless @$reqTags or $sort and $sort ne "Input" 3 7 10
Condition50%3/6
@$reqTags or $sort and $sort ne "Input"
l!l&&r!l&&!r
703
$sort and $sort ne "Input"
!ll&&!rl&&r
030
MC/DC33%1/3
@$reqTags or $sort and $sort ne "Input"
@$reqTags $sort $sort ne "Input"
Truth table50%2/4
A or B and C
A= @$reqTagsB= $sortC= $sort ne "Input"
ABCresult
1XX1
0111
00X0
0100
3311 # return tags in specified sort order
3312 10 @{$$self{IO_TAG_LIST}} = $self->GetTagList($rtnTags, $sort, $$self{OPTIONS}{Sort2});
3313 }
3314  
3315 # restore original options and member variables
3316 714 ▶ %saveOptions and $$self{OPTIONS} = \%saveOptions;
Branch: 1 branch
BranchTrueFalseTotal
%saveOptions and $self->{"OPTIONS"} = \%saveOptions 175 539 714
3317 714 ▶ @$self{@saveMembers} = @savedMembers if @saveMembers;
Branch: 1 branch
BranchTrueFalseTotal
if @saveMembers 4 710 714
3318  
3319 714 return \%info;
3320 }
3321  
3322 #------------------------------------------------------------------------------
3323 # Inputs: 0) ExifTool object reference
3324 # 1) [optional] reference to info hash or tag list ref (default is found tags)
3325 # 2) [optional] sort order ('File', 'Input', ...)
3326 # 3) [optional] secondary sort order
3327 # Returns: List of tags in specified order
3328 sub GetTagList($;$$$)
3329 462 ▶{
Subroutine GetTagList: called CC=28 SCAR=45.3
Pod documented
3330 462 local $_;
3331 462 my ($self, $info, $sort, $sort2) = @_;
3332  
3333 462 my $foundTags;
3334 462 ▶ if (ref $info eq 'HASH') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $info eq 'HASH') { } 451 11 462
elsif (ref $info eq 'ARRAY') { } 11 0 11
3335 451 my @tags = keys %$info;
3336 451 $foundTags = \@tags;
3337 } elsif (ref $info eq 'ARRAY') {
3338 11 $foundTags = $info;
3339 }
3340 462 my $fileOrder = $$self{FILE_ORDER};
3341  
3342 462 ▶ if ($foundTags) {
Branch: 1 branch
BranchTrueFalseTotal
if ($foundTags) { } 462 0 462
3343 # make sure a FILE_ORDER entry exists for all tags
3344 # (note: already generated bogus entries for FOUND_TAGS case below)
3345 462 foreach (@$foundTags) {
3346 24957 ▶ next if defined $$fileOrder{$_};
Branch: 1 branch
BranchTrueFalseTotal
if defined $fileOrder->{$_} 24957 0 24957
3347 0 $$fileOrder{$_} = 999;
3348 }
3349 } else {
3350 0 ▶ $sort = $info if $info and not $sort;
Branch: 1 branch
BranchTrueFalseTotal
if $info and not $sort 0 0 0
Condition0%0/3
$info and not $sort
!ll&&!rl&&r
000
MC/DC0%0/2
$info and not $sort
$info not $sort
Truth table0%0/3
A and not(B)
A= $infoB= not $sort
ABresult
0X0
100
111
3351 0 ▶ $foundTags = $$self{FOUND_TAGS} || $self->SetFoundTags() or return undef;
Branch: 1 branch
BranchTrueFalseTotal
$foundTags = $self->{"FOUND_TAGS"} || $self->SetFoundTags or return undef 0 0 0
Condition0%0/3
$self->{'FOUND_TAGS'} || $self->SetFoundTags
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{'FOUND_TAGS'} || $self->SetFoundTags
$self->{'FOUND_TAGS'} $self->SetFoundTags
Truth table0%0/3
A || B
A= $self->{'FOUND_TAGS'}B= $self->SetFoundTags
ABresult
1X1
011
000
3352 }
3353 462 ▶ $sort or $sort = $$self{OPTIONS}{Sort};
Branch: 1 branch
BranchTrueFalseTotal
$sort or $sort = $self->{"OPTIONS"}{"Sort"} 446 16 462
3354  
3355 # return original list if no sort order specified
3356 462 ▶ return @$foundTags unless $sort and $sort ne 'Input';
Branch: 1 branch
BranchTrueFalseTotal
unless $sort and $sort ne "Input" 23 439 462
Condition66%2/3
$sort and $sort ne "Input"
!ll&&!rl&&r
023439
MC/DC50%1/2
$sort and $sort ne "Input"
$sort $sort ne "Input"
Truth table66%2/3
A and B
A= $sortB= $sort ne "Input"
ABresult
0X0
100
111
3357  
3358 439 ▶ if ($sort eq 'Tag' or $sort eq 'Alpha') {
Branch: 3 branches
BranchTrueFalseTotal
if ($sort eq 'Tag' or $sort eq 'Alpha') { } 0 439 439
elsif ($sort =~ /^Group(\d*(:\d+)*)/) { } 436 3 439
elsif ($sort eq 'Descr') { } 0 3 3
Condition33%1/3
$sort eq "Tag" or $sort eq "Alpha"
l!l&&r!l&&!r
00439
MC/DC0%0/2
$sort eq "Tag" or $sort eq "Alpha"
$sort eq "Tag" $sort eq "Alpha"
Truth table33%1/3
A or B
A= $sort eq "Tag"B= $sort eq "Alpha"
ABresult
1X1
011
000
3359 0 return sort @$foundTags;
3360 } elsif ($sort =~ /^Group(\d*(:\d+)*)/) {
3361 436 ▶ my $family = $1 || 0;
Condition50%1/2
$1 || 0
l!l
0436
MC/DC0%0/1
$1 || 0
$1
Truth table50%1/2
A
A= $1
Aresult
11
00
3362 # want to maintain a basic file order with the groups
3363 # ordered in the way they appear in the file
3364 436 my (%groupCount, %groupOrder);
3365 436 my $numGroups = 0;
3366 436 my $tag;
3367 436 foreach $tag (sort { $$fileOrder{$a} <=> $$fileOrder{$b} } @$foundTags) {
3368 23997 my $group = $self->GetGroup($tag, $family);
3369 23997 my $num = $groupCount{$group};
3370 23997 ▶ $num or $num = $groupCount{$group} = ++$numGroups;
Branch: 1 branch
BranchTrueFalseTotal
$num or $num = ($groupCount{$group} = ++$numGroups) 22440 1557 23997
3371 23997 $groupOrder{$tag} = $num;
3372 }
3373 436 ▶ $sort2 or $sort2 = $$self{OPTIONS}{Sort2};
Branch: 1 branch
BranchTrueFalseTotal
$sort2 or $sort2 = $self->{"OPTIONS"}{"Sort2"} 0 436 436
3374 436 ▶ if ($sort2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sort2) 436 0 436
3375 436 ▶ if ($sort2 eq 'Tag' or $sort2 eq 'Alpha') {
Branch: 2 branches
BranchTrueFalseTotal
if ($sort2 eq 'Tag' or $sort2 eq 'Alpha') { } 0 436 436
elsif ($sort2 eq 'Descr') { } 0 436 436
Condition33%1/3
$sort2 eq "Tag" or $sort2 eq "Alpha"
l!l&&r!l&&!r
00436
MC/DC0%0/2
$sort2 eq "Tag" or $sort2 eq "Alpha"
$sort2 eq "Tag" $sort2 eq "Alpha"
Truth table33%1/3
A or B
A= $sort2 eq "Tag"B= $sort2 eq "Alpha"
ABresult
1X1
011
000
3376 0 ▶ return sort { $groupOrder{$a} <=> $groupOrder{$b} or $a cmp $b } @$foundTags;
Condition0%0/3
$groupOrder{$a} <=> $groupOrder{$b} || $a cmp $b
l!l&&r!l&&!r
000
MC/DC0%0/2
$groupOrder{$a} <=> $groupOrder{$b} || $a cmp $b
$groupOrder{$a} <=> $groupOrder{$b} $a cmp $b
Truth table0%0/3
A || B
A= $groupOrder{$a} <=> $groupOrder{$b}B= $a cmp $b
ABresult
1X1
011
000
3377 } elsif ($sort2 eq 'Descr') {
3378 0 my $desc = $self->GetDescriptions($foundTags);
3379 0 return sort { $groupOrder{$a} <=> $groupOrder{$b} or
3380 0 ▶ $$desc{$a} cmp $$desc{$b} } @$foundTags;
Condition0%0/3
$groupOrder{$a} <=> $groupOrder{$b} || $desc->{$a} cmp $desc->{$b}
l!l&&r!l&&!r
000
MC/DC0%0/2
$groupOrder{$a} <=> $groupOrder{$b} || $desc->{$a} cmp $desc->{$b}
$groupOrder{$a} <=> $groupOrder{$b} $desc->{$a} cmp $desc->{$b}
Truth table0%0/3
A || B
A= $groupOrder{$a} <=> $groupOrder{$b}B= $desc->{$a} cmp $desc->{$b}
ABresult
1X1
011
000
3381 }
3382 }
3383 436 return sort { $groupOrder{$a} <=> $groupOrder{$b} or
3384 133761 ▶ $$fileOrder{$a} <=> $$fileOrder{$b} } @$foundTags;
Condition66%2/3
$groupOrder{$a} <=> $groupOrder{$b} || $fileOrder->{$a} <=> $fileOrder->{$b}
l!l&&r!l&&!r
36362973990
MC/DC0%0/2
$groupOrder{$a} <=> $groupOrder{$b} || $fileOrder->{$a} <=> $fileOrder->{$b}
$groupOrder{$a} <=> $groupOrder{$b} $fileOrder->{$a} <=> $fileOrder->{$b}
Truth table66%2/3
A || B
A= $groupOrder{$a} <=> $groupOrder{$b}B= $fileOrder->{$a} <=> $fileOrder->{$b}
ABresult
1X1
011
000
3385 } elsif ($sort eq 'Descr') {
3386 0 my $desc = $self->GetDescriptions($foundTags);
3387 0 return sort { $$desc{$a} cmp $$desc{$b} } @$foundTags;
3388 } else {
3389 3 return sort { $$fileOrder{$a} <=> $$fileOrder{$b} } @$foundTags;
3390 }
3391 }
3392  
3393 #------------------------------------------------------------------------------
3394 # Get list of found tags in specified sort order
3395 # Inputs: 0) ExifTool object reference, 1) sort order ('File', 'Input', ...)
3396 # 2) secondary sort order
3397 # Returns: List of tag keys in specified order
3398 # Notes: If not specified, sort order is taken from OPTIONS
3399 sub GetFoundTags($;$$)
3400 1 ▶{
Subroutine GetFoundTags: called CC=3 SCAR=12.0
Pod documented
3401 1 local $_;
3402 1 my ($self, $sort, $sort2) = @_;
3403 1 ▶ my $foundTags = $$self{FOUND_TAGS} || $self->SetFoundTags() or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $foundTags = $self->{"FOUND_TAGS"} || $self->SetFoundTags or return undef 1 0 1
Condition33%1/3
$self->{'FOUND_TAGS'} || $self->SetFoundTags
l!l&&r!l&&!r
100
MC/DC0%0/2
$self->{'FOUND_TAGS'} || $self->SetFoundTags
$self->{'FOUND_TAGS'} $self->SetFoundTags
Truth table33%1/3
A || B
A= $self->{'FOUND_TAGS'}B= $self->SetFoundTags
ABresult
1X1
011
000
3404 1 return $self->GetTagList($foundTags, $sort, $sort2);
3405 }
3406  
3407 #------------------------------------------------------------------------------
3408 # Get list of requested tags
3409 # Inputs: 0) ExifTool object reference
3410 # Returns: List of requested tag keys
3411 sub GetRequestedTags($)
3412 2 ▶{
Subroutine GetRequestedTags: called CC=1 SCAR=0.0
Pod documented
3413 2 local $_;
3414 2 return @{$_[0]{REQUESTED_TAGS}};
3415 }
3416  
3417 #------------------------------------------------------------------------------
3418 # Get tag value
3419 # Inputs: 0) ExifTool object reference
3420 # 1) tag key or tag name with optional group names (case sensitive)
3421 # (or flattened tagInfo for getting field values, not part of public API)
3422 # 2) [optional] Value type: PrintConv, ValueConv, Both, Raw, Bin or Rational, the
3423 # default is PrintConv or ValueConv, depending on the PrintConv option setting
3424 # 3) raw field value (not part of public API)
3425 # Returns: Scalar context: tag value or undefined
3426 # List context: list of values or empty list
3427 sub GetValue($$;$)
3428 54526 ▶{
Subroutine GetValue: called CC=105 SCAR=51.3
Pod documented
3429 54526 local $_;
3430 54526 my ($self, $tag, $type) = @_; # plus: ($fieldValue)
3431 54526 my (@convTypes, $tagInfo, $valueConv, $both);
3432 54526 my $rawValue = $$self{VALUE};
3433  
3434 # get specific tag key if tag has a group name
3435 54526 ▶ if ($tag =~ /^(.*):(.+)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag =~ /^(.*):(.+)/) 0 54526 54526
3436 0 my ($gp, $tg) = ($1, $2);
3437 0 my ($i, $key, @keys);
3438 # build list of tag keys in the order of priority (no index
3439 # is top priority, otherwise higher index is higher priority)
3440 0 ▶ for ($key=$tg, $i=$$self{DUPL_TAG}{$tg} || 0; ; --$i) {
Condition0%0/2
$self->{'DUPL_TAG'}{$tg} || 0
l!l
00
MC/DC0%0/1
$self->{'DUPL_TAG'}{$tg} || 0
$self->{'DUPL_TAG'}{$tg}
Truth table0%0/2
A
A= $self->{'DUPL_TAG'}{$tg}
Aresult
11
00
3441 0 ▶ push @keys, $key if defined $$rawValue{$key};
Branch: 1 branch
BranchTrueFalseTotal
if defined $rawValue->{$key} 0 0 0
3442 0 ▶ last if $i <= 0;
Branch: 1 branch
BranchTrueFalseTotal
if $i <= 0 0 0 0
3443 0 $key = "$tg ($i)";
3444 }
3445 0 ▶ if (@keys) {
Branch: 1 branch
BranchTrueFalseTotal
if (@keys) 0 0 0
3446 0 $key = $self->GroupMatches($gp, \@keys);
3447 0 ▶ $tag = $key if $key;
Branch: 1 branch
BranchTrueFalseTotal
if $key 0 0 0
3448 }
3449 }
3450 # figure out what conversions to do
3451 54526 ▶ if ($type) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type) { } 54499 27 54526
3452 54499 ▶ return $$self{TAG_EXTRA}{$tag}{Rational} if $type eq 'Rational';
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "Rational" 0 54499 54499
3453 54499 ▶ return $$self{TAG_EXTRA}{$tag}{BinVal} if $type eq 'Bin';
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "Bin" 0 54499 54499
3454 } else {
3455 27 ▶ $type = $$self{OPTIONS}{PrintConv} ? 'PrintConv' : 'ValueConv';
Branch: 1 branch
BranchTrueFalseTotal
$self->{'OPTIONS'}{'PrintConv'} ? : 27 0 27
3456 }
3457  
3458 # start with the raw value
3459 54526 my $value = $$rawValue{$tag};
3460 54526 ▶ if (not defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $value) { } 10441 44085 54526
3461 10441 ▶ return () unless ref $tag;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $tag 10247 194 10441
3462 # get the value of a structure field
3463 194 $tagInfo = $tag;
3464 194 $tag = $$tagInfo{Name};
3465 194 $value = $_[3];
3466 # (note: type "Both" is not allowed for structure fields)
3467 194 ▶ if ($type ne 'Raw') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type ne "Raw") 194 0 194
3468 194 push @convTypes, 'ValueConv';
3469 194 ▶ push @convTypes, 'PrintConv' unless $type eq 'ValueConv';
Branch: 1 branch
BranchTrueFalseTotal
unless $type eq "ValueConv" 170 24 194
3470 }
3471 } else {
3472 44085 $tagInfo = $$self{TAG_INFO}{$tag};
3473 44085 ▶ if ($$tagInfo{Struct} and ref $value) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tagInfo->{"Struct"} and ref $value) 53 44032 44085
Condition66%2/3
$tagInfo->{"Struct"} and ref $value
!ll&&!rl&&r
44032053
MC/DC50%1/2
$tagInfo->{"Struct"} and ref $value
$tagInfo->{"Struct"} ref $value
Truth table66%2/3
A and B
A= $tagInfo->{"Struct"}B= ref $value
ABresult
0X0
100
111
3474 # must load XMPStruct.pl just in case (should already be loaded if
3475 # a structure was extracted, but we could also arrive here if a simple
3476 # list of values was stored incorrectly in a Struct tag)
3477 53 require 'Image/ExifTool/XMPStruct.pl';
3478 # convert strucure field values
3479 53 ▶ unless ($type eq 'Both') {
Branch: 1 branch
BranchTrueFalseTotal
unless ($type eq "Both") 48 5 53
3480 # (note: ConvertStruct handles the filtering and escaping too if necessary)
3481 48 return Image::ExifTool::XMP::ConvertStruct($self,$tagInfo,$value,$type);
3482 }
3483 5 $valueConv = Image::ExifTool::XMP::ConvertStruct($self,$tagInfo,$value,'ValueConv');
3484 5 $value = Image::ExifTool::XMP::ConvertStruct($self,$tagInfo,$value,'PrintConv');
3485 # (must not save these in $$self{BOTH} because the values may have been escaped)
3486 5 return ($valueConv, $value);
3487 }
3488 44032 ▶ if ($type ne 'Raw') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type ne "Raw") 44032 0 44032
3489 # use values we calculated already if we stored them
3490 44032 $both = $$self{BOTH}{$tag};
3491 44032 ▶ if ($both) {
Branch: 1 branch
BranchTrueFalseTotal
if ($both) { } 6585 37447 44032
3492 6585 ▶ if ($type eq 'PrintConv') {
Branch: 2 branches
BranchTrueFalseTotal
if ($type eq 'PrintConv') { } 2294 4291 6585
elsif ($type eq 'ValueConv') { } 89 4202 4291
3493 2294 $value = $$both[1];
3494 } elsif ($type eq 'ValueConv') {
3495 89 $value = $$both[0];
3496 89 ▶ $value = $$both[1] unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 34 55 89
3497 } else {
3498 4202 ($valueConv, $value) = @$both;
3499 }
3500 } else {
3501 37447 push @convTypes, 'ValueConv';
3502 37447 ▶ push @convTypes, 'PrintConv' unless $type eq 'ValueConv';
Branch: 1 branch
BranchTrueFalseTotal
unless $type eq "ValueConv" 35782 1665 37447
3503 }
3504 }
3505 }
3506  
3507 # do the conversions
3508 44226 my (@val, @prt, @raw, $convType);
3509 44226 foreach $convType (@convTypes) {
3510 # don't convert a scalar reference or structure
3511 72474 ▶ last if ref $value eq 'SCALAR' and not $$tagInfo{ConvertBinary};
Branch: 1 branch
BranchTrueFalseTotal
if ref $value eq "SCALAR" and not $tagInfo->{"ConvertBinary"} 665 71809 72474
Condition66%2/3
ref $value eq "SCALAR" and not $tagInfo->{"ConvertBinary"}
!ll&&!rl&&r
718090665
MC/DC50%1/2
ref $value eq "SCALAR" and not $tagInfo->{"ConvertBinary"}
ref $value eq "SCALAR" not $tagInfo->{"ConvertBinary"}
Truth table66%2/3
A and not(B)
A= ref $value eq "SCALAR"B= not $tagInfo->{"ConvertBinary"}
ABresult
0X0
100
111
3512 71809 my $conv = $$tagInfo{$convType};
3513 71809 ▶ unless (defined $conv) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $conv) 46874 24935 71809
3514 46874 ▶ if ($convType eq 'ValueConv') {
Branch: 1 branch
BranchTrueFalseTotal
if ($convType eq 'ValueConv') { } 29778 17096 46874
3515 29778 ▶ next unless $$tagInfo{Binary};
Branch: 1 branch
BranchTrueFalseTotal
unless $tagInfo->{"Binary"} 29363 415 29778
3516 415 $conv = '\$val'; # return scalar reference for binary values
3517 } else {
3518 # use PRINT_CONV from tag table if PrintConv doesn't exist
3519 17096 ▶ next unless defined($conv = $$tagInfo{Table}{PRINT_CONV});
Branch: 1 branch
BranchTrueFalseTotal
unless defined($conv = $tagInfo->{"Table"}{"PRINT_CONV"}) 16888 208 17096
3520 208 ▶ next if exists $$tagInfo{$convType};
Branch: 1 branch
BranchTrueFalseTotal
if exists $tagInfo->{$convType} 49 159 208
3521 }
3522 }
3523 # save old ValueConv value if we want Both
3524 25509 ▶ $valueConv = $value if $type eq 'Both' and $convType eq 'PrintConv';
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "Both" and $convType eq "PrintConv" 2150 23359 25509
Condition100%3/3
$type eq "Both" and $convType eq "PrintConv"
!ll&&!rl&&r
2154518142150
MC/DC100%2/2
$type eq "Both" and $convType eq "PrintConv"
$type eq "Both" $convType eq "PrintConv"
Truth table100%3/3
A and B
A= $type eq "Both"B= $convType eq "PrintConv"
ABresult
0X0
100
111
3525 25509 my ($i, $val, $vals, @values, $convList);
3526 # split into list if conversion is an array
3527 25509 ▶ if (ref $conv eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $conv eq "ARRAY") 125 25384 25509
3528 125 $convList = $conv;
3529 125 $conv = $$convList[0];
3530 125 ▶ my @valList = (ref $value eq 'ARRAY') ? @$value : split ' ', $value;
Branch: 1 branch
BranchTrueFalseTotal
ref $value eq 'ARRAY' ? : 0 125 125
3531 # reorganize list if specified (Note: The writer currently doesn't
3532 # relist values, so they may be grouped but the order must not change)
3533 125 my $relist = $$tagInfo{Relist};
3534 125 ▶ if ($relist) {
Branch: 1 branch
BranchTrueFalseTotal
if ($relist) { } 7 118 125
3535 7 my (@newList, $oldIndex);
3536 7 foreach $oldIndex (@$relist) {
3537 14 my ($newVal, @join);
3538 14 ▶ if (ref $oldIndex) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $oldIndex) { } 7 7 14
3539 7 foreach (@$oldIndex) {
3540 16 ▶ push @join, $valList[$_] if defined $valList[$_];
Branch: 1 branch
BranchTrueFalseTotal
if defined $valList[$_] 16 0 16
3541 }
3542 7 ▶ $newVal = join(' ', @join) if @join;
Branch: 1 branch
BranchTrueFalseTotal
if @join 7 0 7
3543 } else {
3544 7 $newVal = $valList[$oldIndex];
3545 }
3546 14 ▶ push @newList, $newVal if defined $newVal;
Branch: 1 branch
BranchTrueFalseTotal
if defined $newVal 12 2 14
3547 }
3548 7 $value = \@newList;
3549 } else {
3550 118 $value = \@valList;
3551 }
3552 125 ▶ return () unless @$value;
Branch: 1 branch
BranchTrueFalseTotal
unless @$value 0 125 125
3553 }
3554 # initialize array so we can iterate over values in list
3555 25509 ▶ if (ref $value eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value eq 'ARRAY') { } 157 25352 25509
3556 157 ▶ if (defined $$tagInfo{RawJoin}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $tagInfo->{'RawJoin'}) { } 7 150 157
3557 7 $val = join ' ', @$value;
3558 } else {
3559 150 $i = 0;
3560 150 $vals = $value;
3561 150 $val = $$vals[0];
3562 }
3563 } else {
3564 25352 $val = $value;
3565 }
3566 # loop through all values in list
3567 25509 for (;;) {
3568 25730 ▶ if (defined $conv) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $conv) { } 25711 19 25730
3569 # get values of required tags if this is a Composite tag
3570 25711 ▶ if (ref $val eq 'HASH' and not @val) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $val eq "HASH" and not @val) 2983 22728 25711
Condition66%2/3
ref $val eq "HASH" and not @val
!ll&&!rl&&r
2272802983
MC/DC50%1/2
ref $val eq "HASH" and not @val
ref $val eq "HASH" not @val
Truth table66%2/3
A and not(B)
A= ref $val eq "HASH"B= not @val
ABresult
0X0
100
111
3571 # disable escape of source values so we don't double escape them
3572 2983 my $oldEscape = $$self{ESCAPE_PROC};
3573 2983 delete $$self{ESCAPE_PROC};
3574 # temporarily delete filter so it isn't applied to the Require'd values
3575 2983 my $oldFilter = $$self{OPTIONS}{Filter};
3576 2983 delete $$self{OPTIONS}{Filter};
3577 2983 foreach (keys %$val) {
3578 17398 ▶ next unless defined $$val{$_};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $val->{$_} 0 17398 17398
3579 17398 $raw[$_] = $$rawValue{$$val{$_}};
3580 17398 ($val[$_], $prt[$_]) = $self->GetValue($$val{$_}, 'Both');
3581 17398 ▶ next if defined $val[$_] or not $$tagInfo{Require}{$_};
Branch: 1 branch
BranchTrueFalseTotal
if defined $val[$_] or not $tagInfo->{"Require"}{$_} 17013 385 17398
Condition100%3/3
defined $val[$_] or not $tagInfo->{"Require"}{$_}
l!l&&r!l&&!r
76449369385
MC/DC100%2/2
defined $val[$_] or not $tagInfo->{"Require"}{$_}
defined $val[$_] not $tagInfo->{"Require"}{$_}
Truth table100%3/3
A or not(B)
A= defined $val[$_]B= not $tagInfo->{"Require"}{$_}
ABresult
1X1
011
000
3582 385 ▶ $$self{OPTIONS}{Filter} = $oldFilter if defined $oldFilter;
Branch: 1 branch
BranchTrueFalseTotal
if defined $oldFilter 0 385 385
3583 385 $$self{ESCAPE_PROC} = $oldEscape;
3584 385 return ();
3585 }
3586 2598 ▶ $$self{OPTIONS}{Filter} = $oldFilter if defined $oldFilter;
Branch: 1 branch
BranchTrueFalseTotal
if defined $oldFilter 7 2591 2598
3587 2598 $$self{ESCAPE_PROC} = $oldEscape;
3588 # set $val to $val[0], or \@val for a CODE ref conversion
3589 2598 ▶ $val = ref $conv eq 'CODE' ? \@val : $val[0];
Branch: 1 branch
BranchTrueFalseTotal
ref $conv eq 'CODE' ? : 0 2598 2598
3590 }
3591 25326 ▶ if (ref $conv eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $conv eq 'HASH') { } 7778 17548 25326
3592 # look up converted value in hash
3593 7778 ▶ if (not defined($value = $$conv{$val})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined($value = $conv->{$val})) 464 7314 7778
3594 464 ▶ if ($$conv{BITMASK}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conv->{'BITMASK'}) { } 130 334 464
3595 130 $value = DecodeBits($val, $$conv{BITMASK}, $$tagInfo{BitsPerWord});
3596 } else {
3597 # use alternate conversion routine if available
3598 334 ▶ if ($$conv{OTHER}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conv->{"OTHER"}) 258 76 334
3599 258 local $SIG{'__WARN__'} = \&SetWarning;
3600 258 undef $evalWarning;
3601 258 $value = &{$$conv{OTHER}}($val, undef, $conv);
3602 258 ▶ $self->Warn("$convType $tag: " . CleanWarning()) if $evalWarning;
Branch: 1 branch
BranchTrueFalseTotal
if $Image::ExifTool::evalWarning 0 258 258
3603 }
3604 334 ▶ if (not defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $value) 79 255 334
3605 79 ▶ if ($$tagInfo{PrintHex} and defined $val and IsInt($val) and
Branch: 1 branch
BranchTrueFalseTotal
if ($tagInfo->{'PrintHex'} and defined $val and &IsInt($val) and $convType eq 'PrintConv') { } 0 79 79
Condition55%5/9
$tagInfo->{"PrintHex"} and defined $val and &IsInt($val) and $convType eq "PrintConv"
!ll&&!rl&&r
7900
$tagInfo->{"PrintHex"} and defined $val and &IsInt($val)
!ll&&!rl&&r
7810
$tagInfo->{"PrintHex"} and defined $val
!ll&&!rl&&r
7801
MC/DC0%0/4
$tagInfo->{"PrintHex"} and defined $val and &IsInt($val) and $convType eq "PrintConv"
$tagInfo->{"PrintHex"} defined $val &IsInt($val) $convType eq "PrintConv"
Truth table40%2/5
A and B and C and D
A= $tagInfo->{"PrintHex"}B= defined $valC= &IsInt($val)D= $convType eq "PrintConv"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
3606 $convType eq 'PrintConv')
3607 {
3608 0 $value = sprintf('Unknown (0x%x)',$val);
3609 } else {
3610 79 $value = "Unknown ($val)";
3611 }
3612 }
3613 }
3614 }
3615 # override with our localized language PrintConv if available
3616 7778 my $tmp;
3617 7778 ▶ if ($$self{CUR_LANG} and $convType eq 'PrintConv' and
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"CUR_LANG"} and $convType eq "PrintConv" and ref($tmp = $self->{"CUR_LANG"}{$tagInfo->{"Name"}}) eq "HASH" and $tmp = $tmp->{"PrintConv"}) 261 7517 7778
Condition77%7/9
$self->{"CUR_LANG"} and $convType eq "PrintConv" and ref($tmp = $self->{"CUR_LANG"}{$tagInfo->{"Name"}}) eq "HASH" and $tmp = $tmp->{"PrintConv"}
!ll&&!rl&&r
75170261
$self->{"CUR_LANG"} and $convType eq "PrintConv" and ref($tmp = $self->{"CUR_LANG"}{$tagInfo->{"Name"}}) eq "HASH"
!ll&&!rl&&r
747245261
$self->{"CUR_LANG"} and $convType eq "PrintConv"
!ll&&!rl&&r
74720306
MC/DC50%2/4
$self->{"CUR_LANG"} and $convType eq "PrintConv" and ref($tmp = $self->{"CUR_LANG"}{$tagInfo->{"Name"}}) eq "HASH" and $tmp = $tmp->{"PrintConv"}
$self->{"CUR_LANG"} $convType eq "PrintConv" ref($tmp = $self->{"CUR_LANG"}{$tagInfo->{"Name"}}) eq "HASH" $tmp = $tmp->{"PrintConv"}
Truth table60%3/5
A and B and C and D
A= $self->{"CUR_LANG"}B= $convType eq "PrintConv"C= ref($tmp = $self->{"CUR_LANG"}{$tagInfo->{"Name"}}) eq "HASH"D= $tmp = $tmp->{"PrintConv"}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
3618 # (no need to check for lang-alt tag names -- they won't have a PrintConv)
3619 ref($tmp = $$self{CUR_LANG}{$$tagInfo{Name}}) eq 'HASH' and
3620 ($tmp = $$tmp{PrintConv}))
3621 {
3622 261 ▶ if ($$conv{BITMASK} and not defined $$conv{$val}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($conv->{'BITMASK'} and not defined $conv->{$val}) { } 0 261 261
elsif (defined($tmp = $tmp->{$value})) { } 213 48 261
Condition33%1/3
$conv->{"BITMASK"} and not defined $conv->{$val}
!ll&&!rl&&r
26100
MC/DC0%0/2
$conv->{"BITMASK"} and not defined $conv->{$val}
$conv->{"BITMASK"} not defined $conv->{$val}
Truth table33%1/3
A and not(B)
A= $conv->{"BITMASK"}B= not defined $conv->{$val}
ABresult
0X0
100
111
3623 0 my @vals = split ', ', $value;
3624 0 foreach (@vals) {
3625 0 ▶ $_ = $$tmp{$_} if defined $$tmp{$_};
Branch: 1 branch
BranchTrueFalseTotal
if defined $tmp->{$_} 0 0 0
3626 }
3627 0 $value = join ', ', @vals;
3628 } elsif (defined($tmp = $$tmp{$value})) {
3629 213 $value = $self->Decode($tmp, 'UTF8');
3630 }
3631 }
3632 } else {
3633 # call subroutine or do eval to convert value
3634 17548 local $SIG{'__WARN__'} = \&SetWarning;
3635 17548 undef $evalWarning;
3636 17548 ▶ if (ref $conv eq 'CODE') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $conv eq 'CODE') { } 1283 16265 17548
3637 1283 $value = &$conv($val, $self);
3638 } else {
3639 #### eval ValueConv/PrintConv ($val, $self, @val, @prt, @raw)
3640 16265 $value = eval $conv;
3641 16265 ▶ $@ and $evalWarning = $@;
Branch: 1 branch
BranchTrueFalseTotal
$@ and $Image::ExifTool::evalWarning = $@ 0 16265 16265
3642 }
3643 17548 ▶ $self->Warn("$convType $tag: " . CleanWarning()) if $evalWarning;
Branch: 1 branch
BranchTrueFalseTotal
if $Image::ExifTool::evalWarning 0 17548 17548
3644 }
3645 } else {
3646 19 $value = $val;
3647 }
3648 25345 ▶ last unless $vals;
Branch: 1 branch
BranchTrueFalseTotal
unless $vals 24974 371 25345
3649 # must store a separate copy of each binary data value in the list
3650 371 ▶ if (ref $value eq 'SCALAR') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value eq "SCALAR") 3 368 371
3651 3 my $tval = $$value;
3652 3 $value = \$tval;
3653 }
3654 # save this converted value and step to next value in list
3655 371 ▶ push @values, $value if defined $value;
Branch: 1 branch
BranchTrueFalseTotal
if defined $value 371 0 371
3656 371 ▶ if (++$i >= scalar(@$vals)) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$i >= scalar @$vals) 150 221 371
3657 150 ▶ $value = \@values if @values;
Branch: 1 branch
BranchTrueFalseTotal
if @values 150 0 150
3658 150 last;
3659 }
3660 221 $val = $$vals[$i];
3661 221 ▶ if ($convList) {
Branch: 1 branch
BranchTrueFalseTotal
if ($convList) 133 88 221
3662 133 my $nextConv = $$convList[$i];
3663 133 ▶ if ($nextConv and $nextConv eq 'REPEAT') {
Branch: 1 branch
BranchTrueFalseTotal
if ($nextConv and $nextConv eq 'REPEAT') { } 0 133 133
Condition66%2/3
$nextConv and $nextConv eq "REPEAT"
!ll&&!rl&&r
151180
MC/DC0%0/2
$nextConv and $nextConv eq "REPEAT"
$nextConv $nextConv eq "REPEAT"
Truth table66%2/3
A and B
A= $nextConvB= $nextConv eq "REPEAT"
ABresult
0X0
100
111
3664 0 undef $convList;
3665 } else {
3666 133 $conv = $nextConv;
3667 }
3668 }
3669 }
3670 # return undefined now if no value
3671 25124 ▶ return () unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 576 24548 25124
3672 # join back into single value if split for conversion list
3673 24548 ▶ if ($convList and ref $value eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if ($convList and ref $value eq "ARRAY") 125 24423 24548
Condition66%2/3
$convList and ref $value eq "ARRAY"
!ll&&!rl&&r
244230125
MC/DC50%1/2
$convList and ref $value eq "ARRAY"
$convList ref $value eq "ARRAY"
Truth table66%2/3
A and B
A= $convListB= ref $value eq "ARRAY"
ABresult
0X0
100
111
3674 125 ▶ $value = join($convType eq 'PrintConv' ? '; ' : ' ', @$value);
Branch: 1 branch
BranchTrueFalseTotal
$convType eq 'PrintConv' ? : 117 8 125
3675 }
3676 }
3677 43265 ▶ if ($type eq 'Both') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "Both") 7639 35626 43265
3678 # save both (unescaped) values because we often need them again
3679 # (Composite tags need "Both" and often Require one tag for various Composite tags)
3680 7639 ▶ $$self{BOTH}{$tag} = [ $valueConv, $value ] unless $both;
Branch: 1 branch
BranchTrueFalseTotal
unless $both 3437 4202 7639
3681 # escape values if necessary
3682 7639 ▶ if ($$self{ESCAPE_PROC}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'ESCAPE_PROC'}) { } 0 7639 7639
elsif (not defined $valueConv) { } 3817 3822 7639
3683 0 DoEscape($value, $$self{ESCAPE_PROC});
3684 0 ▶ if (defined $valueConv) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $valueConv) { } 0 0 0
3685 0 DoEscape($valueConv, $$self{ESCAPE_PROC});
3686 } else {
3687 0 $valueConv = $value;
3688 }
3689 } elsif (not defined $valueConv) {
3690 # $valueConv is undefined if there was no print conversion done
3691 3817 $valueConv = $value;
3692 }
3693 7639 $self->Filter($$self{OPTIONS}{Filter}, \$value);
3694 # return Both values as a list (ValueConv, PrintConv)
3695 7639 return ($valueConv, $value);
3696 }
3697 # escape value if necessary
3698 35626 ▶ DoEscape($value, $$self{ESCAPE_PROC}) if $$self{ESCAPE_PROC};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"ESCAPE_PROC"} 163 35463 35626
3699  
3700 # filter if necessary
3701 35626 ▶ $self->Filter($$self{OPTIONS}{Filter}, \$value) if $$self{OPTIONS}{Filter} and $type eq 'PrintConv';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"OPTIONS"}{"Filter"} and $type eq "PrintConv" 442 35184 35626
Condition100%3/3
$self->{"OPTIONS"}{"Filter"} and $type eq "PrintConv"
!ll&&!rl&&r
351795442
MC/DC100%2/2
$self->{"OPTIONS"}{"Filter"} and $type eq "PrintConv"
$self->{"OPTIONS"}{"Filter"} $type eq "PrintConv"
Truth table100%3/3
A and B
A= $self->{"OPTIONS"}{"Filter"}B= $type eq "PrintConv"
ABresult
0X0
100
111
3702  
3703 35626 ▶ if (ref $value eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value eq "ARRAY") 311 35315 35626
3704 311 ▶ if (defined $$self{OPTIONS}{ListItem}) {
Branch: 3 branches
BranchTrueFalseTotal
if (defined $self->{'OPTIONS'}{'ListItem'}) { } 3 308 311
elsif (wantarray) { } 1 307 308
elsif ($type eq 'PrintConv' and not $self->{'OPTIONS'}{'List'}) { } 170 163 333
3705 3 $value = $$value[$$self{OPTIONS}{ListItem}];
3706 } elsif (wantarray) {
3707 # return array if requested
3708 1 return @$value;
3709 ▶ } elsif ($type eq 'PrintConv' and not $$self{OPTIONS}{List}) {
Condition100%3/3
$type eq "PrintConv" and not $self->{"OPTIONS"}{"List"}
!ll&&!rl&&r
26111170
MC/DC100%2/2
$type eq "PrintConv" and not $self->{"OPTIONS"}{"List"}
$type eq "PrintConv" not $self->{"OPTIONS"}{"List"}
Truth table100%3/3
A and not(B)
A= $type eq "PrintConv"B= not $self->{"OPTIONS"}{"List"}
ABresult
0X0
100
111
3710 # join PrintConv values in delimited string if List option not used
3711 # and list contains simple scalars (otherwise return ARRAY ref)
3712 170 ▶ ref and return $value foreach @$value;
Branch: 1 branch
BranchTrueFalseTotal
ref $_ and return $value 1 464 465
3713 169 $value = join $$self{OPTIONS}{ListSep}, @$value;
3714 }
3715 }
3716 35624 return $value;
3717 }
3718  
3719 #------------------------------------------------------------------------------
3720 # Get tag identification number
3721 # Inputs: 0) ExifTool object reference, 1) tag key
3722 # Returns: Scalar context: tag ID if available, otherwise ''
3723 # List context: 0) tag ID (or ''), 1) language code (or undef)
3724 sub GetTagID($$)
3725 24010 ▶{
Subroutine GetTagID: called CC=5 SCAR=16.2
Pod documented
3726 24010 my ($self, $tag) = @_;
3727 24010 my $tagInfo = $$self{TAG_INFO}{$tag};
3728 24010 ▶ return '' unless $tagInfo and defined $$tagInfo{TagID};
Branch: 1 branch
BranchTrueFalseTotal
unless $tagInfo and defined $tagInfo->{"TagID"} 2 24008 24010
Condition66%2/3
$tagInfo and defined $tagInfo->{"TagID"}
!ll&&!rl&&r
0224008
MC/DC50%1/2
$tagInfo and defined $tagInfo->{"TagID"}
$tagInfo defined $tagInfo->{"TagID"}
Truth table66%2/3
A and B
A= $tagInfoB= defined $tagInfo->{"TagID"}
ABresult
0X0
100
111
3729 24008 ▶ my $id = $$tagInfo{KeysID} || $$tagInfo{TagID};
Condition100%3/3
$tagInfo->{'KeysID'} || $tagInfo->{'TagID'}
l!l&&r!l&&!r
2523518465
MC/DC100%2/2
$tagInfo->{'KeysID'} || $tagInfo->{'TagID'}
$tagInfo->{'KeysID'} $tagInfo->{'TagID'}
Truth table100%3/3
A || B
A= $tagInfo->{'KeysID'}B= $tagInfo->{'TagID'}
ABresult
1X1
011
000
3730 24008 ▶ return ($id, $$tagInfo{LangCode}) if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 24008 24008
3731 24008 return $id;
3732 }
3733  
3734 #------------------------------------------------------------------------------
3735 # Get description for specified tag
3736 # Inputs: 0) ExifTool object reference, 1) tag key
3737 # Returns: Tag description
3738 # Notes: Will always return a defined value, even if description isn't available
3739 sub GetDescription($$)
3740 24010 ▶{
Subroutine GetDescription: called CC=14 SCAR=27.6
Pod documented
3741 24010 local $_;
3742 24010 my ($self, $tag) = @_;
3743 24010 my ($desc, $name);
3744 24010 my $tagInfo = $$self{TAG_INFO}{$tag};
3745 # ($tagInfo won't be defined for missing tags extracted with -f)
3746 24010 ▶ if ($tagInfo) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tagInfo) 24010 0 24010
3747 # use alternate language description if available
3748 24010 ▶ while ($$self{CUR_LANG}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"CUR_LANG"}) 847 23163 24010
3749 847 $desc = $$self{CUR_LANG}{$$tagInfo{Name}};
3750 847 ▶ if ($desc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($desc) { } 718 129 847
3751 # must look up Description if this tag also has a PrintConv
3752 718 ▶ $desc = $$desc{Description} or last if ref $desc;
Branch: 1 branch
BranchTrueFalseTotal
if ref $desc 263 455 718
Condition80%4/5
ref $desc && (($desc = $desc->{'Description'}) || (last))
!ll&&!rl&&r
4552630
$desc = $desc->{"Description"} or last
l!l
2549
MC/DC0%0/2
ref $desc && (($desc = $desc->{'Description'}) || (last))
ref $desc $desc = $desc->{"Description"}
Truth table66%2/3
A && B
A= ref $descB= $desc = $desc->{"Description"}
ABresult
0X0
100
111
3753 } else {
3754 # look up default language of lang-alt tag
3755 last unless $$tagInfo{LangCode} and
3756 ($name = $$tagInfo{Name}) =~ s/-$$tagInfo{LangCode}$// and
3757 129 ▶ $desc = $$self{CUR_LANG}{$name};
Branch: 1 branch
BranchTrueFalseTotal
unless $tagInfo->{"LangCode"} and ($name = $tagInfo->{"Name"}) =~ s/-$tagInfo->{"LangCode"}$// and $desc = $self->{"CUR_LANG"}{$name} 128 1 129
Condition66%4/6
$tagInfo->{"LangCode"} and ($name = $tagInfo->{"Name"}) =~ s/-$tagInfo->{"LangCode"}$// and $desc = $self->{"CUR_LANG"}{$name}
!ll&&!rl&&r
12801
$tagInfo->{"LangCode"} and ($name = $tagInfo->{"Name"}) =~ s/-$tagInfo->{"LangCode"}$//
!ll&&!rl&&r
12801
MC/DC33%1/3
$tagInfo->{"LangCode"} and ($name = $tagInfo->{"Name"}) =~ s/-$tagInfo->{"LangCode"}$// and $desc = $self->{"CUR_LANG"}{$name}
$tagInfo->{"LangCode"} ($name = $tagInfo->{"Name"}) =~ s/-$tagInfo->{"LangCode"}$// $desc = $self->{"CUR_LANG"}{$name}
Truth table50%2/4
A and B and C
A= $tagInfo->{"LangCode"}B= ($name = $tagInfo->{"Name"}) =~ s/-$tagInfo->{"LangCode"}$//C= $desc = $self->{"CUR_LANG"}{$name}
ABCresult
0XX0
10X0
1100
1111
3758 1 ▶ $desc = $$desc{Description} or last if ref $desc;
Branch: 1 branch
BranchTrueFalseTotal
if ref $desc 0 1 1
Condition20%1/5
ref $desc && (($desc = $desc->{'Description'}) || (last))
!ll&&!rl&&r
100
$desc = $desc->{"Description"} or last
l!l
00
MC/DC0%0/2
ref $desc && (($desc = $desc->{'Description'}) || (last))
ref $desc $desc = $desc->{"Description"}
Truth table33%1/3
A && B
A= ref $descB= $desc = $desc->{"Description"}
ABresult
0X0
100
111
3759 1 $desc .= " ($$tagInfo{LangCode})";
3760 }
3761 # escape description if necessary
3762 710 ▶ DoEscape($desc, $$self{ESCAPE_PROC}) if $$self{ESCAPE_PROC};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"ESCAPE_PROC"} 0 710 710
3763 # return description in proper Charset
3764 710 return $self->Decode($desc, 'UTF8');
3765 }
3766 23300 $desc = $$tagInfo{Description};
3767 }
3768 # just make the tag more readable if description doesn't exist
3769 23300 ▶ unless ($desc) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($desc) 9894 13406 23300
3770 9894 $desc = MakeDescription(GetTagName($tag));
3771 # save description in tag information
3772 9894 ▶ $$tagInfo{Description} = $desc if $tagInfo;
Branch: 1 branch
BranchTrueFalseTotal
if $tagInfo 9894 0 9894
3773 }
3774 23300 return $desc;
3775 }
3776  
3777 #------------------------------------------------------------------------------
3778 # Get group name for specified tag
3779 # Inputs: 0) ExifTool object reference
3780 # 1) tag key (or reference to tagInfo hash, not part of the public API)
3781 # 2) [optional] group family (-1 to get extended group list, or multiple
3782 # families separated by colons to return multiple groups as a string)
3783 # Returns: Scalar context: group name (for family 0 if not otherwise specified)
3784 # List context: group name if family specified, otherwise list of
3785 # group names for each family. Returns '' for undefined tag.
3786 # Notes: Multiple families may be specified with ':' in family argument (eg. '1:2')
3787 sub GetGroup($$;$)
3788 204764 ▶{
Subroutine GetGroup: called CC=63 SCAR=45.4
Pod documented
3789 204764 local $_;
3790 204764 my ($self, $tag, $family) = @_;
3791 204764 my ($tagInfo, @groups, @families, $simplify, $byTagInfo, $ex, $noID);
3792 204764 ▶ if (ref $tag eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $tag eq 'HASH') { } 129957 74807 204764
3793 129957 $tagInfo = $tag;
3794 129957 $tag = $$tagInfo{Name};
3795 # set flag so we don't get extra information for an extracted tag
3796 129957 $byTagInfo = 1;
3797 129957 $ex = { };
3798 } else {
3799 74807 ▶ $tagInfo = $$self{TAG_INFO}{$tag} || { };
Condition50%1/2
$self->{'TAG_INFO'}{$tag} || {}
l!l
748070
MC/DC0%0/1
$self->{'TAG_INFO'}{$tag} || {}
$self->{'TAG_INFO'}{$tag}
Truth table50%1/2
A
A= $self->{'TAG_INFO'}{$tag}
Aresult
11
00
3800 74807 ▶ $ex = $$self{TAG_EXTRA}{$tag} || { };
Condition50%1/2
$self->{'TAG_EXTRA'}{$tag} || {}
l!l
748070
MC/DC0%0/1
$self->{'TAG_EXTRA'}{$tag} || {}
$self->{'TAG_EXTRA'}{$tag}
Truth table50%1/2
A
A= $self->{'TAG_EXTRA'}{$tag}
Aresult
11
00
3801 }
3802 204764 my $groups = $$tagInfo{Groups};
3803 # fill in default groups unless already done
3804 # (after this, Groups 0-2 in tagInfo are guaranteed to be defined)
3805 204764 ▶ unless ($$tagInfo{GotGroups}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($tagInfo->{"GotGroups"}) 39174 165590 204764
3806 39174 ▶ my $tagTablePtr = $$tagInfo{Table} || { GROUPS => { } };
Condition50%1/2
$tagInfo->{'Table'} || {'GROUPS', {}}
l!l
391740
MC/DC0%0/1
$tagInfo->{'Table'} || {'GROUPS', {}}
$tagInfo->{'Table'}
Truth table50%1/2
A
A= $tagInfo->{'Table'}
Aresult
11
00
3807 # construct our group list
3808 39174 ▶ $groups or $groups = $$tagInfo{Groups} = { };
Branch: 1 branch
BranchTrueFalseTotal
$groups or $groups = ($tagInfo->{"Groups"} = {}) 5529 33645 39174
3809 # fill in default groups
3810 39174 foreach (0..2) {
3811 117522 ▶ $$groups{$_} = $$tagTablePtr{GROUPS}{$_} || '' unless $$groups{$_};
Branch: 1 branch
BranchTrueFalseTotal
unless $groups->{$_} 109805 7717 117522
Condition50%1/2
$tagTablePtr->{'GROUPS'}{$_} || ''
l!l
1098050
MC/DC0%0/1
$tagTablePtr->{'GROUPS'}{$_} || ''
$tagTablePtr->{'GROUPS'}{$_}
Truth table50%1/2
A
A= $tagTablePtr->{'GROUPS'}{$_}
Aresult
11
00
3812 }
3813 # set flag indicating group list was built
3814 39174 $$tagInfo{GotGroups} = 1;
3815 }
3816 204764 ▶ if (defined $family and $family ne '-1') {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $family and $family ne '-1') { } 103316 101448 204764
Condition100%3/3
defined $family and $family ne -1
!ll&&!rl&&r
8296218486103316
MC/DC100%2/2
defined $family and $family ne -1
defined $family $family ne -1
Truth table100%3/3
A and B
A= defined $familyB= $family ne -1
ABresult
0X0
100
111
3817 103316 ▶ if ($family =~ /[^\d]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($family =~ /[^\d]/) { } 2736 100580 103316
3818 2736 @families = ($family =~ /\d+/g);
3819 2736 ▶ return($$ex{G0} || $$groups{0}) unless @families;
Branch: 1 branch
BranchTrueFalseTotal
unless @families 0 2736 2736
Condition0%0/3
$ex->{'G0'} || $groups->{'0'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$ex->{'G0'} || $groups->{'0'}
$ex->{'G0'} $groups->{'0'}
Truth table0%0/3
A || B
A= $ex->{'G0'}B= $groups->{'0'}
ABresult
1X1
011
000
3820 2736 ▶ $simplify = 1 unless $family =~ /^:/;
Branch: 1 branch
BranchTrueFalseTotal
unless $family =~ /^:/ 2736 0 2736
3821 2736 undef $family;
3822 2736 foreach (0..2) { $groups[$_] = $$groups{$_}; }
3823 2736 ▶ $noID = 1 if @families == 1 and $families[0] != 7;
Branch: 1 branch
BranchTrueFalseTotal
if @families == 1 and $families[0] != 7 0 2736 2736
Condition33%1/3
@families == 1 and $families[0] != 7
!ll&&!rl&&r
273600
MC/DC0%0/2
@families == 1 and $families[0] != 7
@families == 1 $families[0] != 7
Truth table33%1/3
A and B
A= @families == 1B= $families[0] != 7
ABresult
0X0
100
111
3824 } else {
3825 100580 ▶ return($$ex{"G$family"} || $$groups{$family}) if $family == 0 or $family == 2;
Branch: 1 branch
BranchTrueFalseTotal
if $family == 0 or $family == 2 69797 30783 100580
Condition83%5/6
$family == 0 or $family == 2
l!l&&r!l&&!r
6945534230783
$$ex{"G$family"} || $groups->{$family}
l!l&&r!l&&!r
182696150
MC/DC100%2/2
$family == 0 or $family == 2
$family == 0 $family == 2
MC/DC0%0/2
$$ex{"G$family"} || $groups->{$family}
$$ex{"G$family"} $groups->{$family}
Truth table100%3/3
A or B
A= $family == 0B= $family == 2
ABresult
1X1
011
000
Truth table66%2/3
A || B
A= $$ex{"G$family"}B= $groups->{$family}
ABresult
1X1
011
000
3826 30783 $groups[1] = $$groups{1};
3827 }
3828 } else {
3829 101448 ▶ return($$ex{G0} || $$groups{0}) unless wantarray;
Branch: 1 branch
BranchTrueFalseTotal
unless wantarray 380 101068 101448
Condition33%1/3
$ex->{'G0'} || $groups->{'0'}
l!l&&r!l&&!r
03800
MC/DC0%0/2
$ex->{'G0'} || $groups->{'0'}
$ex->{'G0'} $groups->{'0'}
Truth table33%1/3
A || B
A= $ex->{'G0'}B= $groups->{'0'}
ABresult
1X1
011
000
3830 101068 foreach (0..2) { $groups[$_] = $$groups{$_}; }
3831 }
3832 134587 $groups[3] = 'Main';
3833 134587 ▶ $groups[4] = ($tag =~ /\((\d+)\)$/ and $1 ne '0') ? "Copy$1" : '';
Branch: 1 branch
BranchTrueFalseTotal
$tag =~ /\((\d+)\)$/ && $1 ne '0' ? : 5527 129060 134587
Condition66%2/3
$tag =~ /\((\d+)\)$/ and $1 ne 0
!ll&&!rl&&r
12906005527
MC/DC50%1/2
$tag =~ /\((\d+)\)$/ and $1 ne 0
$tag =~ /\((\d+)\)$/ $1 ne 0
Truth table66%2/3
A and B
A= $tag =~ /\((\d+)\)$/B= $1 ne 0
ABresult
0X0
100
111
3834 # handle dynamic group names if necessary
3835 134587 ▶ unless ($byTagInfo) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($byTagInfo) 48513 86074 134587
3836 48513 ▶ $groups[0] = $$ex{G0} if $$ex{G0};
Branch: 1 branch
BranchTrueFalseTotal
if $ex->{"G0"} 330 48183 48513
3837 48513 ▶ $groups[1] = $$ex{G1} =~ /^\+(.*)/ ? "$groups[1]$1" : $$ex{G1} if $$ex{G1};
Branch: 2 branches
BranchTrueFalseTotal
if $ex->{"G1"} 17993 30520 48513
$ex->{'G1'} =~ /^\+(.*)/ ? : 384 17609 17993
3838 48513 ▶ $groups[3] = 'Doc' . $$ex{G3} if $$ex{G3};
Branch: 1 branch
BranchTrueFalseTotal
if $ex->{"G3"} 1357 47156 48513
3839 48513 ▶ $groups[5] = $$ex{G5} || $groups[1] if defined $$ex{G5};
Branch: 1 branch
BranchTrueFalseTotal
if defined $ex->{"G5"} 255 48258 48513
Condition66%2/3
$ex->{'G5'} || $groups[1]
l!l&&r!l&&!r
218370
MC/DC0%0/2
$ex->{'G5'} || $groups[1]
$ex->{'G5'} $groups[1]
Truth table66%2/3
A || B
A= $ex->{'G5'}B= $groups[1]
ABresult
1X1
011
000
3840 48513 ▶ if (defined $$ex{G6}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ex->{"G6"}) 0 48513 48513
3841 0 ▶ $groups[5] = '' unless defined $groups[5]; # (can't leave a hole in the array)
Branch: 1 branch
BranchTrueFalseTotal
unless defined $groups[5] 0 0 0
3842 0 $groups[6] = $$ex{G6};
3843 }
3844 48513 ▶ if ($$ex{G8}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ex->{"G8"}) 16 48497 48513
3845 16 $groups[7] = '';
3846 16 $groups[8] = $$ex{G8};
3847 }
3848 # generate tag ID group names unless obviously not needed
3849 48513 ▶ unless ($noID) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($noID) 48513 0 48513
3850 48513 ▶ my $id = $$tagInfo{KeysID} || $$tagInfo{TagID};
Condition100%3/3
$tagInfo->{'KeysID'} || $tagInfo->{'TagID'}
l!l&&r!l&&!r
10547424984
MC/DC100%2/2
$tagInfo->{'KeysID'} || $tagInfo->{'TagID'}
$tagInfo->{'KeysID'} $tagInfo->{'TagID'}
Truth table100%3/3
A || B
A= $tagInfo->{'KeysID'}B= $tagInfo->{'TagID'}
ABresult
1X1
011
000
3851 48513 ▶ if (not defined $id) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $id) { } 2 48511 48513
elsif ($id =~ /^\d+$/) { } 30259 18252 48511
3852 2 $id = ''; # (just to be safe)
3853 } elsif ($id =~ /^\d+$/) {
3854 30259 ▶ $id = sprintf('0x%x', $id) if $$self{OPTIONS}{HexTagIDs};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"OPTIONS"}{"HexTagIDs"} 0 30259 30259
3855 } else {
3856 18252 $id =~ s/([^-_A-Za-z0-9])/sprintf('%.2x',ord $1)/ge;
3857 }
3858 48513 $groups[7] = 'ID-' . $id;
3859 48513 ▶ defined $groups[$_] or $groups[$_] = '' foreach (5,6);
Branch: 1 branch
BranchTrueFalseTotal
defined $groups[$_] or $groups[$_] = "" 255 96771 97026
3860 }
3861 }
3862 134587 ▶ if ($family) {
Branch: 1 branch
BranchTrueFalseTotal
if ($family) 49269 85318 134587
3863 49269 ▶ return $groups[$family] || '' if $family > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $family > 0 30783 18486 49269
Condition50%1/2
$groups[$family] || ''
l!l
307830
MC/DC0%0/1
$groups[$family] || ''
$groups[$family]
Truth table50%1/2
A
A= $groups[$family]
Aresult
11
00
3864 # add additional matching group names to list
3865 # eg) for MIE-Doc, also add MIE1, MIE1-Doc, MIE-Doc1 and MIE1-Doc1
3866 # and for MIE2-Doc3, also add MIE2, MIE-Doc3, MIE2-Doc and MIE-Doc
3867 18486 ▶ if ($groups[1] =~ /^MIE(\d*)-(.+?)(\d*)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($groups[1] =~ /^MIE(\d*)-(.+?)(\d*)$/) 42 18444 18486
3868 42 ▶ push @groups, 'MIE' . ($1 || '1');
Condition50%1/2
$1 || '1'
l!l
042
MC/DC0%0/1
$1 || '1'
$1
Truth table50%1/2
A
A= $1
Aresult
11
00
3869 42 ▶ push @groups, 'MIE' . ($1 ? '' : '1') . "-$2$3";
Branch: 1 branch
BranchTrueFalseTotal
$1 ? : 0 42 42
3870 42 ▶ push @groups, "MIE$1-$2" . ($3 ? '' : '1');
Branch: 1 branch
BranchTrueFalseTotal
$3 ? : 0 42 42
3871 42 ▶ push @groups, 'MIE' . ($1 ? '' : '1') . "-$2" . ($3 ? '' : '1');
Branch: 2 branches
BranchTrueFalseTotal
$1 ? : 0 42 42
$3 ? : 0 42 42
3872 }
3873 }
3874 103804 ▶ if (@families) {
Branch: 1 branch
BranchTrueFalseTotal
if (@families) 2736 101068 103804
3875 2736 my @grps;
3876 # create list of group names (without identical adjacent groups if simplifying)
3877 2736 foreach (@families) {
3878 5472 my $grp = $groups[$_];
3879 5472 ▶ unless ($grp) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($grp) 0 5472 5472
3880 0 ▶ next if $simplify;
Branch: 1 branch
BranchTrueFalseTotal
if $simplify 0 0 0
3881 0 $grp = '';
3882 }
3883 5472 ▶ push @grps, $grp unless $simplify and @grps and $grp eq $grps[-1];
Branch: 1 branch
BranchTrueFalseTotal
unless $simplify and @grps and $grp eq $grps[-1] 5456 16 5472
Condition83%5/6
$simplify and @grps and $grp eq $grps[-1]
!ll&&!rl&&r
2736272016
$simplify and @grps
!ll&&!rl&&r
027362736
MC/DC66%2/3
$simplify and @grps and $grp eq $grps[-1]
$simplify @grps $grp eq $grps[-1]
Truth table75%3/4
A and B and C
A= $simplifyB= @grpsC= $grp eq $grps[-1]
ABCresult
0XX0
10X0
1100
1111
3884 }
3885 # remove leading "Main:" if simplifying
3886 2736 ▶ shift @grps if $simplify and @grps > 1 and $grps[0] eq 'Main';
Branch: 1 branch
BranchTrueFalseTotal
if $simplify and @grps > 1 and $grps[0] eq "Main" 0 2736 2736
Condition66%4/6
$simplify and @grps > 1 and $grps[0] eq "Main"
!ll&&!rl&&r
1627200
$simplify and @grps > 1
!ll&&!rl&&r
0162720
MC/DC0%0/3
$simplify and @grps > 1 and $grps[0] eq "Main"
$simplify @grps > 1 $grps[0] eq "Main"
Truth table50%2/4
A and B and C
A= $simplifyB= @grps > 1C= $grps[0] eq "Main"
ABCresult
0XX0
10X0
1100
1111
3887 # return colon-separated string of group names
3888 2736 return join ':', @grps;
3889 }
3890 101068 return @groups;
3891 }
3892  
3893 #------------------------------------------------------------------------------
3894 # Get group names for specified tags
3895 # Inputs: 0) ExifTool object reference
3896 # 1) [optional] information hash reference (default all extracted info)
3897 # 2) [optional] group family (default 0)
3898 # Returns: List of group names in alphabetical order
3899 sub GetGroups($;$$)
3900 3 ▶{
Subroutine GetGroups: called CC=4 SCAR=13.9
Pod documented
3901 3 local $_;
3902 3 my $self = shift;
3903 3 my $info = shift;
3904 3 my $family;
3905  
3906 # figure out our arguments
3907 3 ▶ if (ref $info ne 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $info ne 'HASH') { } 2 1 3
3908 2 $family = $info;
3909 2 $info = $$self{VALUE};
3910 } else {
3911 1 $family = shift;
3912 }
3913 3 ▶ $family = 0 unless defined $family;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $family 0 3 3
3914  
3915 # get a list of all groups in specified information
3916 3 my ($tag, %groups);
3917 3 foreach $tag (keys %$info) {
3918 383 $groups{ $self->GetGroup($tag, $family) } = 1;
3919 }
3920 3 return sort keys %groups;
3921 }
3922  
3923 #------------------------------------------------------------------------------
3924 # Set priority for group where new values are written
3925 # Inputs: 0) ExifTool object reference,
3926 # 1-N) group names (reset to default if no groups specified)
3927 # - used when new tag values are set (ie. before files are written)
3928 sub SetNewGroups($;@)
3929 508 ▶{
Subroutine SetNewGroups: called CC=3 SCAR=11.0
Pod documented
3930 508 local $_;
3931 508 my ($self, @groups) = @_;
3932 508 ▶ @groups or @groups = @defaultWriteGroups;
Branch: 1 branch
BranchTrueFalseTotal
@groups or @groups = @defaultWriteGroups 508 0 508
3933 508 my $count = @groups * 10;
3934 508 my %priority;
3935 508 foreach (@groups) {
3936 4572 $priority{lc($_)} = $count;
3937 4572 $count -= 10;
3938 }
3939 508 $priority{file} = 500; # 'File' group is always written (Comment)
3940 508 $priority{composite} = 500; # 'Composite' group is always written
3941 # set write priority (higher # is higher priority)
3942 508 $$self{WRITE_PRIORITY} = \%priority;
3943 508 $$self{WRITE_GROUPS} = \@groups;
3944 }
3945  
3946 #------------------------------------------------------------------------------
3947 # Build Composite tags from Require'd/Desire'd tags
3948 # Inputs: 0) ExifTool object reference, 1) flag to build only tags that require
3949 # tags from alternate files (without this, these tags are ignored)
3950 # Note: Tag values are calculated in alphabetical order unless a tag Require's
3951 # or Desire's another Composite tag, in which case the calculation is
3952 # deferred until after the other tag is calculated.
3953 sub BuildCompositeTags($)
3954 541 ▶{
Subroutine BuildCompositeTags: called CC=68 SCAR=45.1
Pod documented
3955 541 local $_;
3956 541 my ($self, $altOnly) = @_;
3957  
3958 541 $$self{BuildingComposite} = 1;
3959  
3960 541 my $compTable = GetTagTable('Image::ExifTool::Composite');
3961 541 my @tagList = sort keys %$compTable;
3962 541 my $rawValue = $$self{VALUE};
3963 541 my $compKeys = $$self{COMP_KEYS};
3964 541 my (%cache, $allBuilt);
3965  
3966 541 for (;;) {
3967 2363 my (%notBuilt, $tag, @deferredTags);
3968 2363 foreach (@tagList) {
3969 47601 ▶ $notBuilt{$$compTable{$_}{Name}} = 1 unless $specialTags{$_};
Branch: 1 branch
BranchTrueFalseTotal
unless $Image::ExifTool::specialTags{$_} 44355 3246 47601
3970 }
3971 COMPOSITE_TAG:
3972 2363 foreach $tag (@tagList) {
3973 47601 ▶ next if $specialTags{$tag};
Branch: 1 branch
BranchTrueFalseTotal
if $Image::ExifTool::specialTags{$tag} 3246 44355 47601
3974 44355 my $tagInfo = $self->GetTagInfo($compTable, $tag);
3975 44355 ▶ next unless $tagInfo;
Branch: 1 branch
BranchTrueFalseTotal
unless $tagInfo 263 44092 44355
3976 44092 my $tagName = $$compTable{$tag}{Name};
3977 # put required tags into array and make sure they all exist
3978 44092 ▶ my $subDoc = ($$tagInfo{SubDoc} and $$self{DOC_COUNT});
Condition100%3/3
$tagInfo->{'SubDoc'} && $self->{'DOC_COUNT'}
!ll&&!rl&&r
410852799208
MC/DC100%2/2
$tagInfo->{'SubDoc'} && $self->{'DOC_COUNT'}
$tagInfo->{'SubDoc'} $self->{'DOC_COUNT'}
Truth table100%3/3
A && B
A= $tagInfo->{'SubDoc'}B= $self->{'DOC_COUNT'}
ABresult
0X0
100
111
3979 44092 ▶ my $require = $$tagInfo{Require} || { };
Condition100%2/2
$tagInfo->{'Require'} || {}
l!l
379786114
MC/DC100%1/1
$tagInfo->{'Require'} || {}
$tagInfo->{'Require'}
Truth table100%2/2
A
A= $tagInfo->{'Require'}
Aresult
11
00
3980 44092 ▶ my $desire = $$tagInfo{Desire} || { };
Condition100%2/2
$tagInfo->{'Desire'} || {}
l!l
1930524787
MC/DC100%1/1
$tagInfo->{'Desire'} || {}
$tagInfo->{'Desire'}
Truth table100%2/2
A
A= $tagInfo->{'Desire'}
Aresult
11
00
3981 44092 ▶ my $inhibit = $$tagInfo{Inhibit} || { };
Condition100%2/2
$tagInfo->{'Inhibit'} || {}
l!l
271941373
MC/DC100%1/1
$tagInfo->{'Inhibit'} || {}
$tagInfo->{'Inhibit'}
Truth table100%2/2
A
A= $tagInfo->{'Inhibit'}
Aresult
11
00
3982 # loop through sub-documents if necessary
3983 44092 my $docNum = 0;
3984 44092 for (;;) {
3985 44092 my (%tagKey, $found, $index, $requireAlt);
3986 # save Require'd and Desire'd tag values in list
3987 44092 for ($index=0; ; ++$index) {
3988 103005 ▶ my $reqTag = $$require{$index} || $$desire{$index} || $$inhibit{$index};
Condition100%6/6
$require->{$index} || $desire->{$index} || $inhibit->{$index}
l!l&&r!l&&!r
9147120269508
$require->{$index} or $desire->{$index}
l!l&&r!l&&!r
411495032211534
MC/DC100%3/3
$require->{$index} || $desire->{$index} || $inhibit->{$index}
$require->{$index} $desire->{$index} $inhibit->{$index}
Truth table100%4/4
A or B || C
A= $require->{$index}B= $desire->{$index}C= $inhibit->{$index}
ABCresult
1XX1
01X1
0011
0000
3989 103005 ▶ unless ($reqTag) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($reqTag) 9508 93497 103005
3990 # allow Composite with no Require'd or Desire'd tags
3991 9508 ▶ $found = 1 if $index == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $index == 0 0 9508 9508
3992 9508 last;
3993 }
3994 93497 ▶ if ($subDoc) {
Branch: 3 branches
BranchTrueFalseTotal
if ($subDoc) { } 304 93193 93497
elsif ($reqTag =~ /^(.*):(.+)/) { } 29587 63606 93193
elsif ($notBuilt{$reqTag} and not $inhibit->{$index}) { } 5241 116730 121971
3995 # handle SubDoc tags specially to cache tag keys for faster
3996 # processing when there are a large number of sub-documents
3997 # - get document number from the tag groups if specified,
3998 # otherwise we are looping through all documents for this tag
3999 304 ▶ my $doc = $reqTag =~ s/\b(Main|Doc(\d+)):// ? ($2 || 0) : $docNum;
Branch: 1 branch
BranchTrueFalseTotal
$reqTag =~ s/\b(Main|Doc(\d+)):// ? : 0 304 304
Condition0%0/2
$2 or 0
l!l
00
MC/DC0%0/1
$2 or 0
$2
Truth table0%0/2
A
A= $2
Aresult
11
00
4000 # make fast lookup for keys of this tag with specified groups other than doc group
4001 # (similar to code in InsertTagValues(), but this is case-sensitive)
4002 304 my $cacheTag = $cache{$reqTag};
4003 304 ▶ unless ($cacheTag) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($cacheTag) 304 0 304
4004 304 $cacheTag = $cache{$reqTag} = [ ];
4005 304 my $reqGroup;
4006 304 ▶ $reqTag =~ s/^(.*):// and $reqGroup = $1;
Branch: 1 branch
BranchTrueFalseTotal
$reqTag =~ s/^(.*):// and $reqGroup = $1 304 0 304
4007 304 my ($i, $key, @keys);
4008 # build list of tag keys in order of precedence
4009 304 ▶ for ($key=$reqTag, $i=$$self{DUPL_TAG}{$reqTag} || 0; ; --$i) {
Condition50%1/2
$self->{'DUPL_TAG'}{$reqTag} || 0
l!l
0304
MC/DC0%0/1
$self->{'DUPL_TAG'}{$reqTag} || 0
$self->{'DUPL_TAG'}{$reqTag}
Truth table50%1/2
A
A= $self->{'DUPL_TAG'}{$reqTag}
Aresult
11
00
4010 304 ▶ push @keys, $key if defined $$rawValue{$key};
Branch: 1 branch
BranchTrueFalseTotal
if defined $rawValue->{$key} 0 304 304
4011 304 ▶ last if $i <= 0;
Branch: 1 branch
BranchTrueFalseTotal
if $i <= 0 304 0 304
4012 0 $key = "$reqTag ($i)";
4013 }
4014 304 ▶ @keys = $self->GroupMatches($reqGroup, \@keys) if defined $reqGroup;
Branch: 1 branch
BranchTrueFalseTotal
if defined $reqGroup 304 0 304
4015 # loop through tags in reverse order of precedence so the higher
4016 # priority tag will win in the case of duplicates within a doc
4017 304 ▶ $$cacheTag[$$self{TAG_EXTRA}{$_}{G3} || 0] = $_ foreach reverse @keys;
Condition0%0/2
$self->{'TAG_EXTRA'}{$_}{'G3'} || 0
l!l
00
MC/DC0%0/1
$self->{'TAG_EXTRA'}{$_}{'G3'} || 0
$self->{'TAG_EXTRA'}{$_}{'G3'}
Truth table0%0/2
A
A= $self->{'TAG_EXTRA'}{$_}{'G3'}
Aresult
11
00
4018 }
4019 # (set $reqTag to a bogus key if not found)
4020 304 ▶ $reqTag = $$cacheTag[$doc] || "$reqTag (0)";
Condition50%1/2
$cacheTag->[$doc] || "$reqTag (0)"
l!l
0304
MC/DC0%0/1
$cacheTag->[$doc] || "$reqTag (0)"
$cacheTag->[$doc]
Truth table50%1/2
A
A= $cacheTag->[$doc]
Aresult
11
00
4021 } elsif ($reqTag =~ /^(.*):(.+)/) {
4022 29587 my ($reqGroup, $name) = ($1, $2);
4023 29587 ▶ if ($reqGroup eq 'Composite' and $notBuilt{$name}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($reqGroup eq "Composite" and $notBuilt{$name}) 2238 27349 29587
Condition100%3/3
$reqGroup eq "Composite" and $notBuilt{$name}
!ll&&!rl&&r
266506992238
MC/DC100%2/2
$reqGroup eq "Composite" and $notBuilt{$name}
$reqGroup eq "Composite" $notBuilt{$name}
Truth table100%3/3
A and B
A= $reqGroup eq "Composite"B= $notBuilt{$name}
ABresult
0X0
100
111
4024 # defer only until all other tags are built if
4025 # we are inhibiting based on another Composite tag
4026 2238 ▶ unless ($$inhibit{$index} and $allBuilt) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($inhibit->{$index} and $allBuilt) 1767 471 2238
Condition100%3/3
$inhibit->{$index} and $allBuilt
!ll&&!rl&&r
2821485471
MC/DC100%2/2
$inhibit->{$index} and $allBuilt
$inhibit->{$index} $allBuilt
Truth table100%3/3
A and B
A= $inhibit->{$index}B= $allBuilt
ABresult
0X0
100
111
4027 1767 push @deferredTags, $tag;
4028 1767 next COMPOSITE_TAG;
4029 }
4030 }
4031 27820 my ($i, $key, @keys, $altFile);
4032 27820 my $et = $self;
4033 # get tags from alternate file if a family 8 group was specified
4034 27820 ▶ if ($reqTag =~ /\b(File\d+):/i and $$self{ALT_EXIFTOOL}{$1}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($reqTag =~ /\b(File\d+):/i and $self->{"ALT_EXIFTOOL"}{$1}) 2 27818 27820
Condition100%3/3
$reqTag =~ /\b(File\d+):/i and $self->{"ALT_EXIFTOOL"}{$1}
!ll&&!rl&&r
2781712
MC/DC100%2/2
$reqTag =~ /\b(File\d+):/i and $self->{"ALT_EXIFTOOL"}{$1}
$reqTag =~ /\b(File\d+):/i $self->{"ALT_EXIFTOOL"}{$1}
Truth table100%3/3
A and B
A= $reqTag =~ /\b(File\d+):/iB= $self->{"ALT_EXIFTOOL"}{$1}
ABresult
0X0
100
111
4035 2 $et = $$self{ALT_EXIFTOOL}{$1};
4036 2 $altFile = $1;
4037 # set flags indicating we require tags from alternate files
4038 2 $$self{DoAltComposite} = $requireAlt = 1;
4039 }
4040 # (CAREFUL! keys may not be sequential if one was deleted)
4041 27820 ▶ for ($key=$name, $i=$$et{DUPL_TAG}{$name} || 0; ; --$i) {
Condition100%2/2
$et->{'DUPL_TAG'}{$name} || 0
l!l
53627284
MC/DC100%1/1
$et->{'DUPL_TAG'}{$name} || 0
$et->{'DUPL_TAG'}{$name}
Truth table100%2/2
A
A= $et->{'DUPL_TAG'}{$name}
Aresult
11
00
4042 28526 ▶ push @keys, $key if defined $$et{VALUE}{$key};
Branch: 1 branch
BranchTrueFalseTotal
if defined $et->{"VALUE"}{$key} 4056 24470 28526
4043 28526 ▶ last if $i <= 0;
Branch: 1 branch
BranchTrueFalseTotal
if $i <= 0 27820 706 28526
4044 706 $key = "$name ($i)";
4045 }
4046 # make sure the necessary information is available from the alternate file
4047 27820 ▶ $self->CopyAltInfo($altFile, \@keys) if $altFile;
Branch: 1 branch
BranchTrueFalseTotal
if $altFile 2 27818 27820
4048 # find first matching tag
4049 27820 $key = $self->GroupMatches($reqGroup, \@keys);
4050 27820 ▶ $reqTag = $key || "$name (0)";
Condition100%2/2
$key || "$name (0)"
l!l
216225658
MC/DC100%1/1
$key || "$name (0)"
$key
Truth table100%2/2
A
A= $key
Aresult
11
00
4051 ▶ } elsif ($notBuilt{$reqTag} and not $$inhibit{$index}) {
Condition66%2/3
$notBuilt{$reqTag} and not $inhibit->{$index}
!ll&&!rl&&r
5836505241
MC/DC50%1/2
$notBuilt{$reqTag} and not $inhibit->{$index}
$notBuilt{$reqTag} not $inhibit->{$index}
Truth table66%2/3
A and not(B)
A= $notBuilt{$reqTag}B= not $inhibit->{$index}
ABresult
0X0
100
111
4052 # calculate this tag later if it relies on another
4053 # Composite tag which hasn't been calculated yet
4054 5241 push @deferredTags, $tag;
4055 5241 next COMPOSITE_TAG;
4056 }
4057 86489 ▶ if (defined $$rawValue{$reqTag}) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $rawValue->{$reqTag}) { } 17030 69459 86489
elsif ($require->{$index}) { } 27505 41954 69459
4058 17030 ▶ if ($$inhibit{$index}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($inhibit->{$index}) { } 71 16959 17030
4059 71 $found = 0;
4060 71 last;
4061 } else {
4062 16959 $found = 1;
4063 }
4064 } elsif ($$require{$index}) {
4065 27505 $found = 0;
4066 27505 last; # don't continue since we require this tag
4067 }
4068 58913 $tagKey{$index} = $reqTag;
4069 }
4070 # stop now if this requires alternate tags and we aren't building them
4071 37084 ▶ last if $requireAlt xor $altOnly;
Branch: 1 branch
BranchTrueFalseTotal
if $requireAlt xor $altOnly 73 37011 37084
Condition100%4/4
$requireAlt xor $altOnly
l&&rl&&!r!l&&r!l&&!r
117237010
MC/DC100%2/2
$requireAlt xor $altOnly
$requireAlt $altOnly
Truth table100%4/4
A xor B
A= $requireAltB= $altOnly
ABresult
110
101
011
000
4072 37011 ▶ if ($docNum) {
Branch: 3 branches
BranchTrueFalseTotal
if ($docNum) { } 0 37011 37011
elsif ($found) { } 5513 31498 37011
elsif (not defined $found) { } 3965 27533 31498
4073 0 ▶ if ($found) {
Branch: 1 branch
BranchTrueFalseTotal
if ($found) 0 0 0
4074 0 $$self{DOC_NUM} = $docNum;
4075 # save pointers to all used tag keys
4076 0 foreach (keys %tagKey) {
4077 0 ▶ $$compKeys{$_} or $$compKeys{$_} = [ ];
Branch: 1 branch
BranchTrueFalseTotal
$compKeys->{$_} or $compKeys->{$_} = [] 0 0 0
4078 0 push @{$$compKeys{$tagKey{$_}}}, [ \%tagKey, $_ ];
4079 }
4080 0 $self->FoundTag($tagInfo, \%tagKey);
4081 0 delete $$self{DOC_NUM};
4082 }
4083 0 ▶ next if ++$docNum <= $$self{DOC_COUNT};
Branch: 1 branch
BranchTrueFalseTotal
if ++$docNum <= $self->{"DOC_COUNT"} 0 0 0
4084 0 last;
4085 } elsif ($found) {
4086 5513 delete $notBuilt{$tagName}; # this tag is OK to build now
4087 # keep track of all Require'd tag keys
4088 5513 foreach (keys %tagKey) {
4089 # only tag keys with same name as a Composite tag
4090 # can be replaced (also eliminates keys with
4091 # instance numbers which can't be replaced either)
4092 24355 ▶ next unless $compositeID{$tagKey{$_}};
Branch: 1 branch
BranchTrueFalseTotal
unless $compositeID{$tagKey{$_}} 19488 4867 24355
4093 }
4094 # save pointers to all used tag keys
4095 5513 foreach (keys %tagKey) {
4096 24355 ▶ $$compKeys{$_} or $$compKeys{$_} = [ ];
Branch: 1 branch
BranchTrueFalseTotal
$compKeys->{$_} or $compKeys->{$_} = [] 17766 6589 24355
4097 24355 push @{$$compKeys{$tagKey{$_}}}, [ \%tagKey, $_ ];
4098 }
4099 # save reference to tag key lookup as value for Composite tag
4100 5513 my $key = $self->FoundTag($tagInfo, \%tagKey);
4101 } elsif (not defined $found) {
4102 3965 delete $notBuilt{$tagName}; # tag can't be built anyway
4103 }
4104 37011 ▶ last unless $subDoc;
Branch: 1 branch
BranchTrueFalseTotal
unless $subDoc 36803 208 37011
4105 # don't process sub-documents if there is no chance to build this tag
4106 # (can be very time-consuming if there are many docs)
4107 208 ▶ if (%$require) {
Branch: 1 branch
BranchTrueFalseTotal
if (%$require) { } 176 32 208
4108 176 foreach (keys %$require) {
4109 176 my $reqTag = $$require{$_};
4110 176 $reqTag =~ s/.*://;
4111 176 ▶ next COMPOSITE_TAG unless defined $$rawValue{$reqTag};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $rawValue->{$reqTag} 176 0 176
4112 }
4113 0 $docNum = 1; # go ahead and process the 1st sub-document
4114 } else {
4115 32 ▶ my @try = ref $$tagInfo{SubDoc} ? @{$$tagInfo{SubDoc}} : keys %$desire;
Branch: 1 branch
BranchTrueFalseTotal
ref $tagInfo->{'SubDoc'} ? : 32 0 32
4116 # at least one of the specified desire tags must exist
4117 32 foreach (@try) {
4118 64 ▶ my $desTag = $$desire{$_} or next;
Branch: 1 branch
BranchTrueFalseTotal
my $desTag = $desire->{$_} or next 64 0 64
4119 64 $desTag =~ s/.*://;
4120 64 ▶ defined $$rawValue{$desTag} and $docNum = 1, last;
Branch: 1 branch
BranchTrueFalseTotal
defined $rawValue->{$desTag} and $docNum = 1, last 0 64 64
4121 }
4122 32 ▶ last unless $docNum;
Branch: 1 branch
BranchTrueFalseTotal
unless $docNum 32 0 32
4123 }
4124 }
4125 }
4126 2363 ▶ last unless @deferredTags;
Branch: 1 branch
BranchTrueFalseTotal
unless @deferredTags 541 1822 2363
4127 1822 ▶ if (@deferredTags == @tagList) {
Branch: 1 branch
BranchTrueFalseTotal
if (@deferredTags == @tagList) 471 1351 1822
4128 471 ▶ if ($allBuilt) {
Branch: 1 branch
BranchTrueFalseTotal
if ($allBuilt) 0 471 471
4129 # everything was deferred in the last pass,
4130 # must be a circular dependency
4131 0 warn "Circular dependency in Composite tags\n";
4132 0 last;
4133 }
4134 471 $allBuilt = 1; # try once more, ignoring Composite Inhibit tags
4135 }
4136 1822 @tagList = @deferredTags; # calculate deferred tags now
4137 }
4138 541 delete $$self{BuildingComposite};
4139 }
4140  
4141 #------------------------------------------------------------------------------
4142 # Get reference to Composite tag info hash
4143 # Inputs: 0) case-sensitive Composite tag name
4144 # Returns: tagInfo hash or undef
4145 sub GetCompositeTagInfo($)
4146 11 ▶{
Subroutine GetCompositeTagInfo: called CC=2 SCAR=7.1
Pod undocumented
4147 11 my $tag = shift;
4148 11 ▶ return undef unless $compositeID{$tag};
Branch: 1 branch
BranchTrueFalseTotal
unless $compositeID{$tag} 0 11 11
4149 11 return $Image::ExifTool::Composite{$compositeID{$tag}[0]};
4150 }
4151  
4152 #------------------------------------------------------------------------------
4153 # Return List ExifTool API options
4154 # Returns: 0) reference to list of available options -- each entry is a list
4155 # [0=option name, 1=default value, 2=description]
4156 sub AvailableOptions()
4157 0 ▶{
Subroutine AvailableOptions: not called CC=1 SCAR=6.9
Pod documented
4158 0 return \@availableOptions;
4159 }
4160  
4161 #------------------------------------------------------------------------------
4162 # Get tag name (removes copy index)
4163 # Inputs: 0) Tag key
4164 # Returns: Tag name
4165 sub GetTagName($)
4166 17429 ▶{
Subroutine GetTagName: called CC=1 SCAR=0.0
Pod documented
4167 17429 local $_;
4168 17429 $_[0] =~ /^(\S+)/;
4169 17429 return $1;
4170 }
4171  
4172 #------------------------------------------------------------------------------
4173 # Get list of shortcuts
4174 # Returns: Shortcut list (sorted alphabetically)
4175 sub GetShortcuts()
4176 0 ▶{
Subroutine GetShortcuts: not called CC=1 SCAR=6.9
Pod documented
4177 0 local $_;
4178 0 require Image::ExifTool::Shortcuts;
4179 0 return sort keys %Image::ExifTool::Shortcuts::Main;
4180 }
4181  
4182 #------------------------------------------------------------------------------
4183 # Get file type for specified extension
4184 # Inputs: 0) file name or extension (case is not significant),
4185 # or FileType value if a description is requested
4186 # 1) flag to return long description instead of type ('0' to return any recognized type)
4187 # Returns: File type (or desc) or undef if extension not supported or if
4188 # description is the same as the input FileType. In list context,
4189 # may return more than one file type if the file may be different formats.
4190 # Returns list of all supported extensions if no file specified
4191 sub GetFileType(;$$)
4192 1010 ▶{
Subroutine GetFileType: called CC=30 SCAR=50.5
Pod documented
4193 1010 local $_;
4194 1010 my ($file, $desc) = @_;
4195 1010 ▶ unless (defined $file) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $file) 0 1010 1010
4196 0 my @types;
4197 0 ▶ if (defined $desc and $desc eq '0') {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $desc and $desc eq '0') { } 0 0 0
Condition0%0/3
defined $desc and $desc eq 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $desc and $desc eq 0
defined $desc $desc eq 0
Truth table0%0/3
A and B
A= defined $descB= $desc eq 0
ABresult
0X0
100
111
4198 # return all recognized types
4199 0 @types = sort keys %fileTypeLookup;
4200 } else {
4201 # return all supported types
4202 0 foreach (sort keys %fileTypeLookup) {
4203 0 my $module = $moduleName{$_};
4204 0 ▶ $module = $moduleName{$fileTypeLookup{$_}} unless defined $module;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $module 0 0 0
4205 0 ▶ push @types, $_ unless defined $module and $module eq '0';
Branch: 1 branch
BranchTrueFalseTotal
unless defined $module and $module eq 0 0 0 0
Condition0%0/3
defined $module and $module eq 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $module and $module eq 0
defined $module $module eq 0
Truth table0%0/3
A and B
A= defined $moduleB= $module eq 0
ABresult
0X0
100
111
4206 }
4207 }
4208 0 return @types;
4209 }
4210 1010 my ($fileType, $subType);
4211 1010 my $fileExt = GetFileExtension($file);
4212 1010 ▶ unless ($fileExt) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($fileExt) 73 937 1010
4213 73 ▶ if ($file =~ s/ \((.*)\)$//) {
Branch: 1 branch
BranchTrueFalseTotal
if ($file =~ s/ \((.*)\)$//) 0 73 73
4214 0 $subType = $1;
4215 0 $fileExt = GetFileExtension($file);
4216 }
4217 73 ▶ $fileExt = uc($file) unless $fileExt;
Branch: 1 branch
BranchTrueFalseTotal
unless $fileExt 73 0 73
4218 }
4219 1010 ▶ $fileExt and $fileType = $fileTypeLookup{$fileExt}; # look up the file type
Branch: 1 branch
BranchTrueFalseTotal
$fileExt and $fileType = $Image::ExifTool::fileTypeLookup{$fileExt} 962 48 1010
4220 1010 ▶ $fileType = $fileTypeLookup{$fileType} while $fileType and not ref $fileType;
Branch: 1 branch
BranchTrueFalseTotal
$fileType and not ref $fileType and do { $fileType = $Image::ExifTool::fileTypeLookup{$fileType} } 454 1010 1464
Condition100%3/3
$fileType and not ref $fileType
!ll&&!rl&&r
55955454
MC/DC100%2/2
$fileType and not ref $fileType
$fileType not ref $fileType
Truth table100%3/3
A and not(B)
A= $fileTypeB= not ref $fileType
ABresult
0X0
100
111
4221 # return description if specified
4222 # (allow input $file to be a FileType for this purpose)
4223 1010 ▶ if ($desc) {
Branch: 2 branches
BranchTrueFalseTotal
if ($desc) { } 0 1010 1010
elsif ($fileType and !defined($desc) || $desc ne '0') { } 955 110 1065
4224 0 ▶ if ($fileType) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fileType) { } 0 0 0
4225 0 ▶ if ($static_vars{OverrideFileDescription} and $static_vars{OverrideFileDescription}{$fileExt}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Image::ExifTool::static_vars{'OverrideFileDescription'} and $Image::ExifTool::static_vars{'OverrideFileDescription'}{$fileExt}) { } 0 0 0
Condition0%0/3
$Image::ExifTool::static_vars{"OverrideFileDescription"} and $Image::ExifTool::static_vars{"OverrideFileDescription"}{$fileExt}
!ll&&!rl&&r
000
MC/DC0%0/2
$Image::ExifTool::static_vars{"OverrideFileDescription"} and $Image::ExifTool::static_vars{"OverrideFileDescription"}{$fileExt}
$Image::ExifTool::static_vars{"OverrideFileDescription"} $Image::ExifTool::static_vars{"OverrideFileDescription"}{$fileExt}
Truth table0%0/3
A and B
A= $Image::ExifTool::static_vars{"OverrideFileDescription"}B= $Image::ExifTool::static_vars{"OverrideFileDescription"}{$fileExt}
ABresult
0X0
100
111
4226 0 $desc = $static_vars{OverrideFileDescription}{$fileExt};
4227 } else {
4228 0 $desc = $$fileType[1];
4229 }
4230 } else {
4231 0 ▶ $desc = $fileDescription{$file} || $file;
Condition0%0/3
$fileDescription{$file} || $file
l!l&&r!l&&!r
000
MC/DC0%0/2
$fileDescription{$file} || $file
$fileDescription{$file} $file
Truth table0%0/3
A || B
A= $fileDescription{$file}B= $file
ABresult
1X1
011
000
4232 }
4233 0 ▶ $desc .= ", $subType" if $subType;
Branch: 1 branch
BranchTrueFalseTotal
if $subType 0 0 0
4234 0 return $desc;
4235 ▶ } elsif ($fileType and (not defined $desc or $desc ne '0')) {
Condition50%3/6
$fileType and !defined($desc) || $desc ne 0
!ll&&!rl&&r
550955
not defined $desc or $desc ne 0
l!l&&r!l&&!r
95500
MC/DC33%1/3
$fileType and !defined($desc) || $desc ne 0
$fileType not defined $desc $desc ne 0
Truth table50%2/4
A and not(B) or C
A= $fileTypeB= not defined $descC= $desc ne 0
ABCresult
0XX0
1000
11X1
1011
4236 # return only supported file types
4237 955 my $mod = $moduleName{$$fileType[0]};
4238 955 ▶ undef $fileType if defined $mod and $mod eq '0';
Branch: 1 branch
BranchTrueFalseTotal
if defined $mod and $mod eq 0 0 955 955
Condition66%2/3
defined $mod and $mod eq 0
!ll&&!rl&&r
2676880
MC/DC0%0/2
defined $mod and $mod eq 0
defined $mod $mod eq 0
Truth table66%2/3
A and B
A= defined $modB= $mod eq 0
ABresult
0X0
100
111
4239 }
4240 1010 ▶ $fileType or return ();
Branch: 1 branch
BranchTrueFalseTotal
$fileType or return () 955 55 1010
4241 955 $fileType = $$fileType[0]; # get file type (or list of types)
4242 955 ▶ if (wantarray) {
Branch: 2 branches
BranchTrueFalseTotal
if (wantarray) { } 716 239 955
elsif ($fileType) { } 239 0 239
4243 716 ▶ return @$fileType if ref $fileType eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $fileType eq "ARRAY" 4 712 716
4244 } elsif ($fileType) {
4245 239 ▶ $fileType = $fileExt if ref $fileType eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $fileType eq "ARRAY" 0 239 239
4246 }
4247 951 return $fileType;
4248 }
4249  
4250 #------------------------------------------------------------------------------
4251 # Return true if we can write the specified file type
4252 # Inputs: 0) file name or ext
4253 # Returns: true if writable, 0 if not writable, '' if not writable due to extension,
4254 # undef if unrecognized
4255 sub CanWrite($)
4256 0 ▶{
Subroutine CanWrite: not called CC=13 SCAR=52.0
Pod documented
4257 0 local $_;
4258 0 ▶ my $file = shift or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $file = shift() or return undef 0 0 0
4259 0 ▶ my ($type) = GetFileType($file) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my($type) = &GetFileType($file) or return undef 0 0 0
4260 0 ▶ if ($noWriteFile{$type}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Image::ExifTool::noWriteFile{$type}) 0 0 0
4261 # can't write TIFF files with certain extensions (various RAW formats)
4262 0 ▶ my $ext = GetFileExtension($file) || uc($file);
Condition0%0/3
&GetFileExtension($file) || uc $file
l!l&&r!l&&!r
000
MC/DC0%0/2
&GetFileExtension($file) || uc $file
&GetFileExtension($file) uc $file
Truth table0%0/3
A || B
A= &GetFileExtension($file)B= uc $file
ABresult
1X1
011
000
4263 0 ▶ return grep(/^$ext$/, @{$noWriteFile{$type}}) ? '' : 1 if $ext;
Branch: 2 branches
BranchTrueFalseTotal
if $ext 0 0 0
grep(/^$ext$/, @{$Image::ExifTool::noWriteFile{$type};}) ? : 0 0 0
4264 }
4265 0 ▶ if ($onlyWriteFile{$type}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($onlyWriteFile{$type}) 0 0 0
4266 0 ▶ my $ext = GetFileExtension($file) || uc($file);
Condition0%0/3
&GetFileExtension($file) || uc $file
l!l&&r!l&&!r
000
MC/DC0%0/2
&GetFileExtension($file) || uc $file
&GetFileExtension($file) uc $file
Truth table0%0/3
A || B
A= &GetFileExtension($file)B= uc $file
ABresult
1X1
011
000
4267 0 ▶ return grep(/^$ext$/, @{$onlyWriteFile{$type}}) ? 1 : 0 if $ext;
Branch: 2 branches
BranchTrueFalseTotal
if $ext 0 0 0
grep(/^$ext$/, @{$onlyWriteFile{$type};}) ? : 0 0 0
4268 }
4269 0 ▶ unless (%writeTypes) {
Branch: 1 branch
BranchTrueFalseTotal
unless (%writeTypes) 0 0 0
4270 0 $writeTypes{$_} = 1 foreach @writeTypes;
4271 }
4272 0 return $writeTypes{$type};
4273 }
4274  
4275 #------------------------------------------------------------------------------
4276 # Return true if we can create the specified file type
4277 # Inputs: 0) file name or ext
4278 # Returns: true if creatable, 0 if not writable, undef if unrecognized
4279 sub CanCreate($)
4280 24 ▶{
Subroutine CanCreate: called CC=6 SCAR=22.1
Pod documented
4281 24 local $_;
4282 24 ▶ my $file = shift or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $file = shift() or return undef 24 0 24
4283 24 ▶ my $ext = GetFileExtension($file) || uc($file);
Condition33%1/3
&GetFileExtension($file) || uc $file
l!l&&r!l&&!r
0240
MC/DC0%0/2
&GetFileExtension($file) || uc $file
&GetFileExtension($file) uc $file
Truth table33%1/3
A || B
A= &GetFileExtension($file)B= uc $file
ABresult
1X1
011
000
4284 24 ▶ my $type = GetFileType($file) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $type = &GetFileType($file) or return undef 24 0 24
4285 24 ▶ return 1 if $createTypes{$ext} or $createTypes{$type};
Branch: 1 branch
BranchTrueFalseTotal
if $createTypes{$ext} or $createTypes{$type} 24 0 24
Condition33%1/3
$createTypes{$ext} or $createTypes{$type}
l!l&&r!l&&!r
2400
MC/DC0%0/2
$createTypes{$ext} or $createTypes{$type}
$createTypes{$ext} $createTypes{$type}
Truth table33%1/3
A or B
A= $createTypes{$ext}B= $createTypes{$type}
ABresult
1X1
011
000
4286 0 return 0;
4287 }
4288  
4289 #------------------------------------------------------------------------------
4290 # Return list of ordered keys if available, otherwise just sort alphabetically
4291 # Inputs: 0) hash ref
4292 # Returns: List of ordered/sorted keys
4293 sub OrderedKeys($)
4294 357 ▶{
Subroutine OrderedKeys: called CC=2 SCAR=6.9
Pod documented
4295 357 my $hash = shift;
4296 357 ▶ return $$hash{_ordered_keys_} ? @{$$hash{_ordered_keys_}} : sort keys %$hash;
Branch: 1 branch
BranchTrueFalseTotal
$hash->{'_ordered_keys_'} ? : 111 246 357
4297 }
4298  
4299 #==============================================================================
4300 # Functions below this are not part of the public API
4301  
4302 # Initialize member variables before reading or writing a new file
4303 # Inputs: 0) ExifTool object reference
4304 sub Init($)
4305 818 ▶{
Subroutine Init: called CC=4 SCAR=13.9
Pod undocumented
4306 818 local $_;
4307 818 my $self = shift;
4308 # delete all DataMember variables (lower-case names)
4309 818 delete $$self{$_} foreach grep /[a-z]/, keys %$self;
4310 # reset static variables
4311 %static_vars = (
4312 KeepUTCTime => $$self{OPTIONS}{KeepUTCTime},
4313 SystemTimeRes => $$self{OPTIONS}{SystemTimeRes},
4314 818 );
4315 818 delete $$self{FOUND_TAGS}; # list of found tags
4316 818 delete $$self{EXIF_DATA}; # the EXIF data block
4317 818 delete $$self{EXIF_POS}; # EXIF position in file
4318 818 delete $$self{FIRST_EXIF_POS}; # position of first EXIF in file
4319 818 delete $$self{HTML_DUMP}; # html dump information
4320 818 delete $$self{SET_GROUP0}; # group0 name override
4321 818 delete $$self{SET_GROUP1}; # group1 name override
4322 818 delete $$self{DOC_NUM}; # current embedded document number
4323 818 $$self{DOC_COUNT} = 0; # count of embedded documents processed
4324 818 $$self{BASE} = 0; # base for offsets from start of file
4325 818 $$self{FILE_ORDER} = { }; # * hash of tag order in file ('*' = based on tag key)
4326 818 $$self{VALUE} = { }; # * hash of raw tag values
4327 818 $$self{BOTH} = { }; # * hash for Value/PrintConv values of Require'd tags
4328 818 $$self{TAG_INFO} = { }; # * hash of tag information
4329 818 $$self{TAG_EXTRA} = { }; # * hash of extra tag information (dynamic group names)
4330 818 $$self{PRIORITY} = { }; # * priority of current tags
4331 818 $$self{LIST_TAGS} = { }; # hash of tagInfo refs for active List-type tags
4332 818 $$self{PROCESSED} = { }; # hash of processed directory start positions
4333 818 $$self{DIR_COUNT} = { }; # count various types of directories
4334 818 $$self{DUPL_TAG} = { }; # last-used index for duplicate-tag keys
4335 818 $$self{WAS_WARNED} = { }; # number of times each warning was issued
4336 818 $$self{WRITTEN} = { }; # list of tags written (selected tags only)
4337 818 $$self{FORCE_WRITE}= { }; # ForceWrite lookup (set from ForceWrite tag)
4338 818 $$self{FOUND_DIR} = { }; # hash of directory names found in file
4339 818 $$self{COMP_KEYS} = { }; # lookup for tag keys used in Composite tags
4340 818 $$self{PATH} = [ ]; # current subdirectory path in file when reading
4341 818 $$self{NUM_FOUND} = 0; # total number of tags found (incl. duplicates)
4342 818 $$self{CHANGED} = 0; # number of tags changed (writer only)
4343 818 $$self{INDENT} = ' '; # initial indent for verbose messages
4344 818 $$self{PRIORITY_DIR} = ''; # the priority directory name
4345 818 $$self{LOW_PRIORITY_DIR} = { PreviewIFD => 1 }; # names of priority 0 directories
4346 818 $$self{TIFF_TYPE} = ''; # type of TIFF data (APP1, TIFF, NEF, etc...)
4347 818 $$self{FMT_EXPR} = undef; # current advanced formatting expression
4348 818 $$self{HAS_DOC} = { }; # lookup for all document numbers in this file
4349 818 $$self{Make} = ''; # camera make
4350 818 $$self{Model} = ''; # camera model
4351 818 $$self{CameraType} = ''; # Olympus camera type
4352 818 $$self{FileType} = ''; # identified file type
4353 818 ▶ if ($self->Options('HtmlDump')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->Options("HtmlDump")) 0 818 818
4354 0 require Image::ExifTool::HtmlDump;
4355 0 $$self{HTML_DUMP} = Image::ExifTool::HtmlDump->new;
4356 }
4357 # make sure our TextOut is a file reference
4358 818 ▶ $$self{OPTIONS}{TextOut} = \*STDOUT unless ref $$self{OPTIONS}{TextOut};
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self->{"OPTIONS"}{"TextOut"} 0 818 818
4359 }
4360  
4361 #------------------------------------------------------------------------------
4362 # Purge temporary tags from memory and set purge flag for next time
4363 # Inputs: 0) false=disable purging, true=enable purging, and
4364 # purge now if number of digits in tags to purge >= flag
4365 sub Purge(;$)
4366 0 ▶{
Subroutine Purge: not called CC=6 SCAR=37.4
Pod undocumented
4367 0 ▶ $purgeFlag = shift || 0;
Condition0%0/2
shift() || 0
l!l
00
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
4368 0 ▶ if (@purgeTags and length(scalar @purgeTags) >= $purgeFlag) {
Branch: 1 branch
BranchTrueFalseTotal
if (@purgeTags and length scalar @purgeTags >= $purgeFlag) 0 0 0
Condition0%0/3
@purgeTags and length scalar @purgeTags >= $purgeFlag
!ll&&!rl&&r
000
MC/DC0%0/2
@purgeTags and length scalar @purgeTags >= $purgeFlag
@purgeTags length scalar @purgeTags >= $purgeFlag
Truth table0%0/3
A and B
A= @purgeTagsB= length scalar @purgeTags >= $purgeFlag
ABresult
0X0
100
111
4369 0 foreach (@purgeTags) {
4370 0 ▶ delete $$_{Table}{$$_{TagID}} unless defined $$_{IsProtobuf};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_->{"IsProtobuf"} 0 0 0
4371 }
4372 0 undef @purgeTags;
4373 }
4374 }
4375  
4376 #------------------------------------------------------------------------------
4377 # Combine information from a list of info hashes
4378 # Unless Duplicates is enabled, first entry found takes priority
4379 # Inputs: 0) ExifTool object reference, 1-N) list of info hash references
4380 # Returns: Combined information hash reference
4381 sub CombineInfo($;@)
4382 2 ▶{
Subroutine CombineInfo: called CC=7 SCAR=20.8
Pod undocumented
4383 2 local $_;
4384 2 my $self = shift;
4385 2 my (%combinedInfo, $info, $tag, %haveInfo);
4386  
4387 2 ▶ if ($$self{OPTIONS}{Duplicates}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'OPTIONS'}{'Duplicates'}) { } 0 2 2
4388 0 ▶ while ($info = shift) {
Branch: 1 branch
BranchTrueFalseTotal
if ($info = shift()) 0 0 0
4389 0 foreach $tag (keys %$info) {
4390 0 $combinedInfo{$tag} = $$info{$tag};
4391 }
4392 }
4393 } else {
4394 2 ▶ while ($info = shift) {
Branch: 1 branch
BranchTrueFalseTotal
if ($info = shift()) 4 2 6
4395 4 foreach $tag (keys %$info) {
4396 266 my $tagName = GetTagName($tag);
4397 266 ▶ next if $haveInfo{$tagName};
Branch: 1 branch
BranchTrueFalseTotal
if $haveInfo{$tagName} 14 252 266
4398 252 $haveInfo{$tagName} = 1;
4399 252 $combinedInfo{$tag} = $$info{$tag};
4400 }
4401 }
4402 }
4403 2 return \%combinedInfo;
4404 }
4405  
4406 #------------------------------------------------------------------------------
4407 # Finish generating tags after extracting information from a file
4408 # Inputs: 0) ExifTool ref
4409 # Notes: The sequencing here is a bit tricky because tags from the main file
4410 # may be used in the names of alternate files, so we finish generating
4411 # all main file tags first (including all Composite tags which don't
4412 # rely on alternate files) before extracting tags from alternate files,
4413 # then we finish by generating the remaingin Composite tags.
4414 sub DoneExtract($)
4415 550 ▶{
Subroutine DoneExtract: called CC=71 SCAR=56.0
Pod undocumented
4416 550 my $self = shift;
4417 # extract information from alternate files if necessary
4418 550 my ($g8, $altExifTool);
4419 550 my $opts = $$self{OPTIONS};
4420  
4421 # generate ImageDataHash if requested
4422 550 ▶ if ($$self{ImageDataHash}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"ImageDataHash"}) 0 550 550
4423 0 my $digest = $$self{ImageDataHash}->hexdigest;
4424 # (don't store empty digest)
4425 0 ▶ $self->FoundTag(ImageDataHash => $digest) unless
Branch: 1 branch
BranchTrueFalseTotal
unless $digest eq "d41d8cd98f00b204e9800998ecf8427e" or $digest eq "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" or $digest eq "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e" 0 0 0
Condition0%0/6
$digest eq "d41d8cd98f00b204e9800998ecf8427e" or $digest eq "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" or $digest eq "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e"
l!l&&r!l&&!r
000
$digest eq "d41d8cd98f00b204e9800998ecf8427e" or $digest eq "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
l!l&&r!l&&!r
000
MC/DC0%0/3
$digest eq "d41d8cd98f00b204e9800998ecf8427e" or $digest eq "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" or $digest eq "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e"
$digest eq "d41d8cd98f00b204e9800998ecf8427e" $digest eq "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" $digest eq "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e"
Truth table0%0/4
A or B or C
A= $digest eq "d41d8cd98f00b204e9800998ecf8427e"B= $digest eq "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"C= $digest eq "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e"
ABCresult
1XX1
01X1
0011
0000
4426 $digest eq 'd41d8cd98f00b204e9800998ecf8427e' or
4427 $digest eq 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' or
4428 $digest eq 'cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e';
4429 }
4430 # generate Validate tag if requested
4431 550 ▶ if ($$opts{Validate}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{"Validate"}) 1 549 550
4432 1 Image::ExifTool::Validate::FinishValidate($self, $$self{REQ_TAG_LOOKUP}{validate});
4433 }
4434 # generate geolocation tags if requested
4435 550 ▶ if ($$opts{Geolocation}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{"Geolocation"}) 4 546 550
4436 4 my ($arg, @defaults, @tags, $tag, @coord, @ref, @city, $doneCity, $both);
4437 4 my $geoOpt = $$opts{Geolocation};
4438 4 my @args = split /\s*,\s*/, $$opts{Geolocation};
4439 4 foreach $arg (@args) {
4440 8 ▶ lc $arg eq 'both' and $both = 1, next;
Branch: 1 branch
BranchTrueFalseTotal
lc $arg eq "both" and $both = 1, next 0 8 8
4441 8 ▶ $arg !~ s/^\$// and push(@defaults, $arg), next;
Branch: 1 branch
BranchTrueFalseTotal
$arg =~ s/^\$// or push(@defaults, $arg), next 0 8 8
4442 0 push @tags, $arg; # argument is a tag name
4443 }
4444 4 ▶ unless (@tags) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@tags) 4 0 4
4445 # default tags to read if not specified
4446 4 @tags = qw(GPSLatitude GPSLongitude GPSLatitudeRef GPSLongitudeRef
4447 GPSCoordinates LocationShownGPSLatitude LocationShownGPSLongitude
4448 XMP:City State CountryCode Country
4449 IPTC:City Province-State Country-PrimaryLocationCode Country-PrimaryLocationName
4450 LocationShownCity LocationShownProvinceState LocationShownCountryCode LocationShownCountryName);
4451 }
4452 # get information for specified tags
4453 4 my $info = $self->GetInfo(\@tags, { PrintConv => 0, Duplicates => 0 }); # (returns tags in proper case)
4454 4 $opts = $$self{OPTIONS}; # (necessary because GetInfo changes the OPTIONS hash)
4455 4 foreach $tag (@tags) {
4456 76 my $val = $$info{$tag};
4457 76 ▶ next unless defined $val;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $val 69 7 76
4458 7 $self->VPrint(0, "Found $tag ($val)\n");
4459 7 ▶ if ($tag =~ /Coordinates/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag =~ /Coordinates/) 0 7 7
4460 0 ▶ next if defined $coord[0] and defined $coord[1];
Branch: 1 branch
BranchTrueFalseTotal
if defined $coord[0] and defined $coord[1] 0 0 0
Condition0%0/3
defined $coord[0] and defined $coord[1]
!ll&&!rl&&r
000
MC/DC0%0/2
defined $coord[0] and defined $coord[1]
defined $coord[0] defined $coord[1]
Truth table0%0/3
A and B
A= defined $coord[0]B= defined $coord[1]
ABresult
0X0
100
111
4461 0 @coord = split ' ', $val;
4462 0 next;
4463 }
4464 7 ▶ my $n = $tag =~ /Latitude/ ? 0 : ($tag =~ /Longitude/ ? 1 : undef);
Branch: 2 branches
BranchTrueFalseTotal
$tag =~ /Latitude/ ? : 2 5 7
$tag =~ /Longitude/ ? : 2 3 5
4465 7 ▶ if (defined $n) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $n) 4 3 7
4466 4 ▶ if ($tag =~ /Ref$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag =~ /Ref$/) { } 2 2 4
4467 2 ▶ $ref[$n] = $val unless $ref[$n];
Branch: 1 branch
BranchTrueFalseTotal
unless $ref[$n] 2 0 2
4468 } else {
4469 2 ▶ $coord[$n] = $val unless defined $coord[$n];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $coord[$n] 2 0 2
4470 }
4471 4 next;
4472 }
4473 # handle city tags (save info for first city found)
4474 3 ▶ if ($tag =~ /City/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($tag =~ /City/) { } 1 2 3
elsif (@city) { } 2 0 2
4475 1 ▶ @city and $doneCity = 1, next;
Branch: 1 branch
BranchTrueFalseTotal
@city and $doneCity = 1, next 0 1 1
4476 1 push @city, $val;
4477 } elsif (@city) {
4478 2 ▶ push @city, $val unless $doneCity;
Branch: 1 branch
BranchTrueFalseTotal
unless $doneCity 2 0 2
4479 2 ▶ next if $doneCity;
Branch: 1 branch
BranchTrueFalseTotal
if $doneCity 0 2 2
4480 }
4481 }
4482 4 ▶ if (defined $coord[0] and defined $coord[1]) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $coord[0] and defined $coord[1]) { } 1 3 4
elsif (@city) { } 0 3 3
Condition66%2/3
defined $coord[0] and defined $coord[1]
!ll&&!rl&&r
301
MC/DC50%1/2
defined $coord[0] and defined $coord[1]
defined $coord[0] defined $coord[1]
Truth table66%2/3
A and B
A= defined $coord[0]B= defined $coord[1]
ABresult
0X0
100
111
4483 1 ▶ $coord[0] = -$coord[0] if $ref[0] and $coord[0] > 0 and $ref[0] eq 'S';
Branch: 1 branch
BranchTrueFalseTotal
if $ref[0] and $coord[0] > 0 and $ref[0] eq "S" 0 1 1
Condition33%2/6
$ref[0] and $coord[0] > 0 and $ref[0] eq "S"
!ll&&!rl&&r
010
$ref[0] and $coord[0] > 0
!ll&&!rl&&r
001
MC/DC0%0/3
$ref[0] and $coord[0] > 0 and $ref[0] eq "S"
$ref[0] $coord[0] > 0 $ref[0] eq "S"
Truth table25%1/4
A and B and C
A= $ref[0]B= $coord[0] > 0C= $ref[0] eq "S"
ABCresult
0XX0
10X0
1100
1111
4484 1 ▶ $coord[1] = -$coord[1] if $ref[1] and $coord[1] > 0 and $ref[1] eq 'W';
Branch: 1 branch
BranchTrueFalseTotal
if $ref[1] and $coord[1] > 0 and $ref[1] eq "W" 1 0 1
Condition33%2/6
$ref[1] and $coord[1] > 0 and $ref[1] eq "W"
!ll&&!rl&&r
001
$ref[1] and $coord[1] > 0
!ll&&!rl&&r
001
MC/DC0%0/3
$ref[1] and $coord[1] > 0 and $ref[1] eq "W"
$ref[1] $coord[1] > 0 $ref[1] eq "W"
Truth table25%1/4
A and B and C
A= $ref[1]B= $coord[1] > 0C= $ref[1] eq "W"
ABCresult
0XX0
10X0
1100
1111
4485 1 $arg = join ',', @coord;
4486 } elsif (@city) {
4487 0 $arg = join ',', @city;
4488 }
4489 4 ▶ if (not defined $arg) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $arg) 3 1 4
4490 # use specified default values if no tags found
4491 3 $arg = join ',', @defaults;
4492 3 ▶ undef $arg if $arg eq '1';
Branch: 1 branch
BranchTrueFalseTotal
if $arg eq 1 0 3 3
4493 3 $both = 1; # use 'both' GPS and place names if provided
4494 }
4495 4 ▶ if ($arg) {
Branch: 1 branch
BranchTrueFalseTotal
if ($arg) 4 0 4
4496 4 ▶ $arg .= ',both' if $both;
Branch: 1 branch
BranchTrueFalseTotal
if $both 3 1 4
4497 4 $arg = $self->Encode($arg, 'UTF8');
4498 4 require Image::ExifTool::Geolocation;
4499 4 ▶ if ($$opts{Verbose}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{"Verbose"}) 0 4 4
4500 0 ▶ if ($Image::ExifTool::Geolocation::dbInfo) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Image::ExifTool::Geolocation::dbInfo) { } 0 0 0
4501 0 print "Loaded $Image::ExifTool::Geolocation::dbInfo\n";
4502 } else {
4503 0 print "Error loading Geolocation.dat\n";
4504 }
4505 }
4506 4 local $SIG{'__WARN__'} = \&SetWarning;
4507 4 undef $evalWarning;
4508 4 $$opts{GeolocMulti} = $$opts{Duplicates};
4509 4 $self->VPrint(0, "Geolocation arguments: '${arg}'\n");
4510 4 my ($cities, $dist) = Image::ExifTool::Geolocation::Geolocate($arg, $opts);
4511 4 delete $$opts{GeolocMulti};
4512 4 ▶ if ($cities and (@$cities < 2 or $dist or not $self->Warn('Multiple Geolocation cities are possible',2))) {
Branch: 2 branches
BranchTrueFalseTotal
if ($cities and @$cities < 2 || $dist || !$self->Warn('Multiple Geolocation cities are possible', 2)) { } 4 0 4
elsif ($Image::ExifTool::evalWarning) { } 0 0 0
Condition44%4/9
$cities and @$cities < 2 || $dist || !$self->Warn("Multiple Geolocation cities are possible", 2)
!ll&&!rl&&r
004
@$cities < 2 or $dist or not $self->Warn("Multiple Geolocation cities are possible", 2)
l!l&&r!l&&!r
400
@$cities < 2 or $dist
l!l&&r!l&&!r
310
MC/DC0%0/4
$cities and @$cities < 2 || $dist || !$self->Warn("Multiple Geolocation cities are possible", 2)
$cities @$cities < 2 $dist not $self->Warn("Multiple Geolocation cities are possible", 2)
Truth table40%2/5
A and B or C or not(D)
A= $citiesB= @$cities < 2C= $distD= not $self->Warn("Multiple Geolocation cities are possible", 2)
ABCDresult
0XXX0
10000
11XX1
101X1
10011
4513 4 ▶ $self->FoundTag(GeolocationWarning => 'Search matched '.scalar(@$cities).' cities') if @$cities > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @$cities > 1 1 3 4
4514 4 my $city;
4515 4 foreach $city (@$cities) {
4516 5 ▶ $$self{DOC_NUM} = ++$$self{DOC_COUNT} unless $city eq $$cities[0];
Branch: 1 branch
BranchTrueFalseTotal
unless $city eq $cities->[0] 1 4 5
4517 5 my @geo = Image::ExifTool::Geolocation::GetEntry($city, $$opts{Lang});
4518 5 $self->FoundTag(GeolocationCity => $geo[0]);
4519 5 ▶ $self->FoundTag(GeolocationRegion => $geo[1]) if $geo[1];
Branch: 1 branch
BranchTrueFalseTotal
if $geo[1] 5 0 5
4520 5 ▶ $self->FoundTag(GeolocationSubregion => $geo[2]) if $geo[2];
Branch: 1 branch
BranchTrueFalseTotal
if $geo[2] 5 0 5
4521 5 $self->FoundTag(GeolocationCountryCode => $geo[3]);
4522 5 ▶ $self->FoundTag(GeolocationCountry => $geo[4]) if $geo[4];
Branch: 1 branch
BranchTrueFalseTotal
if $geo[4] 5 0 5
4523 5 ▶ $self->FoundTag(GeolocationTimeZone => $geo[5]) if $geo[5];
Branch: 1 branch
BranchTrueFalseTotal
if $geo[5] 5 0 5
4524 5 $self->FoundTag(GeolocationFeatureCode => $geo[6]);
4525 5 ▶ $self->FoundTag(GeolocationFeatureType => $geo[10]) if $geo[10];
Branch: 1 branch
BranchTrueFalseTotal
if $geo[10] 4 1 5
4526 5 $self->FoundTag(GeolocationPopulation => $geo[7]);
4527 5 $self->FoundTag(GeolocationPosition => "$geo[8] $geo[9]");
4528 5 ▶ if ($dist) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dist) 4 1 5
4529 4 $self->FoundTag(GeolocationDistance => $$dist[0][0]);
4530 4 $self->FoundTag(GeolocationBearing => $$dist[0][1]);
4531 4 shift @$dist;
4532 }
4533 5 ▶ last unless $$opts{Duplicates};
Branch: 1 branch
BranchTrueFalseTotal
unless $opts->{"Duplicates"} 0 5 5
4534 }
4535 4 delete $$self{DOC_NUM};
4536 } elsif ($evalWarning) {
4537 0 $self->Warn(CleanWarning());
4538 }
4539 }
4540 }
4541 # generate tags for user-defined parameters that ended with '#'
4542 550 ▶ if (%{$$opts{UserParam}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (%{$opts->{"UserParam"};}) 0 550 550
4543 0 my $doMsg = $$opts{Verbose};
4544 0 my $table = GetTagTable('Image::ExifTool::UserParam');
4545 0 foreach (sort keys %{$$opts{UserParam}}) {
4546 0 ▶ next unless /#$/;
Branch: 1 branch
BranchTrueFalseTotal
unless /#$/ 0 0 0
4547 0 ▶ if ($doMsg) {
Branch: 1 branch
BranchTrueFalseTotal
if ($doMsg) 0 0 0
4548 0 $self->VPrint(0, "UserParam tags:\n");
4549 0 undef $doMsg;
4550 }
4551 0 $self->HandleTag($table, $_, $$opts{UserParam}{$_});
4552 }
4553 }
4554 550 ▶ if ($$opts{Composite} and (not $$opts{FastScan} or $$opts{FastScan} < 5)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{"Composite"} and !$opts->{"FastScan"} || $opts->{"FastScan"} < 5) 540 10 550
Condition66%4/6
$opts->{"Composite"} and !$opts->{"FastScan"} || $opts->{"FastScan"} < 5
!ll&&!rl&&r
100540
not $opts->{"FastScan"} or $opts->{"FastScan"} < 5
l!l&&r!l&&!r
53910
MC/DC33%1/3
$opts->{"Composite"} and !$opts->{"FastScan"} || $opts->{"FastScan"} < 5
$opts->{"Composite"} not $opts->{"FastScan"} $opts->{"FastScan"} < 5
Truth table75%3/4
A and not(B) or C
A= $opts->{"Composite"}B= not $opts->{"FastScan"}C= $opts->{"FastScan"} < 5
ABCresult
0XX0
1000
11X1
1011
4555 # build all composite tags except those requiring tags from alternate files
4556 540 $self->BuildCompositeTags();
4557 }
4558 550 foreach $g8 (sort keys %{$$self{ALT_EXIFTOOL}}) {
4559 8 $altExifTool = $$self{ALT_EXIFTOOL}{$g8};
4560 8 ▶ next if $$altExifTool{DID_EXTRACT}; # avoid extracting twice
Branch: 1 branch
BranchTrueFalseTotal
if $altExifTool->{"DID_EXTRACT"} 2 6 8
4561 6 $$altExifTool{OPTIONS} = $$self{OPTIONS};
4562 6 $$altExifTool{GLOBAL_TIME_OFFSET} = $$self{GLOBAL_TIME_OFFSET};
4563 6 $$altExifTool{REQ_TAG_LOOKUP} = $$self{REQ_TAG_LOOKUP};
4564 6 $$altExifTool{ReqTagAlreadySet} = 1;
4565 6 my $fileName = $$altExifTool{ALT_FILE};
4566 # allow tags from the main file to be used in the alternate file names
4567 # (eg. -file1 '$originalfilename')
4568 6 ▶ if ($fileName =~ /\$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fileName =~ /\$/) 0 6 6
4569 0 my @tags = reverse sort keys %{$$self{VALUE}};
4570 0 $fileName = $self->InsertTagValues($fileName, \@tags, 'Warn');
4571 0 ▶ next unless defined $fileName;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fileName 0 0 0
4572 }
4573 6 $altExifTool->ExtractInfo($fileName);
4574 6 my $err = $$altExifTool{VALUE}{Error};
4575 6 ▶ $err and $self->Warn(qq{$err "$fileName"});
Branch: 1 branch
BranchTrueFalseTotal
$err and $self->Warn(qq[$err "$fileName"]) 0 6 6
4576 # set family 8 group name for all tags
4577 6 $$altExifTool{TAG_EXTRA}{$_}{G8} = $g8 foreach keys %{$$altExifTool{VALUE}};
4578 # prepare our sorted list of found tags
4579 6 $$altExifTool{FoundTags} = $altExifTool->SetFoundTags();
4580 6 $$altExifTool{DID_EXTRACT} = 1;
4581 }
4582 # if necessary, build composite tags that rely on tags from alternate files
4583 550 ▶ $self->BuildCompositeTags(1) if $$self{DoAltComposite};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"DoAltComposite"} 1 549 550
4584 }
4585  
4586 #------------------------------------------------------------------------------
4587 # Get tag table name
4588 # Inputs: 0) ExifTool object reference, 1) tag key
4589 # Returns: Table name if available, otherwise ''
4590 sub GetTableName($$)
4591 0 ▶{
Subroutine GetTableName: not called CC=2 SCAR=17.9
Pod undocumented
4592 0 my ($self, $tag) = @_;
4593 0 ▶ my $tagInfo = $$self{TAG_INFO}{$tag} or return '';
Branch: 1 branch
BranchTrueFalseTotal
my $tagInfo = $self->{"TAG_INFO"}{$tag} or return "" 0 0 0
4594 0 return $$tagInfo{Table}{SHORT_NAME};
4595 }
4596  
4597 #------------------------------------------------------------------------------
4598 # Get tag index number
4599 # Inputs: 0) ExifTool object reference, 1) tag key
4600 # Returns: Table index number, or undefined if this tag isn't indexed
4601 sub GetTagIndex($$)
4602 0 ▶{
Subroutine GetTagIndex: not called CC=2 SCAR=17.9
Pod undocumented
4603 0 my ($self, $tag) = @_;
4604 0 ▶ my $tagInfo = $$self{TAG_INFO}{$tag} or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $tagInfo = $self->{"TAG_INFO"}{$tag} or return undef 0 0 0
4605 0 return $$tagInfo{Index};
4606 }
4607  
4608 #------------------------------------------------------------------------------
4609 # Find value for specified tag
4610 # Inputs: 0) ExifTool ref, 1) tag name, 2) tag group (family 1)
4611 # Returns: value or undef
4612 sub FindValue($$$)
4613 72 ▶{
Subroutine FindValue: called CC=4 SCAR=13.9
Pod undocumented
4614 72 my ($et, $tag, $grp) = @_;
4615 72 my ($i, $val);
4616 72 my $value = $$et{VALUE};
4617 72 for ($i=0; ; ++$i) {
4618 144 ▶ my $key = $tag . ($i ? " ($i)" : '');
Branch: 1 branch
BranchTrueFalseTotal
$i ? : 72 72 144
4619 144 ▶ last unless defined $$value{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value->{$key} 2 142 144
4620 142 ▶ if ($et->GetGroup($key, 1) eq $grp) {
Branch: 1 branch
BranchTrueFalseTotal
if ($et->GetGroup($key, 1) eq $grp) 70 72 142
4621 70 $val = $$value{$key};
4622 70 last;
4623 }
4624 }
4625 72 return $val;
4626 }
4627  
4628 #------------------------------------------------------------------------------
4629 # Get tag key for next existing tag
4630 # Inputs: 0) ExifTool ref, 1) tag key or case-sensitive tag name
4631 # Returns: Key of next existing tag, or undef if no more
4632 # Notes: This routine is provided for iterating through duplicate tags in the
4633 # ValueConv of Composite tags.
4634 sub NextTagKey($$)
4635 23 ▶{
Subroutine NextTagKey: called CC=3 SCAR=11.3
Pod undocumented
4636 23 my ($self, $tag) = @_;
4637 23 ▶ my $i = ($tag =~ s/ \((\d+)\)$//) ? $1 + 1 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$tag =~ s/ \((\d+)\)$// ? : 0 23 23
4638 23 $tag = "$tag ($i)";
4639 23 ▶ return $tag if defined $$self{VALUE}{$tag};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"VALUE"}{$tag} 0 23 23
4640 23 return undef;
4641 }
4642  
4643 #------------------------------------------------------------------------------
4644 # Does a string contain valid UTF-8 characters?
4645 # Inputs: 0) string reference, 1) true to allow last character to be truncated
4646 # Returns: 0=regular ASCII, -1=invalid UTF-8, 1=valid UTF-8 with maximum 16-bit
4647 # wide characters, 2=valid UTF-8 requiring 32-bit wide characters
4648 # Notes: Changes current string position
4649 # (see http://www.fileformat.info/info/unicode/utf8.htm for help understanding this)
4650 sub IsUTF8($;$)
4651 125 ▶{
Subroutine IsUTF8: called CC=23 SCAR=37.5
Pod undocumented
4652 125 my ($strPt, $trunc) = @_;
4653 125 pos($$strPt) = 0; # start at beginning of string
4654 125 ▶ return 0 unless $$strPt =~ /([\x80-\xff])/g;
Branch: 1 branch
BranchTrueFalseTotal
unless $$strPt =~ /([\x80-\xff])/g 69 56 125
4655 56 my $rtnVal = 1;
4656 56 for (;;) {
4657 198 my $ch = ord($1);
4658 # minimum lead byte for 2-byte sequence is 0xc2 (overlong sequences
4659 # not allowed), 0xf8-0xfd are restricted by RFC 3629 (no 5 or 6 byte
4660 # sequences), and 0xfe and 0xff are not valid in UTF-8 strings
4661 198 ▶ return -1 if $ch < 0xc2 or $ch >= 0xf8;
Branch: 1 branch
BranchTrueFalseTotal
if $ch < 194 or $ch >= 248 45 153 198
Condition100%3/3
$ch < 194 or $ch >= 248
l!l&&r!l&&!r
441153
MC/DC100%2/2
$ch < 194 or $ch >= 248
$ch < 194 $ch >= 248
Truth table100%3/3
A or B
A= $ch < 194B= $ch >= 248
ABresult
1X1
011
000
4662 # determine number of bytes remaining in sequence
4663 153 my $n;
4664 153 ▶ if ($ch < 0xe0) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ch < 224) { } 75 78 153
elsif ($ch < 240) { } 78 0 78
4665 75 $n = 1;
4666 } elsif ($ch < 0xf0) {
4667 78 $n = 2;
4668 } else {
4669 0 $n = 3;
4670 # character code is greater than 0xffff if more than 2 extra bytes
4671 # were required in the UTF-8 character
4672 0 $rtnVal = 2;
4673 }
4674 153 my $pos = pos $$strPt;
4675 153 ▶ unless ($$strPt =~ /\G([\x80-\xbf]{$n})/g) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($$strPt =~ /\G([\x80-\xbf]{$n})/g) 1 152 153
4676 1 ▶ return $rtnVal if $trunc and $pos + $n > length $$strPt;
Branch: 1 branch
BranchTrueFalseTotal
if $trunc and $pos + $n > length $$strPt 0 1 1
Condition33%1/3
$trunc and $pos + $n > length $$strPt
!ll&&!rl&&r
010
MC/DC0%0/2
$trunc and $pos + $n > length $$strPt
$trunc $pos + $n > length $$strPt
Truth table33%1/3
A and B
A= $truncB= $pos + $n > length $$strPt
ABresult
0X0
100
111
4677 1 return -1;
4678 }
4679 # the following is ref https://www.cl.cam.ac.uk/%7Emgk25/ucs/utf8_check.c
4680 152 ▶ if ($n == 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n == 2) { } 77 75 152
4681 77 ▶ return -1 if ($ch == 0xe0 and (ord($1) & 0xe0) == 0x80) or
Branch: 1 branch
BranchTrueFalseTotal
if $ch == 224 and (ord $1 & 224) == 128 or $ch == 237 and (ord $1 & 224) == 160 or $ch == 239 and ord $1 == 191 and (ord substr($1, 1) & 254) == 190 0 77 77
Condition44%8/18
$ch == 224 and (ord $1 & 224) == 128 or $ch == 237 and (ord $1 & 224) == 160 or $ch == 239 and ord $1 == 191 and (ord substr($1, 1) & 254) == 190
l!l&&r!l&&!r
0077
$ch == 224 and (ord $1 & 224) == 128 or $ch == 237 and (ord $1 & 224) == 160
l!l&&r!l&&!r
0077
$ch == 224 and (ord $1 & 224) == 128
!ll&&!rl&&r
38390
$ch == 237 and (ord $1 & 224) == 160
!ll&&!rl&&r
7700
$ch == 239 and ord $1 == 191 and (ord substr($1, 1) & 254) == 190
!ll&&!rl&&r
7700
$ch == 239 and ord $1 == 191
!ll&&!rl&&r
7610
MC/DC0%0/7
$ch == 224 and (ord $1 & 224) == 128 or $ch == 237 and (ord $1 & 224) == 160 or $ch == 239 and ord $1 == 191 and (ord substr($1, 1) & 254) == 190
$ch == 224 (ord $1 & 224) == 128 $ch == 237 (ord $1 & 224) == 160 $ch == 239 ord $1 == 191 (ord substr($1, 1) & 254) == 190
Truth table15%3/19
A and B or C and D or E and F and G
A= $ch == 224B= (ord $1 & 224) == 128C= $ch == 237D= (ord $1 & 224) == 160E= $ch == 239F= ord $1 == 191G= (ord substr($1, 1) & 254) == 190
ABCDEFGresult
11XXXXX1
0X11XXX1
1011XXX1
0X0X1111
0X101111
100X1111
10101111
0X0X0XX0
0X0X10X0
0X0X1100
0X100XX0
0X1010X0
0X101100
100X0XX0
100X10X0
100X1100
10100XX0
101010X0
10101100
4682 ($ch == 0xed and (ord($1) & 0xe0) == 0xa0) or
4683 ($ch == 0xef and ord($1) == 0xbf and
4684 (ord(substr $1, 1) & 0xfe) == 0xbe);
4685 } else {
4686 75 ▶ return -1 if ($ch == 0xf0 and (ord($1) & 0xf0) == 0x80) or
Branch: 1 branch
BranchTrueFalseTotal
if $ch == 240 and (ord $1 & 240) == 128 or $ch == 244 and ord $1 > 143 or $ch > 244 0 75 75
Condition33%4/12
$ch == 240 and (ord $1 & 240) == 128 or $ch == 244 and ord $1 > 143 or $ch > 244
l!l&&r!l&&!r
0075
$ch == 240 and (ord $1 & 240) == 128 or $ch == 244 and ord $1 > 143
l!l&&r!l&&!r
0075
$ch == 240 and (ord $1 & 240) == 128
!ll&&!rl&&r
7500
$ch == 244 and ord $1 > 143
!ll&&!rl&&r
7500
MC/DC0%0/5
$ch == 240 and (ord $1 & 240) == 128 or $ch == 244 and ord $1 > 143 or $ch > 244
$ch == 240 (ord $1 & 240) == 128 $ch == 244 ord $1 > 143 $ch > 244
Truth table9%1/11
A and B or C and D or E
A= $ch == 240B= (ord $1 & 240) == 128C= $ch == 244D= ord $1 > 143E= $ch > 244
ABCDEresult
11XXX1
0X11X1
1011X1
0X0X11
0X1011
100X11
101011
0X0X00
0X1000
100X00
101000
4687 ($ch == 0xf4 and ord($1) > 0x8f) or $ch > 0xf4;
4688 }
4689 152 ▶ last unless $$strPt =~ /([\x80-\xff])/g;
Branch: 1 branch
BranchTrueFalseTotal
unless $$strPt =~ /([\x80-\xff])/g 10 142 152
4690 }
4691 10 return $rtnVal;
4692 }
4693  
4694 #------------------------------------------------------------------------------
4695 # Split file name into directory and name parts
4696 # Inptus: 0) file name
4697 # Returns: 0) directory, 1) filename
4698 sub SplitFileName($)
4699 505 ▶{
Subroutine SplitFileName: called CC=4 SCAR=18.5
Pod undocumented
4700 505 my $file = shift;
4701 505 my ($dir, $name);
4702 505 ▶ if (eval { require File::Basename }) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval { do { require File::Basename } }) { } 505 0 505
4703 505 $dir = File::Basename::dirname($file);
4704 505 $name = File::Basename::basename($file);
4705 } else {
4706 0 ($name = $file) =~ tr/\\/\//;
4707 # remove path
4708 0 ▶ if ($name =~ s/(.*)\///) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ s[(.*)/][]) { } 0 0 0
4709 0 ▶ $dir = length($1) ? $1 : '/';
Branch: 1 branch
BranchTrueFalseTotal
length $1 ? : 0 0 0
4710 } else {
4711 0 $dir = '.';
4712 }
4713 }
4714 505 return ($dir, $name);
4715 }
4716  
4717 #------------------------------------------------------------------------------
4718 # Encode file name for calls to system i/o routines
4719 # Inputs: 0) ExifTool ref, 1) file name in CharsetFileName encoding,
4720 # 2) flag to force conversion even if no special characters
4721 # Returns: true if Windows Unicode routines should be used (in which case
4722 # the file name will be encoded as a null-terminated UTF-16LE string)
4723 sub EncodeFileName($$;$)
4724 1198 ▶{
Subroutine EncodeFileName: called CC=16 SCAR=49.0
Pod undocumented
4725 1198 my ($self, $file, $force) = @_;
4726 1198 ▶ return 0 if $file eq '-'; # special case for stdin pipe
Branch: 1 branch
BranchTrueFalseTotal
if $file eq "-" 0 1198 1198
4727 1198 my $enc = $$self{OPTIONS}{CharsetFileName};
4728 1198 my $hasSpecialChars;
4729 1198 ▶ if ($file =~ /[\x80-\xff]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($file =~ /[\x80-\xff]/) 0 1198 1198
4730 0 $hasSpecialChars = 1;
4731 0 ▶ if (not $enc and $^O eq 'MSWin32') {
Branch: 1 branch
BranchTrueFalseTotal
if (not $enc and $^O eq "MSWin32") 0 0 0
Condition0%0/3
not $enc and $^O eq "MSWin32"
!ll&&!rl&&r
000
MC/DC0%0/2
not $enc and $^O eq "MSWin32"
not $enc $^O eq "MSWin32"
Truth table0%0/3
not(A) and B
A= not $encB= $^O eq "MSWin32"
ABresult
0X0
100
111
4732 0 ▶ if (IsUTF8(\$file) < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (&IsUTF8(\$file) < 0) { } 0 0 0
4733 0 ▶ $self->Warn('FileName encoding must be specified') if not defined $enc;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $enc 0 0 0
4734 0 return 0;
4735 } else {
4736 0 $enc = 'UTF8'; # assume UTF8
4737 }
4738 }
4739 }
4740 1198 ▶ if ($hasSpecialChars or $force or $$self{OPTIONS}{WindowsLongPath} or $$self{OPTIONS}{WindowsWideFile}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hasSpecialChars or $force or $self->{"OPTIONS"}{"WindowsLongPath"} or $self->{"OPTIONS"}{"WindowsWideFile"}) 0 1198 1198
Condition33%3/9
$hasSpecialChars or $force or $self->{"OPTIONS"}{"WindowsLongPath"} or $self->{"OPTIONS"}{"WindowsWideFile"}
l!l&&r!l&&!r
001198
$hasSpecialChars or $force or $self->{"OPTIONS"}{"WindowsLongPath"}
l!l&&r!l&&!r
001198
$hasSpecialChars or $force
l!l&&r!l&&!r
001198
MC/DC0%0/4
$hasSpecialChars or $force or $self->{"OPTIONS"}{"WindowsLongPath"} or $self->{"OPTIONS"}{"WindowsWideFile"}
$hasSpecialChars $force $self->{"OPTIONS"}{"WindowsLongPath"} $self->{"OPTIONS"}{"WindowsWideFile"}
Truth table20%1/5
A or B or C or D
A= $hasSpecialCharsB= $forceC= $self->{"OPTIONS"}{"WindowsLongPath"}D= $self->{"OPTIONS"}{"WindowsWideFile"}
ABCDresult
1XXX1
01XX1
001X1
00011
00000
4741 0 ▶ $enc or $enc = 'UTF8';
Branch: 1 branch
BranchTrueFalseTotal
$enc or $enc = "UTF8" 0 0 0
4742 0 ▶ if ($^O eq 'MSWin32') {
Branch: 2 branches
BranchTrueFalseTotal
if ($^O eq 'MSWin32') { } 0 0 0
elsif ($enc ne 'UTF8') { } 0 0 0
4743 0 local $SIG{'__WARN__'} = \&SetWarning;
4744 0 ▶ if (eval { require Win32API::File }) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval { do { require Win32API::File } }) 0 0 0
4745 0 ▶ $file = $self->WindowsLongPath($file) if $$self{OPTIONS}{WindowsLongPath};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"OPTIONS"}{"WindowsLongPath"} 0 0 0
4746 # recode as UTF-16LE and add null terminator
4747 0 $_[1] = $self->Decode($file, $enc, undef, 'UTF16', 'II') . "\0\0";
4748 0 return 1;
4749 }
4750 0 $self->Warn('Install Win32API::File for Windows wide/long file name support');
4751 } elsif ($enc ne 'UTF8') {
4752 # recode as UTF-8 for other platforms if necessary
4753 0 $_[1] = $self->Decode($file, $enc, undef, 'UTF8');
4754 }
4755 }
4756 1198 return 0;
4757 }
4758  
4759 #------------------------------------------------------------------------------
4760 # Rebuild a path as an absolute long path to be usable in Windows system calls
4761 # Inputs: 0) ExifTool ref, 1) path string (CharsetFileName)
4762 # Returns: normalized long path (CharsetFileName)
4763 # Note: this should only be called for Windows systems
4764 # References:
4765 # - https://learn.microsoft.com/en-us/dotnet/standard/io/file-path-formats
4766 # - https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation
4767 # GetFullPathName supported by Windows XP and later. It handles:
4768 # full path names EG: c:\foto\sub\abc.jpg
4769 # relative EG: .\abc.jpg, ..\abc.jpg
4770 # full UNC paths EG: \\server\share\abc.jpg
4771 # relative UNC paths EG: .\abc.jpg, ..\abc.jpg
4772 # Dos device paths EG: \\.\c:\fotoabc.jpg
4773 # relative path on other drives EG: z:abc.jpg (working dir on z: z:\foto called from c:\foto)
4774 # Wide chars EG: Chars that need UTF8.
4775 113 my $k32GetFullPathName;
4776 sub WindowsLongPath($$)
4777 0 ▶{
Subroutine WindowsLongPath: not called CC=16 SCAR=56.1
Pod documented
4778 0 my ($self, $path) = @_;
4779 0 my $debug = $$self{OPTIONS}{Debug};
4780 0 my $out = $$self{OPTIONS}{TextOut};
4781 0 my $suffix = '';
4782 0 my $longPath;
4783  
4784 # remove common suffixes to make cache more effective
4785 0 ▶ if ($path =~ s/(_original|_exiftool_tmp|:Zone\.Identifier)$//) {
Branch: 1 branch
BranchTrueFalseTotal
if ($path =~ s/(_original|_exiftool_tmp|:Zone\.Identifier)$//) 0 0 0
4786 0 $suffix = $1;
4787 0 ▶ if (not length $path or $path =~ m([:./\\]$)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not length $path or $path =~ m([:./\\]$)) 0 0 0
Condition0%0/3
not length $path or $path =~ m([:./\\]$)
l!l&&r!l&&!r
000
MC/DC0%0/2
not length $path or $path =~ m([:./\\]$)
not length $path $path =~ m([:./\\]$)
Truth table0%0/3
not(A) or B
A= not length $pathB= $path =~ m([:./\\]$)
ABresult
1X1
011
000
4788 # don't remove suffix if it could be the whole file name
4789 0 $path .= $suffix;
4790 0 $suffix = '';
4791 }
4792 }
4793 0 ▶ return $$self{LONG_PATH_OUT}.$suffix if defined $$self{LONG_PATH_IN} and $$self{LONG_PATH_IN} eq $path;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"LONG_PATH_IN"} and $self->{"LONG_PATH_IN"} eq $path 0 0 0
Condition0%0/3
defined $self->{"LONG_PATH_IN"} and $self->{"LONG_PATH_IN"} eq $path
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{"LONG_PATH_IN"} and $self->{"LONG_PATH_IN"} eq $path
defined $self->{"LONG_PATH_IN"} $self->{"LONG_PATH_IN"} eq $path
Truth table0%0/3
A and B
A= defined $self->{"LONG_PATH_IN"}B= $self->{"LONG_PATH_IN"} eq $path
ABresult
0X0
100
111
4794  
4795 0 ▶ $debug and print $out "WindowsLongPath input : $path$suffix\n";
Branch: 1 branch
BranchTrueFalseTotal
$debug and print $out "WindowsLongPath input : $path$suffix\n" 0 0 0
4796  
4797 0 for (;;) { # (cheap goto)
4798 0 ($longPath = $path) =~ tr(/)(\\); # convert slashes to backslashes
4799 0 ▶ last if $longPath =~ /^\\\\\?\\/; # already a device path in the format we want
Branch: 1 branch
BranchTrueFalseTotal
if $longPath =~ /^\\\\\?\\/ 0 0 0
4800  
4801 0 ▶ unless ($k32GetFullPathName) { # need to import (once) GetFullPathNameW
Branch: 1 branch
BranchTrueFalseTotal
unless ($k32GetFullPathName) 0 0 0
4802 0 ▶ last if defined $k32GetFullPathName;
Branch: 1 branch
BranchTrueFalseTotal
if defined $k32GetFullPathName 0 0 0
4803 0 ▶ unless (eval { require Win32::API }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (eval { do { require Win32::API } }) 0 0 0
4804 0 $self->Warn('Install Win32::API to use WindowsLongPath option');
4805 0 last;
4806 }
4807 0 $k32GetFullPathName = Win32::API->new('KERNEL32', 'GetFullPathNameW', 'PNPP', 'I');
4808 0 ▶ unless ($k32GetFullPathName) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($k32GetFullPathName) 0 0 0
4809 0 $k32GetFullPathName = 0;
4810 0 $self->Warn('Error loading Win32::API GetFullPathNameW');
4811 0 last;
4812 }
4813 }
4814 0 ▶ my $enc = $$self{OPTIONS}{CharsetFileName} || 'UTF8';
Condition0%0/2
$self->{'OPTIONS'}{'CharsetFileName'} || 'UTF8'
l!l
00
MC/DC0%0/1
$self->{'OPTIONS'}{'CharsetFileName'} || 'UTF8'
$self->{'OPTIONS'}{'CharsetFileName'}
Truth table0%0/2
A
A= $self->{'OPTIONS'}{'CharsetFileName'}
Aresult
11
00
4815 0 my $encPath = $self->Decode($longPath, $enc, undef, 'UTF16', 'II');# need to encode to UTF16
4816 0 my $lenReq = $k32GetFullPathName->Call($encPath,0,0,0) + 1; # first pass gets length required, +1 for safety (null?)
4817 0 my $fullPath = "\0" x $lenReq x 2; # create buffer to hold full path
4818 0 $k32GetFullPathName->Call($encPath, $lenReq, $fullPath, 0); # fullPath is UTF16 now
4819 0 $longPath = $self->Decode($fullPath, 'UTF16', 'II', $enc);
4820  
4821 0 ▶ last if length($longPath) <= 247 - length($suffix);
Branch: 1 branch
BranchTrueFalseTotal
if length $longPath <= 247 - length($suffix) 0 0 0
4822  
4823 0 ▶ if ($longPath =~ /^\\\\/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($longPath =~ /^\\\\/) { } 0 0 0
4824 0 $longPath = '\\\\?\\UNC' . substr($longPath, 1);
4825 } else {
4826 0 $longPath = '\\\\?\\' . $longPath;
4827 }
4828 0 last;
4829 }
4830 # this may be called repeatedly for the same file file (exists, stat, open),
4831 # so cache the last return value (without any of the suffixes that we use)
4832 0 $$self{LONG_PATH_IN} = $path;
4833 0 $$self{LONG_PATH_OUT} = $longPath;
4834 0 ▶ $debug and print $out "WindowsLongPath return: $longPath$suffix\n";
Branch: 1 branch
BranchTrueFalseTotal
$debug and print $out "WindowsLongPath return: $longPath$suffix\n" 0 0 0
4835 0 return $longPath . $suffix;
4836 }
4837  
4838 #------------------------------------------------------------------------------
4839 # Modified perl open() routine to properly handle special characters in file names
4840 # Inputs: 0) ExifTool ref, 1) filehandle, 2) filename,
4841 # 3) mode: '<' or undef = read, '>' = write, '+<' = update
4842 # Returns: true on success
4843 # Note: Must call like "$et->Open(\*FH,$file)", not "$et->Open(FH,$file)" to avoid
4844 # "unopened filehandle" errors due to a change in scope of the filehandle
4845 sub Open($*$;$)
4846 960 ▶{
Subroutine Open: called CC=14 SCAR=46.8
Pod undocumented
4847 960 my ($self, $fh, $file, $mode) = @_;
4848  
4849 960 $file =~ s/^([\s&])/.\/$1/; # protect leading whitespace or ampersand
4850 # default to read mode ('<') unless input is a trusted pipe
4851 960 ▶ $mode = (($file =~ /\|$/ and $$self{TRUST_PIPE}) ? '' : '<') unless $mode;
Branch: 2 branches
BranchTrueFalseTotal
unless $mode 730 230 960
$file =~ /\|$/ && $self->{'TRUST_PIPE'} ? : 0 730 730
Condition33%1/3
$file =~ /\|$/ and $self->{"TRUST_PIPE"}
!ll&&!rl&&r
73000
MC/DC0%0/2
$file =~ /\|$/ and $self->{"TRUST_PIPE"}
$file =~ /\|$/ $self->{"TRUST_PIPE"}
Truth table33%1/3
A and B
A= $file =~ /\|$/B= $self->{"TRUST_PIPE"}
ABresult
0X0
100
111
4852 960 delete $$self{TRUST_PIPE};
4853 960 ▶ if ($mode) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode) 960 0 960
4854 960 ▶ if ($self->EncodeFileName($file)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->EncodeFileName($file)) { } 0 960 960
4855 # handle Windows Unicode file name
4856 0 local $SIG{'__WARN__'} = \&SetWarning;
4857 0 my ($access, $create);
4858 0 ▶ if ($mode eq '>' or $mode eq '>>') {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode eq '>' or $mode eq '>>') { } 0 0 0
Condition0%0/3
$mode eq ">" or $mode eq ">>"
l!l&&r!l&&!r
000
MC/DC0%0/2
$mode eq ">" or $mode eq ">>"
$mode eq ">" $mode eq ">>"
Truth table0%0/3
A or B
A= $mode eq ">"B= $mode eq ">>"
ABresult
1X1
011
000
4859 0 eval {
4860 0 $access = Win32API::File::GENERIC_WRITE();
4861 0 ▶ if ($mode eq '>>') {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode eq '>>') { } 0 0 0
4862 0 $access |= Win32API::File::FILE_APPEND_DATA();
4863 0 $create = Win32API::File::OPEN_ALWAYS();
4864 } else {
4865 0 $create = Win32API::File::CREATE_ALWAYS();
4866 }
4867 }
4868 } else {
4869 0 eval {
4870 0 $access = Win32API::File::GENERIC_READ();
4871 0 ▶ $access |= Win32API::File::GENERIC_WRITE() if $mode eq '+<'; # update
Branch: 1 branch
BranchTrueFalseTotal
if $mode eq "+<" 0 0 0
4872 0 $create = Win32API::File::OPEN_EXISTING();
4873 }
4874 }
4875 0 my $share = 0;
4876 0 eval {
4877 0 ▶ unless ($access & Win32API::File::GENERIC_WRITE()) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($access & Win32API::File::GENERIC_WRITE()) 0 0 0
4878 0 $share = Win32API::File::FILE_SHARE_READ() | Win32API::File::FILE_SHARE_WRITE();
4879 }
4880 };
4881 0 my $wh = eval { Win32API::File::CreateFileW($file, $access, $share, [], $create, 0, []) };
4882 0 ▶ return undef unless $wh;
Branch: 1 branch
BranchTrueFalseTotal
unless $wh 0 0 0
4883 0 my $fd = eval { Win32API::File::OsFHandleOpenFd($wh, 0) };
4884 0 ▶ if (not defined $fd or $fd < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $fd or $fd < 0) 0 0 0
Condition0%0/3
not defined $fd or $fd < 0
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $fd or $fd < 0
not defined $fd $fd < 0
Truth table0%0/3
not(A) or B
A= not defined $fdB= $fd < 0
ABresult
1X1
011
000
4885 0 eval { Win32API::File::CloseHandle($wh) };
4886 0 return undef;
4887 }
4888 0 $file = "&=$fd"; # specify file by descriptor
4889 } else {
4890 # add leading space to protect against leading characters like '>'
4891 # in file name, and trailing "\0" to protect trailing spaces
4892 960 $file = " $file\0";
4893 }
4894 }
4895 960 return open $fh, "$mode$file";
4896 }
4897  
4898 #------------------------------------------------------------------------------
4899 # Check to see if a file exists (with Windows Unicode support)
4900 # Inputs: 0) ExifTool ref, 1) file name, 2) flag if we are writing this file
4901 # Returns: true if file exists
4902 sub Exists($$;$)
4903 231 ▶{
Subroutine Exists: called CC=5 SCAR=26.1
Pod undocumented
4904 231 my ($self, $file, $writing) = @_;
4905  
4906 231 ▶ if ($self->EncodeFileName($file)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->EncodeFileName($file)) { } 0 231 231
elsif ($writing) { } 231 0 231
4907 0 local $SIG{'__WARN__'} = \&SetWarning;
4908 0 my $wh = eval { Win32API::File::CreateFileW($file,
4909 Win32API::File::GENERIC_READ(),
4910 Win32API::File::FILE_SHARE_READ(), [],
4911 Win32API::File::OPEN_EXISTING(), 0, []) };
4912 0 ▶ return 0 unless $wh;
Branch: 1 branch
BranchTrueFalseTotal
unless $wh 0 0 0
4913 0 eval { Win32API::File::CloseHandle($wh) };
4914 } elsif ($writing) {
4915 # (named pipes already exist, but we pretend that they don't
4916 # so we will be able to write them, so test for pipe with -p)
4917 231 ▶ return(-e $file and not -p $file);
Condition33%1/3
-e $file && !(-p $file)
!ll&&!rl&&r
23100
MC/DC0%0/2
-e $file && !(-p $file)
-e $file !(-p $file)
Truth table33%1/3
A && not(B)
A= -e $fileB= !(-p $file)
ABresult
0X0
100
111
4918 } else {
4919 0 return(-e $file);
4920 }
4921 0 return 1;
4922 }
4923  
4924 #------------------------------------------------------------------------------
4925 # Return true if file is a directory (with Windows Unicode support)
4926 # Inputs: 0) ExifTool ref, 1) file name
4927 # Returns: true if file is a directory (false if file isn't, or doesn't exist)
4928 sub IsDirectory($$)
4929 1 ▶{
Subroutine IsDirectory: called CC=6 SCAR=32.5
Pod undocumented
4930 1 my ($et, $file) = @_;
4931 1 ▶ if ($et->EncodeFileName($file)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($et->EncodeFileName($file)) { } 0 1 1
4932 0 local $SIG{'__WARN__'} = \&SetWarning;
4933 0 my $attrs = eval { Win32API::File::GetFileAttributesW($file) };
4934 0 ▶ my $dirBit = eval { Win32API::File::FILE_ATTRIBUTE_DIRECTORY() } || 0;
Condition0%0/2
eval { do { Win32API::File::FILE_ATTRIBUTE_DIRECTORY() } } || 0
l!l
00
MC/DC0%0/1
eval { do { Win32API::File::FILE_ATTRIBUTE_DIRECTORY() } } || 0
eval { do { Win32API::File::FILE_ATTRIBUTE_DIRECTORY() } }
Truth table0%0/2
A
A= eval { do { Win32API::File::FILE_ATTRIBUTE_DIRECTORY() } }
Aresult
11
00
4935 0 ▶ return 1 if $attrs and $attrs != 0xffffffff and $attrs & $dirBit;
Branch: 1 branch
BranchTrueFalseTotal
if $attrs and $attrs != 4294967295 and $attrs & $dirBit 0 0 0
Condition0%0/6
$attrs and $attrs != 4294967295 and $attrs & $dirBit
!ll&&!rl&&r
000
$attrs and $attrs != 4294967295
!ll&&!rl&&r
000
MC/DC0%0/3
$attrs and $attrs != 4294967295 and $attrs & $dirBit
$attrs $attrs != 4294967295 $attrs & $dirBit
Truth table0%0/4
A and B and C
A= $attrsB= $attrs != 4294967295C= $attrs & $dirBit
ABCresult
0XX0
10X0
1100
1111
4936 } else {
4937 1 return -d $file;
4938 }
4939 0 return 0;
4940 }
4941  
4942 #------------------------------------------------------------------------------
4943 # Create directory for specified file
4944 # Inputs: 0) ExifTool ref, 1) complete file name including path
4945 # Returns: '' = directory created, undef = nothing done, otherwise error string
4946 my $k32CreateDir;
4947 sub CreateDirectory($$)
4948 1 ▶{
Subroutine CreateDirectory: called CC=14 SCAR=49.2
Pod undocumented
4949 1 local $_;
4950 1 my ($self, $file) = @_;
4951 1 my ($err, $dir);
4952 1 ($dir = $file) =~ s/[^\/]*$//; # remove filename from path specification
4953 1 ▶ if ($dir and not $self->IsDirectory($dir)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dir and not $self->IsDirectory($dir)) 0 1 1
Condition33%1/3
$dir and not $self->IsDirectory($dir)
!ll&&!rl&&r
010
MC/DC0%0/2
$dir and not $self->IsDirectory($dir)
$dir not $self->IsDirectory($dir)
Truth table33%1/3
A and not(B)
A= $dirB= not $self->IsDirectory($dir)
ABresult
0X0
100
111
4954 0 my @parts = split /\//, $dir;
4955 0 $dir = '';
4956 0 foreach (@parts) {
4957 0 $dir .= $_;
4958 0 ▶ if (length and not $self->IsDirectory($dir) and
Branch: 1 branch
BranchTrueFalseTotal
if (length $_ and not $self->IsDirectory($dir) and not &IsPC() && $dir =~ m[^//[^/]*$]) 0 0 0
Condition0%0/9
length $_ and not $self->IsDirectory($dir) and not &IsPC() && $dir =~ m[^//[^/]*$]
!ll&&!rl&&r
000
length $_ and not $self->IsDirectory($dir)
!ll&&!rl&&r
000
&IsPC() && $dir =~ m[^//[^/]*$]
!ll&&!rl&&r
000
MC/DC0%0/4
length $_ and not $self->IsDirectory($dir) and not &IsPC() && $dir =~ m[^//[^/]*$]
length $_ not $self->IsDirectory($dir) &IsPC() $dir =~ m[^//[^/]*$]
Truth table0%0/5
A and not(B) and not(C && D)
A= length $_B= not $self->IsDirectory($dir)C= &IsPC()D= $dir =~ m[^//[^/]*$]
ABCDresult
0XXX0
10XX0
11110
110X1
11101
4959 # don't try to create a network drive root directory
4960 not (IsPC() and $dir =~ m{^//[^/]*$}))
4961 {
4962 0 my $success;
4963 # create directory since it doesn't exist
4964 0 my $d2 = $dir; # (must make a copy in case EncodeFileName recodes it)
4965 0 ▶ if ($self->EncodeFileName($d2)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->EncodeFileName($d2)) { } 0 0 0
4966 # handle Windows Unicode directory names
4967 0 ▶ unless (defined $k32CreateDir) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $k32CreateDir) 0 0 0
4968 0 ▶ unless (eval { require Win32::API }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (eval { do { require Win32::API } }) 0 0 0
4969 0 $err = 'Install Win32::API to create directories with Unicode names';
4970 0 last;
4971 }
4972 0 $k32CreateDir = Win32::API->new('KERNEL32', 'CreateDirectoryW', 'PP', 'I');
4973 0 ▶ unless ($k32CreateDir) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($k32CreateDir) 0 0 0
4974 0 $k32CreateDir = 0;
4975 # give this error once, then just "Error creating" for subsequent attempts
4976 0 return 'Error loading Win32::API CreateDirectoryW';
4977 }
4978 }
4979 0 ▶ $success = $k32CreateDir->Call($d2, 0) if $k32CreateDir;
Branch: 1 branch
BranchTrueFalseTotal
if $k32CreateDir 0 0 0
4980 } else {
4981 0 $success = mkdir($d2, 0777);
4982 }
4983 0 ▶ $success or $err = "Error creating directory $dir", last;
Branch: 1 branch
BranchTrueFalseTotal
$success or $err = "Error creating directory $dir", last 0 0 0
4984 0 $err = '';
4985 }
4986 0 $dir .= '/';
4987 }
4988 }
4989 1 return $err;
4990 }
4991  
4992 #------------------------------------------------------------------------------
4993 # Get file times (Unix seconds since the epoch)
4994 # Inputs: 0) ExifTool ref, 1) file name or ref
4995 # Returns: 0) access time, 1) modification time, 2) creation time (or undefs on error)
4996 113 my $k32GetFileTime;
4997 sub GetFileTime($$)
4998 0 ▶{
Subroutine GetFileTime: not called CC=14 SCAR=53.5
Pod undocumented
4999 0 my ($self, $file) = @_;
5000  
5001 # open file by name if necessary
5002 0 ▶ unless (ref $file) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $file) 0 0 0
5003 0 local *FH;
5004 0 ▶ unless ($self->Open(\*FH, $file)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->Open(\*FH, $file)) 0 0 0
5005 0 ▶ if ($self->IsDirectory($file)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->IsDirectory($file)) 0 0 0
5006 0 my @rtn = (stat $file)[8, 9, 10];
5007 0 ▶ return @rtn if defined $rtn[0];
Branch: 1 branch
BranchTrueFalseTotal
if defined $rtn[0] 0 0 0
5008 }
5009 0 $self->Warn("GetFileTime error for '${file}'");
5010 0 return ();
5011 }
5012 0 $file = *FH; # (not \*FH, so *FH will be kept open until $file goes out of scope)
5013 }
5014 # on Windows, try to work around incorrect file times when daylight saving time is in effect
5015 0 ▶ if ($^O eq 'MSWin32') {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq "MSWin32") 0 0 0
5016 0 ▶ if (not eval { require Win32::API }) {
Branch: 2 branches
BranchTrueFalseTotal
if (not eval { do { require Win32::API } }) { } 0 0 0
elsif (not eval { do { require Win32API::File } }) { } 0 0 0
5017 0 $self->Warn('Install Win32::API for proper handling of Windows file times', 1);
5018 0 } elsif (not eval { require Win32API::File }) {
5019 0 $self->Warn('Install Win32API::File for proper handling of Windows file times', 1);
5020 } else {
5021 # get Win32 handle, needed for GetFileTime
5022 0 my $win32Handle = eval { Win32API::File::GetOsFHandle($file) };
5023 0 ▶ unless ($win32Handle) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($win32Handle) 0 0 0
5024 0 $self->Warn("Win32API::File::GetOsFHandle returned invalid handle");
5025 0 return ();
5026 }
5027 # get FILETIME structs
5028 0 my ($atime, $mtime, $ctime, $time);
5029 0 $atime = $mtime = $ctime = pack 'LL', 0, 0;
5030 0 ▶ unless ($k32GetFileTime) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($k32GetFileTime) 0 0 0
5031 0 ▶ return () if defined $k32GetFileTime;
Branch: 1 branch
BranchTrueFalseTotal
if defined $k32GetFileTime 0 0 0
5032 0 $k32GetFileTime = Win32::API->new('KERNEL32', 'GetFileTime', 'NPPP', 'I');
5033 0 ▶ unless ($k32GetFileTime) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($k32GetFileTime) 0 0 0
5034 0 $self->Warn('Error loading Win32::API GetFileTime');
5035 0 $k32GetFileTime = 0;
5036 0 return ();
5037 }
5038 }
5039 0 ▶ unless ($k32GetFileTime->Call($win32Handle, $ctime, $atime, $mtime)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($k32GetFileTime->Call($win32Handle, $ctime, $atime, $mtime)) 0 0 0
5040 0 $self->Warn("Win32::API GetFileTime returned " . Win32::GetLastError());
5041 0 return ();
5042 }
5043 # convert FILETIME structs to Unix seconds
5044 0 foreach $time ($atime, $mtime, $ctime) {
5045 0 my ($lo, $hi) = unpack 'LL', $time; # unpack FILETIME struct
5046 # FILETIME is in 100 ns intervals since 0:00 UTC Jan 1, 1601
5047 # (89 leap years between 1601 and 1970)
5048 0 $time = ($hi * 4294967296 + $lo) * 1e-7 - (((1970-1601)*365+89)*24*3600);
5049 }
5050 0 return ($atime, $mtime, $ctime);
5051 }
5052 }
5053 # other os (or Windows fallback)
5054 0 return (stat $file)[8, 9, 10];
5055 }
5056  
5057 #------------------------------------------------------------------------------
5058 # Parse function arguments and set member variables accordingly
5059 # Inputs: Same as ImageInfo()
5060 # - sets REQUESTED_TAGS, REQ_TAG_LOOKUP, IO_TAG_LIST, FILENAME, RAF, OPTIONS
5061 sub ParseArguments($;@)
5062 725 ▶{
Subroutine ParseArguments: called CC=45 SCAR=41.0
Pod undocumented
5063 725 my $self = shift;
5064 725 my $options = $$self{OPTIONS};
5065 725 my @oldGroupOpts = grep /^Group/, keys %{$$self{OPTIONS}};
5066 725 my (@exclude, $wasExcludeOpt);
5067  
5068 725 $$self{REQUESTED_TAGS} = [ ];
5069 725 ▶ $$self{REQ_TAG_LOOKUP} = { } unless $$self{ReqTagAlreadySet};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"ReqTagAlreadySet"} 719 6 725
5070 725 $$self{EXCL_TAG_LOOKUP} = { };
5071 725 $$self{IO_TAG_LIST} = undef;
5072 725 delete $$self{EXCL_XMP_LOOKUP};
5073  
5074 # handle our input arguments
5075 725 ▶ while (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 1591 725 2316
5076 1591 my $arg = shift;
5077 1591 ▶ if (ref $arg and not overload::Method($arg, q[""])) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $arg and not overload::Method($arg, '""')) { } 171 1420 1591
elsif (defined $self->{'FILENAME'}) { } 915 505 1420
Condition66%2/3
ref $arg and not overload::Method($arg, "\"\"")
!ll&&!rl&&r
14200171
MC/DC50%1/2
ref $arg and not overload::Method($arg, "\"\"")
ref $arg not overload::Method($arg, "\"\"")
Truth table66%2/3
A and not(B)
A= ref $argB= not overload::Method($arg, "\"\"")
ABresult
0X0
100
111
5078 171 ▶ if (ref $arg eq 'ARRAY') {
Branch: 4 branches
BranchTrueFalseTotal
if (ref $arg eq 'ARRAY') { } 10 161 171
elsif (ref $arg eq 'HASH') { } 116 45 161
elsif (ref $arg eq 'SCALAR' or UNIVERSAL::isa($arg, 'GLOB')) { } 26 19 45
elsif (UNIVERSAL::isa($arg, 'File::RandomAccess')) { } 19 0 19
5079 10 $$self{IO_TAG_LIST} = $arg;
5080 10 foreach (@$arg) {
5081 91 ▶ if (/^-(.*)/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^-(.*)/) { } 2 89 91
5082 2 push @exclude, $1;
5083 } else {
5084 89 push @{$$self{REQUESTED_TAGS}}, $_;
5085 }
5086 }
5087 } elsif (ref $arg eq 'HASH') {
5088 116 my $opt;
5089 116 foreach $opt (keys %$arg) {
5090 # a single new group option overrides all old group options
5091 189 ▶ if (@oldGroupOpts and $opt =~ /^Group/) {
Branch: 1 branch
BranchTrueFalseTotal
if (@oldGroupOpts and $opt =~ /^Group/) 28 161 189
Condition100%3/3
@oldGroupOpts and $opt =~ /^Group/
!ll&&!rl&&r
215928
MC/DC100%2/2
@oldGroupOpts and $opt =~ /^Group/
@oldGroupOpts $opt =~ /^Group/
Truth table100%3/3
A and B
A= @oldGroupOptsB= $opt =~ /^Group/
ABresult
0X0
100
111
5092 28 foreach (@oldGroupOpts) {
5093 28 delete $$options{$_};
5094 }
5095 28 undef @oldGroupOpts;
5096 }
5097 189 $self->Options($opt, $$arg{$opt});
5098 189 ▶ $opt eq 'Exclude' and $wasExcludeOpt = 1;
Branch: 1 branch
BranchTrueFalseTotal
$opt eq "Exclude" and $wasExcludeOpt = 1 0 189 189
5099 }
5100 ▶ } elsif (ref $arg eq 'SCALAR' or UNIVERSAL::isa($arg,'GLOB')) {
Condition100%3/3
ref $arg eq "SCALAR" or UNIVERSAL::isa($arg, "GLOB")
l!l&&r!l&&!r
25119
MC/DC100%2/2
ref $arg eq "SCALAR" or UNIVERSAL::isa($arg, "GLOB")
ref $arg eq "SCALAR" UNIVERSAL::isa($arg, "GLOB")
Truth table100%3/3
A or B
A= ref $arg eq "SCALAR"B= UNIVERSAL::isa($arg, "GLOB")
ABresult
1X1
011
000
5101 26 ▶ next if defined $$self{RAF};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"RAF"} 0 26 26
5102 # convert image data from UTF-8 to character stream if necessary
5103 # (patches RHEL 3 UTF8 LANG problem)
5104 26 ▶ if (ref $arg eq 'SCALAR' and $] >= 5.006 and ($$self{OPTIONS}{EncodeHangs} or
Branch: 1 branch
BranchTrueFalseTotal
if (ref $arg eq "SCALAR" and $] >= "5.006" and $self->{"OPTIONS"}{"EncodeHangs"} || eval { do { require Encode; &Encode::is_utf8($$arg) } } || $@) 0 26 26
Condition50%6/12
ref $arg eq "SCALAR" and $] >= "5.006" and $self->{"OPTIONS"}{"EncodeHangs"} || eval { do { require Encode; &Encode::is_utf8($$arg) } } || $@
!ll&&!rl&&r
1250
ref $arg eq "SCALAR" and $] >= "5.006"
!ll&&!rl&&r
1025
$self->{"OPTIONS"}{"EncodeHangs"} or eval { do { require Encode; &Encode::is_utf8($$arg) } } or $@
l!l&&r!l&&!r
0025
$self->{"OPTIONS"}{"EncodeHangs"} or eval { do { require Encode; &Encode::is_utf8($$arg) } }
l!l&&r!l&&!r
0025
MC/DC0%0/5
ref $arg eq "SCALAR" and $] >= "5.006" and $self->{"OPTIONS"}{"EncodeHangs"} || eval { do { require Encode; &Encode::is_utf8($$arg) } } || $@
ref $arg eq "SCALAR" $] >= "5.006" $self->{"OPTIONS"}{"EncodeHangs"} eval { do { require Encode; &Encode::is_utf8($$arg) } } $@
Truth table33%2/6
A and B and C or D or E
A= ref $arg eq "SCALAR"B= $] >= "5.006"C= $self->{"OPTIONS"}{"EncodeHangs"}D= eval { do { require Encode; &Encode::is_utf8($$arg) } }E= $@
ABCDEresult
0XXXX0
10XXX0
110000
111XX1
1101X1
110011
5105 25 eval { require Encode; Encode::is_utf8($$arg) } or $@))
5106 {
5107 0 local $SIG{'__WARN__'} = \&SetWarning;
5108 # repack by hand if Encode isn't available
5109 0 ▶ my $buff = ($$self{OPTIONS}{EncodeHangs} or $@) ? pack('C*',unpack($] < 5.010000 ?
Branch: 2 branches
BranchTrueFalseTotal
$self->{'OPTIONS'}{'EncodeHangs'} || $@ ? : 0 0 0
$] < 5.01 ? : 0 0 0
Condition0%0/3
$self->{"OPTIONS"}{"EncodeHangs"} or $@
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"OPTIONS"}{"EncodeHangs"} or $@
$self->{"OPTIONS"}{"EncodeHangs"} $@
Truth table0%0/3
A or B
A= $self->{"OPTIONS"}{"EncodeHangs"}B= $@
ABresult
1X1
011
000
5110 'U0C*' : 'C0C*', $$arg)) : Encode::encode('utf8', $$arg);
5111 0 $arg = \$buff;
5112 }
5113 26 $$self{RAF} = File::RandomAccess->new($arg);
5114 # set filename to empty string to indicate that
5115 # we have a file but we didn't open it
5116 26 $$self{FILENAME} = '';
5117 } elsif (UNIVERSAL::isa($arg, 'File::RandomAccess')) {
5118 19 $$self{RAF} = $arg;
5119 19 $$self{FILENAME} = '';
5120 } else {
5121 0 warn "Don't understand ImageInfo argument $arg\n";
5122 }
5123 } elsif (defined $$self{FILENAME}) {
5124 915 ▶ if ($arg =~ /^-(.*)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($arg =~ /^-(.*)/) { } 58 857 915
5125 58 push @exclude, $1;
5126 } else {
5127 857 push @{$$self{REQUESTED_TAGS}}, $arg;
5128 }
5129 } else {
5130 505 $$self{FILENAME} = $arg;
5131 }
5132 }
5133 # add additional requested tags to lookup
5134 725 ▶ if ($$options{RequestTags}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($options->{"RequestTags"}) 46 679 725
5135 46 $$self{REQ_TAG_LOOKUP}{$_} = 1 foreach @{$$options{RequestTags}};
5136 }
5137 # expand shortcuts in tag arguments if provided
5138 725 ▶ if (@{$$self{REQUESTED_TAGS}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->{"REQUESTED_TAGS"};}) 367 358 725
5139 367 ExpandShortcuts($$self{REQUESTED_TAGS});
5140 # initialize lookup for requested tags
5141 367 foreach (@{$$self{REQUESTED_TAGS}}) {
5142 989 ▶ /^(.*:)?([-\w?*]*)#?$/ or next;
Branch: 1 branch
BranchTrueFalseTotal
/^(.*:)?([-\w?*]*)#?$/ or next 989 0 989
5143 989 ▶ $$self{REQ_TAG_LOOKUP}{lc($2)} = 1 if $2;
Branch: 1 branch
BranchTrueFalseTotal
if $2 989 0 989
5144 989 ▶ next unless $1;
Branch: 1 branch
BranchTrueFalseTotal
unless $1 734 255 989
5145 255 $$self{REQ_TAG_LOOKUP}{lc($_).':'} = 1 foreach split /:/, $1;
5146 }
5147 }
5148 725 ▶ if (@exclude or $wasExcludeOpt) {
Branch: 1 branch
BranchTrueFalseTotal
if (@exclude or $wasExcludeOpt) 45 680 725
Condition66%2/3
@exclude or $wasExcludeOpt
l!l&&r!l&&!r
450680
MC/DC50%1/2
@exclude or $wasExcludeOpt
@exclude $wasExcludeOpt
Truth table66%2/3
A or B
A= @excludeB= $wasExcludeOpt
ABresult
1X1
011
000
5149 # must add existing excluded tags
5150 45 ▶ push @exclude, @{$$options{Exclude}} if $$options{Exclude};
Branch: 1 branch
BranchTrueFalseTotal
if $options->{"Exclude"} 1 44 45
5151 45 $$options{Exclude} = \@exclude;
5152 # expand shortcuts in new exclude list
5153 45 ExpandShortcuts($$options{Exclude}, 1); # (also remove '#' suffix)
5154 }
5155 # generate lookup for excluded tags
5156 725 ▶ if ($$options{Exclude}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($options->{"Exclude"}) 52 673 725
5157 52 foreach (@{$$options{Exclude}}) {
5158 69 ▶ /([-\w]+)#?$/ and $$self{EXCL_TAG_LOOKUP}{lc $1} = 1;
Branch: 1 branch
BranchTrueFalseTotal
/([-\w]+)#?$/ and $self->{"EXCL_TAG_LOOKUP"}{lc $1} = 1 68 1 69
5159 69 ▶ if (/(xmp-.*:[-\w]+)#?/i) {
Branch: 1 branch
BranchTrueFalseTotal
if (/(xmp-.*:[-\w]+)#?/i) 0 69 69
5160 0 ▶ $$self{EXCL_XMP_LOOKUP} or $$self{EXCL_XMP_LOOKUP} = { };
Branch: 1 branch
BranchTrueFalseTotal
$self->{"EXCL_XMP_LOOKUP"} or $self->{"EXCL_XMP_LOOKUP"} = {} 0 0 0
5161 0 $$self{EXCL_XMP_LOOKUP}{lc $1} = 1;
5162 }
5163 }
5164 # exclude list is used only for EXCL_TAG_LOOKUP when TAGS_FROM_FILE is set
5165 52 ▶ undef $$options{Exclude} if $$self{TAGS_FROM_FILE};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"TAGS_FROM_FILE"} 7 45 52
5166 }
5167 }
5168  
5169 #------------------------------------------------------------------------------
5170 # Does group name match the tag ID?
5171 # Inputs: 0) tag ID, 1) group name (with "ID-" removed)
5172 # Returns: true on success
5173 sub IsSameID($$)
5174 2 ▶{
Subroutine IsSameID: called CC=8 SCAR=25.5
Pod undocumented
5175 2 my ($id, $grp) = @_;
5176 2 for (;;) {
5177 2 ▶ return 1 if $grp eq $id; # decimal ID's or raw ID's
Branch: 1 branch
BranchTrueFalseTotal
if $grp eq $id 1 1 2
5178 1 ▶ if ($id =~ /^\d+$/) { # numerical numerical ID's may be in hex
Branch: 1 branch
BranchTrueFalseTotal
if ($id =~ /^\d+$/) { } 0 1 1
5179 0 ▶ return 1 if $grp =~ s/^0x0*// and $grp eq sprintf('%x', $id);
Branch: 1 branch
BranchTrueFalseTotal
if $grp =~ s/^0x0*// and $grp eq sprintf("%x", $id) 0 0 0
Condition0%0/3
$grp =~ s/^0x0*// and $grp eq sprintf("%x", $id)
!ll&&!rl&&r
000
MC/DC0%0/2
$grp =~ s/^0x0*// and $grp eq sprintf("%x", $id)
$grp =~ s/^0x0*// $grp eq sprintf("%x", $id)
Truth table0%0/3
A and B
A= $grp =~ s/^0x0*//B= $grp eq sprintf("%x", $id)
ABresult
0X0
100
111
5180 } else { # other ID's may conform to ExifTool group name conventions
5181 1 my $tmp = $id;
5182 1 ▶ return 1 if $tmp =~ s/([^-_A-Za-z0-9])/sprintf('%.2x',ord $1)/ge and $grp eq $tmp;
Branch: 1 branch
BranchTrueFalseTotal
if $tmp =~ s/([^-_A-Za-z0-9])/sprintf "%.2x", ord $1;/eg and $grp eq $tmp 0 1 1
Condition33%1/3
$tmp =~ s/([^-_A-Za-z0-9])/sprintf "%.2x", ord $1;/eg and $grp eq $tmp
!ll&&!rl&&r
010
MC/DC0%0/2
$tmp =~ s/([^-_A-Za-z0-9])/sprintf "%.2x", ord $1;/eg and $grp eq $tmp
$tmp =~ s/([^-_A-Za-z0-9])/sprintf "%.2x", ord $1;/eg $grp eq $tmp
Truth table33%1/3
A and B
A= $tmp =~ s/([^-_A-Za-z0-9])/sprintf "%.2x", ord $1;/egB= $grp eq $tmp
ABresult
0X0
100
111
5183 }
5184 1 ▶ last unless $id =~ s/-.*//; # remove language code if it exists
Branch: 1 branch
BranchTrueFalseTotal
unless $id =~ s/-.*// 1 0 1
5185 }
5186 1 return 0;
5187 }
5188  
5189 #------------------------------------------------------------------------------
5190 # Get list of tags in specified group
5191 # Inputs: 0) ExifTool ref, 1) group spec (case insensitive), 2) tag key or reference to list of tag keys
5192 # Returns: list of matching tags in list context, or first match in scalar context
5193 # Notes: Group spec may contain multiple groups separated by colons, each
5194 # possibly with a leading family number
5195 sub GroupMatches($$$)
5196 28417 ▶{
Subroutine GroupMatches: called CC=20 SCAR=31.6
Pod undocumented
5197 28417 my ($self, $group, $tagList) = @_;
5198 28417 ▶ $tagList = [ $tagList ] unless ref $tagList;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $tagList 0 28417 28417
5199 28417 my ($tag, @matches);
5200 # check each group name individually (eg. "Author:1IPTC")
5201 28417 my @grps = split ':', $group;
5202 28417 my (@fmys, $g);
5203 28417 ▶ for ($g=0; $g<@grps; ++$g) {
Branch: 1 branch
BranchTrueFalseTotal
if ($g < @grps) 29008 28417 57425
5204 29008 ▶ if ($grps[$g] =~ s/^(\d*)(id-)?//i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($grps[$g] =~ s/^(\d*)(id-)?//i) 29008 0 29008
5205 29008 ▶ $fmys[$g] = $1 if length $1;
Branch: 1 branch
BranchTrueFalseTotal
if length $1 2 29006 29008
5206 29008 ▶ if ($2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($2) 0 29008 29008
5207 0 $fmys[$g] = 7;
5208 0 next; # (don't convert tag ID's to lower case)
5209 }
5210 }
5211 29008 $grps[$g] = lc $grps[$g];
5212 29008 ▶ $grps[$g] = '' if $grps[$g] eq 'copy0'; # accept 'Copy0' for primary tag
Branch: 1 branch
BranchTrueFalseTotal
if $grps[$g] eq "copy0" 0 29008 29008
5213 }
5214 28417 foreach $tag (@$tagList) {
5215 18486 my @groups = $self->GetGroup($tag, -1);
5216 18486 ▶ for ($g=0; $g<@grps; ++$g) {
Branch: 1 branch
BranchTrueFalseTotal
if ($g < @grps) 18951 4729 23680
5217 18951 my $grp = $grps[$g];
5218 18951 ▶ next if $grp eq '*' or $grp eq 'all';
Branch: 1 branch
BranchTrueFalseTotal
if $grp eq "*" or $grp eq "all" 0 18951 18951
Condition33%1/3
$grp eq "*" or $grp eq "all"
l!l&&r!l&&!r
0018951
MC/DC0%0/2
$grp eq "*" or $grp eq "all"
$grp eq "*" $grp eq "all"
Truth table33%1/3
A or B
A= $grp eq "*"B= $grp eq "all"
ABresult
1X1
011
000
5219 18951 my $f;
5220 18951 ▶ if (defined($f = $fmys[$g])) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($f = $fmys[$g])) { } 3 18948 18951
5221 3 ▶ last unless defined $groups[$f];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $groups[$f] 0 3 3
5222 3 ▶ if ($f == 7) {
Branch: 1 branch
BranchTrueFalseTotal
if ($f == 7) { } 0 3 3
5223 0 ▶ next if IsSameID($self->GetTagID($tag), $grp);
Branch: 1 branch
BranchTrueFalseTotal
if &IsSameID(scalar $self->GetTagID($tag), $grp) 0 0 0
5224 } else {
5225 3 ▶ next if $grp eq lc $groups[$f];
Branch: 1 branch
BranchTrueFalseTotal
if $grp eq lc $groups[$f] 2 1 3
5226 }
5227 1 last;
5228 } else {
5229 18948 ▶ last unless grep /^$grp$/i, @groups;
Branch: 1 branch
BranchTrueFalseTotal
unless grep /^$grp$/i, @groups 13756 5192 18948
5230 }
5231 }
5232 18486 ▶ if ($g == @grps) {
Branch: 1 branch
BranchTrueFalseTotal
if ($g == @grps) 4729 13757 18486
5233 4729 ▶ return $tag unless wantarray;
Branch: 1 branch
BranchTrueFalseTotal
unless wantarray 2162 2567 4729
5234 2567 push @matches, $tag;
5235 }
5236 }
5237 26255 ▶ return wantarray ? @matches : $matches[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 597 25658 26255
5238 }
5239  
5240 #------------------------------------------------------------------------------
5241 # Remove specified tags from returned tag list, updating indices in other lists
5242 # Inputs: 0) tag list ref, 1) index list ref, 2) index list ref, 3) hash ref,
5243 # 4) true to include tags from hash instead of excluding
5244 # Returns: nothing, but updates input lists
5245 sub RemoveTagsFromList($$$$;$)
5246 73 ▶{
Subroutine RemoveTagsFromList: called CC=13 SCAR=25.7
Pod undocumented
5247 73 local $_;
5248 73 my ($tags, $list1, $list2, $exclude, $inv) = @_;
5249 73 my @filteredTags;
5250  
5251 73 ▶ if (@$list1 or @$list2) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$list1 or @$list2) { } 6 67 73
Condition100%3/3
@$list1 or @$list2
l!l&&r!l&&!r
1567
MC/DC100%2/2
@$list1 or @$list2
@$list1 @$list2
Truth table100%3/3
A or B
A= @$list1B= @$list2
ABresult
1X1
011
000
5252 6 ▶ while (@$tags) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$tags) 229 6 235
5253 229 my $tag = pop @$tags;
5254 229 my $i = @$tags;
5255 229 ▶ if ($$exclude{$tag} xor $inv) {
Branch: 1 branch
BranchTrueFalseTotal
if ($exclude->{$tag} xor $inv) { } 150 79 229
Condition50%2/4
$exclude->{$tag} xor $inv
l&&rl&&!r!l&&r!l&&!r
0150079
MC/DC50%1/2
$exclude->{$tag} xor $inv
$exclude->{$tag} $inv
Truth table50%2/4
A xor B
A= $exclude->{$tag}B= $inv
ABresult
110
101
011
000
5256 # remove index of excluded tag from each list
5257 150 ▶ @$list1 = map { $_ < $i ? $_ : $_ == $i ? () : $_ - 1 } @$list1;
Branch: 2 branches
BranchTrueFalseTotal
$_ < $i ? : 3 9 12
$_ == $i ? : 1 8 9
5258 150 ▶ @$list2 = map { $_ < $i ? $_ : $_ == $i ? () : $_ - 1 } @$list2;
Branch: 2 branches
BranchTrueFalseTotal
$_ < $i ? : 6959 1252 8211
$_ == $i ? : 150 1102 1252
5259 } else {
5260 79 unshift @filteredTags, $tag;
5261 }
5262 }
5263 } else {
5264 67 foreach (@$tags) {
5265 6950 ▶ push @filteredTags, $_ unless $$exclude{$_} xor $inv;
Branch: 1 branch
BranchTrueFalseTotal
unless $exclude->{$_} xor $inv 3181 3769 6950
Condition100%4/4
$exclude->{$_} xor $inv
l&&rl&&!r!l&&r!l&&!r
101928334862162
MC/DC100%2/2
$exclude->{$_} xor $inv
$exclude->{$_} $inv
Truth table100%4/4
A xor B
A= $exclude->{$_}B= $inv
ABresult
110
101
011
000
5266 }
5267 }
5268 73 $_[0] = \@filteredTags; # update tag list
5269 }
5270  
5271 #------------------------------------------------------------------------------
5272 # Copy tags from alternate input file
5273 # Inputs: 0) ExifTool ref, 1) family 8 group, 2) list ref for tag keys to copy
5274 # - updates tag key list to match keys newly added to $self
5275 sub CopyAltInfo($$$)
5276 8 ▶{
Subroutine CopyAltInfo: called CC=7 SCAR=19.8
Pod undocumented
5277 8 my ($self, $g8, $tags) = @_;
5278 8 my ($tag, $vtag);
5279 8 ▶ return unless $g8 =~ /(\d+)/;
Branch: 1 branch
BranchTrueFalseTotal
unless $g8 =~ /(\d+)/ 0 8 8
5280 8 ▶ my $et = $$self{ALT_EXIFTOOL}{$g8} or return;
Branch: 1 branch
BranchTrueFalseTotal
my $et = $self->{"ALT_EXIFTOOL"}{$g8} or return 8 0 8
5281 8 my $altOrder = ($1 + 1) * 100000; # increment file order
5282 8 foreach $tag (@$tags) {
5283 9 ($vtag = $tag) =~ s/( |$)/ #[$g8]/;
5284 9 ▶ unless (defined $$self{VALUE}{$vtag}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"VALUE"}{$vtag}) 8 1 9
5285 8 $$self{VALUE}{$vtag} = $$et{VALUE}{$tag};
5286 8 $$self{TAG_INFO}{$vtag} = $$et{TAG_INFO}{$tag};
5287 8 ▶ $$self{TAG_EXTRA}{$vtag} = $$et{TAG_EXTRA}{$tag} || { };
Condition50%1/2
$et->{'TAG_EXTRA'}{$tag} || {}
l!l
80
MC/DC0%0/1
$et->{'TAG_EXTRA'}{$tag} || {}
$et->{'TAG_EXTRA'}{$tag}
Truth table50%1/2
A
A= $et->{'TAG_EXTRA'}{$tag}
Aresult
11
00
5288 8 ▶ $$self{FILE_ORDER}{$vtag} = ($$et{FILE_ORDER}{$tag} || 0) + $altOrder;
Condition50%1/2
$et->{'FILE_ORDER'}{$tag} || 0
l!l
80
MC/DC0%0/1
$et->{'FILE_ORDER'}{$tag} || 0
$et->{'FILE_ORDER'}{$tag}
Truth table50%1/2
A
A= $et->{'FILE_ORDER'}{$tag}
Aresult
11
00
5289 }
5290 9 $tag = $vtag;
5291 }
5292 }
5293  
5294 #------------------------------------------------------------------------------
5295 # Set list of found tags from previously requested tags
5296 # Inputs: 0) ExifTool object reference
5297 # Returns: 0) Reference to list of found tag keys (in order of requested tags)
5298 # 1) Reference to list of indices for tags requested by value
5299 # 2) Reference to list of indices for tags specified by wildcard or "all"
5300 # Notes: index lists are returned in increasing order
5301 sub SetFoundTags($)
5302 720 ▶{
Subroutine SetFoundTags: called CC=87 SCAR=51.1
Pod undocumented
5303 720 local $_;
5304 720 my $self = shift;
5305 720 my $options = $$self{OPTIONS};
5306 720 ▶ my $reqTags = $$self{REQUESTED_TAGS} || [ ];
Condition50%1/2
$self->{'REQUESTED_TAGS'} || []
l!l
7200
MC/DC0%0/1
$self->{'REQUESTED_TAGS'} || []
$self->{'REQUESTED_TAGS'}
Truth table50%1/2
A
A= $self->{'REQUESTED_TAGS'}
Aresult
11
00
5307 720 my $duplicates = $$options{Duplicates};
5308 720 my $exclude = $$options{Exclude};
5309 720 my $fileOrder = $$self{FILE_ORDER};
5310 720 my @groupOptions;
5311 # ignore empty group options
5312 720 ▶ $$options{$_} and push @groupOptions, $_ foreach sort grep /^Group/, keys %$options;
Branch: 1 branch
BranchTrueFalseTotal
$options->{$_} and push @groupOptions, $_ 29 692 721
5313 720 ▶ my $doDups = $duplicates || $exclude || @groupOptions;
Condition83%5/6
$duplicates || $exclude || @groupOptions
l!l&&r!l&&!r
70866
$duplicates or $exclude
l!l&&r!l&&!r
708012
MC/DC66%2/3
$duplicates || $exclude || @groupOptions
$duplicates $exclude @groupOptions
Truth table75%3/4
A or B || C
A= $duplicatesB= $excludeC= @groupOptions
ABCresult
1XX1
01X1
0011
0000
5314 720 my ($tag, $rtnTags, @byValue, @wildTags);
5315  
5316 # only return requested tags if specified
5317 720 ▶ if (@$reqTags) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$reqTags) { } 367 353 720
5318 367 ▶ $rtnTags or $rtnTags = [ ];
Branch: 1 branch
BranchTrueFalseTotal
$rtnTags or $rtnTags = [] 0 367 367
5319 # scan through the requested tags and generate a list of tags we found
5320 367 my $tagHash = $$self{VALUE};
5321 367 my $reqTag;
5322 367 foreach $reqTag (@$reqTags) {
5323 989 my (@matches, $group, $allGrp, $allTag, $byValue, $g8);
5324 989 my $et = $self;
5325 989 ▶ if ($reqTag =~ /^(.*):(.+)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($reqTag =~ /^(.*):(.+)/) { } 255 734 989
5326 255 ($group, $tag) = ($1, $2);
5327 255 ▶ if ($group =~ /^(\*|all)$/i) {
Branch: 3 branches
BranchTrueFalseTotal
if ($group =~ /^(\*|all)$/i) { } 0 255 255
elsif ($reqTag =~ /\bfile(\d+):/i) { } 6 249 255
elsif (not $group =~ /^[-\w:]*$/) { } 0 249 249
5328 0 $allGrp = 1;
5329 } elsif ($reqTag =~ /\bfile(\d+):/i) {
5330 6 $g8 = "File$1";
5331 6 ▶ $et = $$self{ALT_EXIFTOOL}{$g8} || $self;
Condition33%1/3
$self->{'ALT_EXIFTOOL'}{$g8} || $self
l!l&&r!l&&!r
600
MC/DC0%0/2
$self->{'ALT_EXIFTOOL'}{$g8} || $self
$self->{'ALT_EXIFTOOL'}{$g8} $self
Truth table33%1/3
A || B
A= $self->{'ALT_EXIFTOOL'}{$g8}B= $self
ABresult
1X1
011
000
5332 6 $fileOrder = $$et{FILE_ORDER};
5333 6 $tagHash = $$et{VALUE};
5334 } elsif ($group !~ /^[-\w:]*$/) {
5335 0 $self->Warn("Invalid group name '${group}'");
5336 0 $group = 'invalid';
5337 }
5338 } else {
5339 734 $tag = $reqTag;
5340 }
5341 989 ▶ $byValue = 1 if $tag =~ s/#$// and $$options{PrintConv};
Branch: 1 branch
BranchTrueFalseTotal
if $tag =~ s/#$// and $options->{"PrintConv"} 15 974 989
Condition66%2/3
$tag =~ s/#$// and $options->{"PrintConv"}
!ll&&!rl&&r
974015
MC/DC50%1/2
$tag =~ s/#$// and $options->{"PrintConv"}
$tag =~ s/#$// $options->{"PrintConv"}
Truth table66%2/3
A and B
A= $tag =~ s/#$//B= $options->{"PrintConv"}
ABresult
0X0
100
111
5342 989 ▶ if (defined $$tagHash{$reqTag} and not $doDups) {
Branch: 5 branches
BranchTrueFalseTotal
if (defined $tagHash->{$reqTag} and not $doDups) { } 6 983 989
elsif ($tag =~ /^(\*|all)$/i) { } 164 819 983
elsif ($tag =~ /[*?]/) { } 9 810 819
elsif ($doDups or defined $group) { } 748 62 810
elsif ($tag =~ /^[-\w]+$/) { } 62 0 62
Condition100%3/3
defined $tagHash->{$reqTag} and not $doDups
!ll&&!rl&&r
7921916
MC/DC100%2/2
defined $tagHash->{$reqTag} and not $doDups
defined $tagHash->{$reqTag} not $doDups
Truth table100%3/3
A and not(B)
A= defined $tagHash->{$reqTag}B= not $doDups
ABresult
0X0
100
111
5343 6 $matches[0] = $tag;
5344 } elsif ($tag =~ /^(\*|all)$/i) {
5345 # tag name of '*' or 'all' matches all tags
5346 164 ▶ if ($doDups or $allGrp) {
Branch: 1 branch
BranchTrueFalseTotal
if ($doDups or $allGrp) { } 163 1 164
Condition66%2/3
$doDups or $allGrp
l!l&&r!l&&!r
16301
MC/DC50%1/2
$doDups or $allGrp
$doDups $allGrp
Truth table66%2/3
A or B
A= $doDupsB= $allGrp
ABresult
1X1
011
000
5347 163 @matches = grep(!/#/, keys %$tagHash);
5348 } else {
5349 1 @matches = grep(!/ /, keys %$tagHash);
5350 }
5351 164 ▶ next unless @matches; # don't want entry in list for '*' tag
Branch: 1 branch
BranchTrueFalseTotal
unless @matches 0 164 164
5352 164 $allTag = 1;
5353 } elsif ($tag =~ /[*?]/) {
5354 # allow wildcards in tag names
5355 9 $tag =~ tr/-_A-Za-z0-9*?//dc; # sterilize
5356 9 $tag =~ s/\*/[-\\w]*/g;
5357 9 $tag =~ s/\?/[-\\w]/g;
5358 9 ▶ $tag .= '( \\(.*)?' if $doDups or $allGrp;
Branch: 1 branch
BranchTrueFalseTotal
if $doDups or $allGrp 9 0 9
Condition33%1/3
$doDups or $allGrp
l!l&&r!l&&!r
900
MC/DC0%0/2
$doDups or $allGrp
$doDups $allGrp
Truth table33%1/3
A or B
A= $doDupsB= $allGrp
ABresult
1X1
011
000
5359 9 @matches = grep(/^$tag$/i, keys %$tagHash);
5360 9 ▶ next unless @matches; # don't want entry in list for wildcard tags
Branch: 1 branch
BranchTrueFalseTotal
unless @matches 0 9 9
5361 9 $allTag = 1;
5362 ▶ } elsif ($doDups or defined $group) {
Condition100%3/3
$doDups or defined $group
l!l&&r!l&&!r
739962
MC/DC100%2/2
$doDups or defined $group
$doDups defined $group
Truth table100%3/3
A or B
A= $doDupsB= defined $group
ABresult
1X1
011
000
5363 748 $tag =~ tr/-_A-Za-z0-9//dc; # sterilize
5364 # must also look for tags like "Tag (1)"
5365 # (but be sure not to match temporary ValueConv entries like "Tag #")
5366 748 @matches = grep(/^$tag( \(|$)/i, keys %$tagHash);
5367 } elsif ($tag =~ /^[-\w]+$/) {
5368 # find first matching value
5369 # (use in list context to return value instead of count)
5370 62 ($matches[0]) = grep /^$tag$/i, keys %$tagHash;
5371 62 ▶ defined $matches[0] or undef @matches;
Branch: 1 branch
BranchTrueFalseTotal
defined $matches[0] or undef @matches 0 62 62
5372 } else {
5373 0 $self->Warn("Invalid tag name '${tag}'");
5374 }
5375 989 ▶ if (defined $group and not $allGrp) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $group and not $allGrp) 255 734 989
Condition66%2/3
defined $group and not $allGrp
!ll&&!rl&&r
7340255
MC/DC50%1/2
defined $group and not $allGrp
defined $group not $allGrp
Truth table66%2/3
A and not(B)
A= defined $groupB= not $allGrp
ABresult
0X0
100
111
5376 # keep only specified group
5377 255 @matches = $et->GroupMatches($group, \@matches);
5378 255 ▶ next unless @matches or not $allTag;
Branch: 1 branch
BranchTrueFalseTotal
unless @matches or not $allTag 20 235 255
Condition100%3/3
@matches or not $allTag
l!l&&r!l&&!r
1934220
MC/DC100%2/2
@matches or not $allTag
@matches not $allTag
Truth table100%3/3
A or not(B)
A= @matchesB= not $allTag
ABresult
1X1
011
000
5379 }
5380 969 ▶ if (@matches > 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (@matches > 1) { } 162 807 969
elsif (not @matches) { } 532 275 807
5381 # maintain original file order for multiple tags
5382 162 @matches = sort { $$fileOrder{$a} <=> $$fileOrder{$b} } @matches;
5383 # return only the highest priority tag unless duplicates wanted
5384 162 ▶ unless ($doDups or $allTag or $allGrp) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($doDups or $allTag or $allGrp) 0 162 162
Condition50%3/6
$doDups or $allTag or $allGrp
l!l&&r!l&&!r
16200
$doDups or $allTag
l!l&&r!l&&!r
16110
MC/DC0%0/3
$doDups or $allTag or $allGrp
$doDups $allTag $allGrp
Truth table50%2/4
A or B or C
A= $doDupsB= $allTagC= $allGrp
ABCresult
1XX1
01X1
0011
0000
5385 0 $tag = shift @matches;
5386 0 ▶ my $oldPriority = $$et{PRIORITY}{$tag} || 1;
Condition0%0/2
$et->{'PRIORITY'}{$tag} || 1
l!l
00
MC/DC0%0/1
$et->{'PRIORITY'}{$tag} || 1
$et->{'PRIORITY'}{$tag}
Truth table0%0/2
A
A= $et->{'PRIORITY'}{$tag}
Aresult
11
00
5387 0 foreach (@matches) {
5388 0 my $priority = $$et{PRIORITY}{$_};
5389 0 ▶ $priority = 1 unless defined $priority;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $priority 0 0 0
5390 0 ▶ next unless $priority >= $oldPriority;
Branch: 1 branch
BranchTrueFalseTotal
unless $priority >= $oldPriority 0 0 0
5391 0 $tag = $_;
5392 0 ▶ $oldPriority = $priority || 1;
Condition0%0/2
$priority || 1
l!l
00
MC/DC0%0/1
$priority || 1
$priority
Truth table0%0/2
A
A= $priority
Aresult
11
00
5393 }
5394 0 @matches = ( $tag );
5395 }
5396 } elsif (not @matches) {
5397 # put entry in return list even without value (value is undef)
5398 532 ▶ $matches[0] = $byValue ? "$tag #(0)" : "$tag (0)";
Branch: 1 branch
BranchTrueFalseTotal
$byValue ? : 9 523 532
5399 # bogus file order entry to avoid warning if sorting in file order
5400 532 $$self{FILE_ORDER}{$matches[0]} = 9999;
5401 }
5402 # copy over necessary information for tags from alternate files
5403 969 ▶ if ($g8) {
Branch: 1 branch
BranchTrueFalseTotal
if ($g8) 6 963 969
5404 6 $self->CopyAltInfo($g8, \@matches);
5405 # restore variables to original values for main file
5406 6 $fileOrder = $$self{FILE_ORDER};
5407 6 $tagHash = $$self{VALUE};
5408 }
5409 # save indices of tags extracted by value
5410 969 ▶ push @byValue, scalar(@$rtnTags) .. (scalar(@$rtnTags)+scalar(@matches)-1) if $byValue;
Branch: 1 branch
BranchTrueFalseTotal
if $byValue 15 954 969
5411 # save indices of wildcard tags
5412 969 ▶ push @wildTags, scalar(@$rtnTags) .. (scalar(@$rtnTags)+scalar(@matches)-1) if $allTag;
Branch: 1 branch
BranchTrueFalseTotal
if $allTag 153 816 969
5413 969 push @$rtnTags, @matches;
5414 }
5415 } else {
5416 # no requested tags, so we want all tags
5417 353 my @allTags;
5418 353 ▶ if ($doDups) {
Branch: 1 branch
BranchTrueFalseTotal
if ($doDups) { } 353 0 353
5419 353 @allTags = keys %{$$self{VALUE}};
5420 } else {
5421 # only include tag if it doesn't end in a copy number
5422 0 @allTags = grep(!/ /, keys %{$$self{VALUE}});
5423 }
5424 353 $rtnTags = \@allTags;
5425 }
5426  
5427 # filter excluded tags and group options
5428 720 ▶ while (($exclude or @groupOptions) and @$rtnTags) {
Branch: 1 branch
BranchTrueFalseTotal
if ($exclude || @groupOptions and @$rtnTags) 72 648 720
Condition83%5/6
$exclude || @groupOptions and @$rtnTags
!ll&&!rl&&r
648072
$exclude or @groupOptions
l!l&&r!l&&!r
4527648
MC/DC66%2/3
$exclude || @groupOptions and @$rtnTags
$exclude @groupOptions @$rtnTags
Truth table60%3/5
A or B and C
A= $excludeB= @groupOptionsC= @$rtnTags
ABCresult
00X0
1X00
0100
1X11
0111
5429 72 ▶ if ($exclude) {
Branch: 1 branch
BranchTrueFalseTotal
if ($exclude) 45 27 72
5430 45 my ($pat, %exclude);
5431 45 foreach $pat (@$exclude) {
5432 61 my $group;
5433 61 ▶ if ($pat =~ /^(.*):(.+)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pat =~ /^(.*):(.+)/) { } 34 27 61
5434 34 ($group, $tag) = ($1, $2);
5435 34 ▶ if ($group =~ /^(\*|all)$/i) {
Branch: 2 branches
BranchTrueFalseTotal
if ($group =~ /^(\*|all)$/i) { } 0 34 34
elsif (not $group =~ /^[-\w:]*$/) { } 0 34 34
5436 0 undef $group;
5437 } elsif ($group !~ /^[-\w:]*$/) {
5438 0 $self->Warn("Invalid group name '${group}'");
5439 0 $group = 'invalid';
5440 }
5441 } else {
5442 27 $tag = $pat;
5443 }
5444 61 my @matches;
5445 61 ▶ if ($tag =~ /^(\*|all)$/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag =~ /^(\*|all)$/i) { } 34 27 61
5446 34 @matches = @$rtnTags;
5447 } else {
5448 # allow wildcards in tag names
5449 27 $tag =~ s/\*/[-\\w]*/g;
5450 27 $tag =~ s/\?/[-\\w]/g;
5451 27 @matches = grep(/^$tag( |$)/i, @$rtnTags);
5452 }
5453 61 ▶ @matches = $self->GroupMatches($group, \@matches) if $group and @matches;
Branch: 1 branch
BranchTrueFalseTotal
if $group and @matches 34 27 61
Condition66%2/3
$group and @matches
!ll&&!rl&&r
27034
MC/DC50%1/2
$group and @matches
$group @matches
Truth table66%2/3
A and B
A= $groupB= @matches
ABresult
0X0
100
111
5454 61 $exclude{$_} = 1 foreach @matches;
5455 }
5456 45 ▶ if (%exclude) {
Branch: 1 branch
BranchTrueFalseTotal
if (%exclude) 45 0 45
5457 # remove excluded tags from return list(s)
5458 45 RemoveTagsFromList($rtnTags, \@byValue, \@wildTags, \%exclude);
5459 45 ▶ last unless @$rtnTags; # all done if nothing left
Branch: 1 branch
BranchTrueFalseTotal
unless @$rtnTags 0 45 45
5460 }
5461 45 ▶ last if $duplicates and not @groupOptions;
Branch: 1 branch
BranchTrueFalseTotal
if $duplicates and not @groupOptions 44 1 45
Condition66%2/3
$duplicates and not @groupOptions
!ll&&!rl&&r
0144
MC/DC50%1/2
$duplicates and not @groupOptions
$duplicates not @groupOptions
Truth table66%2/3
A and not(B)
A= $duplicatesB= not @groupOptions
ABresult
0X0
100
111
5462 }
5463 # filter groups if requested, or to remove duplicates
5464 28 my (%keepTags, %wantGroup, $family, $groupOpt);
5465 28 my $allGroups = 1;
5466 # build hash of requested/excluded group names for each group family
5467 28 my $wantOrder = 0;
5468 28 foreach $groupOpt (@groupOptions) {
5469 29 ▶ $groupOpt =~ /^Group(\d*(:\d+)*)/ or next;
Branch: 1 branch
BranchTrueFalseTotal
$groupOpt =~ /^Group(\d*(:\d+)*)/ or next 29 0 29
5470 29 ▶ $family = $1 || 0;
Condition100%2/2
$1 || 0
l!l
209
MC/DC100%1/1
$1 || 0
$1
Truth table100%2/2
A
A= $1
Aresult
11
00
5471 29 ▶ $wantGroup{$family} or $wantGroup{$family} = { };
Branch: 1 branch
BranchTrueFalseTotal
$wantGroup{$family} or $wantGroup{$family} = {} 0 29 29
5472 29 my $groupList;
5473 29 ▶ if (ref $$options{$groupOpt} eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $options->{$groupOpt} eq 'ARRAY') { } 4 25 29
5474 4 $groupList = $$options{$groupOpt};
5475 } else {
5476 25 $groupList = [ $$options{$groupOpt} ];
5477 }
5478 29 foreach (@$groupList) {
5479 # groups have priority in order they were specified
5480 33 ++$wantOrder;
5481 33 my ($groupName, $want);
5482 33 ▶ if (/^-(.*)/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^-(.*)/) { } 2 31 33
5483 # excluded group begins with '-'
5484 2 $groupName = $1;
5485 2 $want = 0; # we don't want tags in this group
5486 } else {
5487 31 $groupName = $_;
5488 31 $want = $wantOrder; # we want tags in this group
5489 31 $allGroups = 0; # don't want all groups if we requested one
5490 }
5491 33 $wantGroup{$family}{$groupName} = $want;
5492 }
5493 }
5494 # loop through all tags and decide which ones we want
5495 28 my (@tags, %bestTag);
5496 28 GR_TAG: foreach $tag (@$rtnTags) {
5497 4505 my $wantTag = $allGroups; # want tag by default if want all groups
5498 4505 foreach $family (keys %wantGroup) {
5499 4676 my $group = $self->GetGroup($tag, $family);
5500 4676 my $wanted = $wantGroup{$family}{$group};
5501 4676 ▶ next unless defined $wanted;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $wanted 3464 1212 4676
5502 1212 ▶ next GR_TAG unless $wanted; # skip tag if group excluded
Branch: 1 branch
BranchTrueFalseTotal
unless $wanted 177 1035 1212
5503 # take lowest non-zero want flag
5504 1035 ▶ next if $wantTag and $wantTag < $wanted;
Branch: 1 branch
BranchTrueFalseTotal
if $wantTag and $wantTag < $wanted 0 1035 1035
Condition33%1/3
$wantTag and $wantTag < $wanted
!ll&&!rl&&r
103500
MC/DC0%0/2
$wantTag and $wantTag < $wanted
$wantTag $wantTag < $wanted
Truth table33%1/3
A and B
A= $wantTagB= $wantTag < $wanted
ABresult
0X0
100
111
5505 1035 $wantTag = $wanted;
5506 }
5507 4328 ▶ next unless $wantTag;
Branch: 1 branch
BranchTrueFalseTotal
unless $wantTag 3281 1047 4328
5508 1047 ▶ $duplicates and $keepTags{$tag} = 1, next;
Branch: 1 branch
BranchTrueFalseTotal
$duplicates and $keepTags{$tag} = 1, next 382 665 1047
5509 # determine which tag we want to keep
5510 665 my $tagName = GetTagName($tag);
5511 665 my $bestTag = $bestTag{$tagName};
5512 665 ▶ if (defined $bestTag) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $bestTag) 28 637 665
5513 28 ▶ next if $wantTag > $keepTags{$bestTag};
Branch: 1 branch
BranchTrueFalseTotal
if $wantTag > $keepTags{$bestTag} 13 15 28
5514 15 ▶ if ($wantTag == $keepTags{$bestTag}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($wantTag == $keepTags{$bestTag}) 0 15 15
5515 # want two tags with the same name -- keep the latest one
5516 0 ▶ if ($tag =~ / \((\d+)\)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag =~ / \((\d+)\)$/) 0 0 0
5517 0 my $tagNum = $1;
5518 0 ▶ next if $bestTag !~ / \((\d+)\)$/ or $1 > $tagNum;
Branch: 1 branch
BranchTrueFalseTotal
if not $bestTag =~ / \((\d+)\)$/ or $1 > $tagNum 0 0 0
Condition0%0/3
not $bestTag =~ / \((\d+)\)$/ or $1 > $tagNum
l!l&&r!l&&!r
000
MC/DC0%0/2
not $bestTag =~ / \((\d+)\)$/ or $1 > $tagNum
not $bestTag =~ / \((\d+)\)$/ $1 > $tagNum
Truth table0%0/3
not(A) or B
A= not $bestTag =~ / \((\d+)\)$/B= $1 > $tagNum
ABresult
1X1
011
000
5519 }
5520 }
5521 # this tag is better, so delete old best tag
5522 15 delete $keepTags{$bestTag};
5523 }
5524 652 $keepTags{$tag} = $wantTag; # keep this tag (for now...)
5525 652 $bestTag{$tagName} = $tag; # this is our current best tag
5526 }
5527 # include only tags we want to keep in return lists
5528 28 RemoveTagsFromList($rtnTags, \@byValue, \@wildTags, \%keepTags, 1);
5529 28 last;
5530 }
5531 720 $$self{FOUND_TAGS} = $rtnTags; # save found tags
5532  
5533 # return reference to found tag keys (and list of indices of tags to extract by value)
5534 720 ▶ return wantarray ? ($rtnTags, \@byValue, \@wildTags) : $rtnTags;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 714 6 720
5535 }
5536  
5537 #------------------------------------------------------------------------------
5538 # Utility to load our write routines if required (called via AUTOLOAD)
5539 # Inputs: 0) autoload function, 1-N) function arguments
5540 # Returns: result of function or dies if function not available
5541 sub DoAutoLoad(@)
5542 763 ▶{
Subroutine DoAutoLoad: called CC=6 SCAR=18.1
Pod undocumented
5543 763 my $autoload = shift;
5544 763 my @callInfo = split(/::/, $autoload);
5545 763 my $file = 'Image/ExifTool/Write';
5546  
5547 763 ▶ return if $callInfo[$#callInfo] eq 'DESTROY';
Branch: 1 branch
BranchTrueFalseTotal
if $callInfo[$#callInfo] eq "DESTROY" 508 255 763
5548 255 ▶ if (@callInfo == 4) {
Branch: 2 branches
BranchTrueFalseTotal
if (@callInfo == 4) { } 193 62 255
elsif ($callInfo[-1] eq 'ShiftTime') { } 1 61 62
5549 # load Image/ExifTool/WriteMODULE.pl
5550 193 $file .= "$callInfo[2].pl";
5551 } elsif ($callInfo[-1] eq 'ShiftTime') {
5552 1 $file = 'Image/ExifTool/Shift.pl'; # load Shift.pl
5553 } else {
5554 # load Image/ExifTool/Writer.pl
5555 61 $file .= 'r.pl';
5556 }
5557 # attempt to load the package
5558 255 ▶ eval { require $file } or die "Error while attempting to call $autoload\n$@\n";
Branch: 1 branch
BranchTrueFalseTotal
eval { do { require $file } } or die "Error while attempting to call $autoload\n$@\n" 255 0 255
5559 255 ▶ unless (defined &$autoload) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined &$autoload) 0 255 255
5560 0 my @caller = caller(0);
5561 # reproduce Perl's standard 'undefined subroutine' message:
5562 0 die "Undefined subroutine $autoload called at $caller[1] line $caller[2]\n";
5563 }
5564 113 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
5565 255 return &$autoload(@_); # call the function
5566 }
5567  
5568 #------------------------------------------------------------------------------
5569 # AutoLoad our writer routines when necessary
5570 #
5571 sub AUTOLOAD
5572 570 ▶{
Subroutine AUTOLOAD: called CC=1 SCAR=0.0
5573 570 return DoAutoLoad($AUTOLOAD, @_);
5574 }
5575  
5576 #------------------------------------------------------------------------------
5577 # Add cleanup routine to call before returning from Extract
5578 # Inputs: 0) ExifTool ref, 1) code ref to routine with ExifTool ref as an argument
5579 sub AddCleanup($)
5580 0 ▶{
Subroutine AddCleanup: not called CC=2 SCAR=17.9
Pod undocumented
5581 0 my ($self, $sub) = @_;
5582 0 ▶ $$self{Cleanup} or $$self{Cleanup} = [ ];
Branch: 1 branch
BranchTrueFalseTotal
$self->{"Cleanup"} or $self->{"Cleanup"} = [] 0 0 0
5583 0 push @{$$self{Cleanup}}, $sub;
5584 }
5585  
5586 #------------------------------------------------------------------------------
5587 # Add warning tag
5588 # Inputs: 0) ExifTool object reference, 1) warning message
5589 # 2) 0=normal warning, 1=minor, 2=minor with behavioural change when
5590 # ignored, 3=warning shouldn't be issued with Validate option,
5591 # bit 0x04 set causes warning count to not be incremented
5592 # Returns: true if warning tag was added
5593 sub Warn($$;$)
5594 95 ▶{
Subroutine Warn: called CC=14 SCAR=28.2
Pod undocumented
5595 95 my ($self, $str, $ignorable) = @_;
5596 95 my $noWarn = $$self{OPTIONS}{NoWarning};
5597 95 my $noCount;
5598 95 ▶ while ($ignorable) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorable) 40 55 95
5599 40 ▶ if ($ignorable & 0x04) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ignorable & 4) 1 39 40
5600 1 $noCount = 1;
5601 1 ▶ $ignorable &= 0x03 or last;
Branch: 1 branch
BranchTrueFalseTotal
$ignorable &= 3 or last 1 0 1
5602 }
5603 40 my $ignorable = $ignorable & 0x03;
5604 40 ▶ return 0 if $$self{OPTIONS}{IgnoreMinorErrors};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"OPTIONS"}{"IgnoreMinorErrors"} 1 39 40
5605 39 ▶ return 0 if $ignorable eq '3' and $$self{OPTIONS}{Validate};
Branch: 1 branch
BranchTrueFalseTotal
if $ignorable eq 3 and $self->{"OPTIONS"}{"Validate"} 0 39 39
Condition66%2/3
$ignorable eq 3 and $self->{"OPTIONS"}{"Validate"}
!ll&&!rl&&r
3810
MC/DC0%0/2
$ignorable eq 3 and $self->{"OPTIONS"}{"Validate"}
$ignorable eq 3 $self->{"OPTIONS"}{"Validate"}
Truth table66%2/3
A and B
A= $ignorable eq 3B= $self->{"OPTIONS"}{"Validate"}
ABresult
0X0
100
111
5606 0 ▶ return 1 if defined $noWarn and eval { $str =~ /$noWarn/ };
Branch: 1 branch
BranchTrueFalseTotal
if defined $noWarn and eval { do { $str =~ /$noWarn/ } } 0 39 39
Condition33%1/3
defined $noWarn and eval { do { $str =~ /$noWarn/ } }
!ll&&!rl&&r
3900
MC/DC0%0/2
defined $noWarn and eval { do { $str =~ /$noWarn/ } }
defined $noWarn eval { do { $str =~ /$noWarn/ } }
Truth table33%1/3
A and B
A= defined $noWarnB= eval { do { $str =~ /$noWarn/ } }
ABresult
0X0
100
111
5607 39 ▶ $str = $ignorable eq '2' ? "[Minor] $str" : "[minor] $str";
Branch: 1 branch
BranchTrueFalseTotal
$ignorable eq '2' ? : 2 37 39
5608 39 last;
5609 }
5610 0 ▶ unless (defined $noWarn and eval { $str =~ /$noWarn/ }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $noWarn and eval { do { $str =~ /$noWarn/ } }) 94 0 94
Condition33%1/3
defined $noWarn and eval { do { $str =~ /$noWarn/ } }
!ll&&!rl&&r
9400
MC/DC0%0/2
defined $noWarn and eval { do { $str =~ /$noWarn/ } }
defined $noWarn eval { do { $str =~ /$noWarn/ } }
Truth table33%1/3
A and B
A= defined $noWarnB= eval { do { $str =~ /$noWarn/ } }
ABresult
0X0
100
111
5611 # add each warning only once but count number of occurrences
5612 94 ▶ if ($$self{WAS_WARNED}{$str}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'WAS_WARNED'}{$str}) { } 10 84 94
5613 10 ▶ ++$$self{WAS_WARNED}{$str} unless $noCount;
Branch: 1 branch
BranchTrueFalseTotal
unless $noCount 10 0 10
5614 } else {
5615 84 $self->FoundTag('Warning', $str);
5616 84 $$self{WAS_WARNED}{$str} = 1;
5617 }
5618 }
5619 94 return 1;
5620 }
5621  
5622 #------------------------------------------------------------------------------
5623 # Add error tag
5624 # Inputs: 0) ExifTool object reference, 1) error message, 2) true if minor
5625 # Returns: true if error tag was added, otherwise warning was added
5626 sub Error($$;$)
5627 4 ▶{
Subroutine Error: called CC=5 SCAR=19.6
Pod undocumented
5628 4 my ($self, $str, $ignorable) = @_;
5629 4 ▶ if ($$self{DemoteErrors}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'DemoteErrors'}) { } 0 4 4
elsif ($ignorable) { } 1 3 4
5630 0 ▶ $self->Warn($str) and ++$$self{DemoteErrors};
Branch: 1 branch
BranchTrueFalseTotal
$self->Warn($str) and ++$self->{"DemoteErrors"} 0 0 0
5631 0 return 1;
5632 } elsif ($ignorable) {
5633 1 ▶ $$self{OPTIONS}{IgnoreMinorErrors} and $self->Warn($str), return 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->{"OPTIONS"}{"IgnoreMinorErrors"} and $self->Warn($str), (return 0) 1 0 1
5634 0 $str = "[minor] $str";
5635 }
5636 3 $self->FoundTag('Error', $str);
5637 3 return 1;
5638 }
5639  
5640 #------------------------------------------------------------------------------
5641 # Expand shortcuts
5642 # Inputs: 0) reference to list of tags, 1) set to remove trailing '#'
5643 # Notes: Handles leading '-' for excluded tags, trailing '#' for ValueConv,
5644 # multiple group names, and redirected tags
5645 sub ExpandShortcuts($;$)
5646 528 ▶{
Subroutine ExpandShortcuts: called CC=32 SCAR=43.9
Pod undocumented
5647 528 my ($tagList, $removeSuffix) = @_;
5648 528 ▶ return unless $tagList and @$tagList;
Branch: 1 branch
BranchTrueFalseTotal
unless $tagList and @$tagList 0 528 528
Condition33%1/3
$tagList and @$tagList
!ll&&!rl&&r
00528
MC/DC0%0/2
$tagList and @$tagList
$tagList @$tagList
Truth table33%1/3
A and B
A= $tagListB= @$tagList
ABresult
0X0
100
111
5649  
5650 528 require Image::ExifTool::Shortcuts;
5651  
5652 # expand shortcuts
5653 528 ▶ my $suffix = $removeSuffix ? '' : '#';
Branch: 1 branch
BranchTrueFalseTotal
$removeSuffix ? : 60 468 528
5654 528 my @expandedTags;
5655 528 my ($entry, $tag, $excl);
5656 528 foreach $entry (@$tagList) {
5657 # skip things like options hash references in list
5658 1174 ▶ if (ref $entry) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $entry) 1 1173 1174
5659 1 push @expandedTags, $entry;
5660 1 next;
5661 }
5662 # remove leading '-'
5663 1173 ($excl, $tag) = $entry =~ /^(-?)(.*)/s;
5664 1173 my ($post, @post, $pre, $v);
5665 # handle redirection
5666 1173 ▶ if (not $excl and $tag =~ /(.+?)([-+]?[<>].+)/s) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $excl and $tag =~ /(.+?)([-+]?[<>].+)/s) { } 31 1142 1173
Condition100%3/3
not $excl and $tag =~ /(.+?)([-+]?[<>].+)/s
!ll&&!rl&&r
8113431
MC/DC100%2/2
not $excl and $tag =~ /(.+?)([-+]?[<>].+)/s
not $excl $tag =~ /(.+?)([-+]?[<>].+)/s
Truth table100%3/3
not(A) and B
A= not $exclB= $tag =~ /(.+?)([-+]?[<>].+)/s
ABresult
0X0
100
111
5667 31 ($tag, $post) = ($1, $2);
5668 31 ▶ if ($post =~ /^[-+]?>/ or $post !~ /\$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($post =~ /^[-+]?>/ or not $post =~ /\$/) 23 8 31
Condition100%3/3
$post =~ /^[-+]?>/ or not $post =~ /\$/
l!l&&r!l&&!r
10138
MC/DC100%2/2
$post =~ /^[-+]?>/ or not $post =~ /\$/
$post =~ /^[-+]?>/ not $post =~ /\$/
Truth table100%3/3
A or not(B)
A= $post =~ /^[-+]?>/B= not $post =~ /\$/
ABresult
1X1
011
000
5669 # expand shortcuts in postfix (rhs of redirection)
5670 23 my ($op, $p2, $t2) = ($post =~ /([-+]?[<>])(.+:)?(.+)/);
5671 23 ▶ $p2 = '' unless defined $p2;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $p2 6 17 23
5672 23 ▶ $v = ($t2 =~ s/#$//) ? $suffix : ''; # ValueConv suffix
Branch: 1 branch
BranchTrueFalseTotal
$t2 =~ s/#$// ? : 0 23 23
5673 23 my ($match) = grep /^\Q$t2\E$/i, keys %Image::ExifTool::Shortcuts::Main;
5674 23 ▶ if ($match) {
Branch: 1 branch
BranchTrueFalseTotal
if ($match) 0 23 23
5675 0 foreach (@{$Image::ExifTool::Shortcuts::Main{$match}}) {
5676 0 ▶ /^-/ and next; # ignore excluded tags
Branch: 1 branch
BranchTrueFalseTotal
/^-/ and next 0 0 0
5677 0 ▶ if ($p2 and /(.+:)(.+)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p2 and /(.+:)(.+)/) { } 0 0 0
Condition0%0/3
$p2 and /(.+:)(.+)/
!ll&&!rl&&r
000
MC/DC0%0/2
$p2 and /(.+:)(.+)/
$p2 /(.+:)(.+)/
Truth table0%0/3
A and B
A= $p2B= /(.+:)(.+)/
ABresult
0X0
100
111
5678 0 push @post, "$op$_$v";
5679 } else {
5680 0 push @post, "$op$p2$_$v";
5681 }
5682 }
5683 0 ▶ next unless @post;
Branch: 1 branch
BranchTrueFalseTotal
unless @post 0 0 0
5684 0 $post = shift @post;
5685 }
5686 }
5687 } else {
5688 1142 $post = '';
5689 }
5690 # handle group names
5691 1173 ▶ if ($tag =~ /(.+:)(.+)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag =~ /(.+:)(.+)/) { } 328 845 1173
5692 328 ($pre, $tag) = ($1, $2);
5693 } else {
5694 845 $pre = '';
5695 }
5696 1173 ▶ $v = ($tag =~ s/#$//) ? $suffix : ''; # ValueConv suffix
Branch: 1 branch
BranchTrueFalseTotal
$tag =~ s/#$// ? : 4 1169 1173
5697 # loop over all postfixes
5698 1173 for (;;) {
5699 # expand the tag name
5700 1173 my ($match) = grep /^\Q$tag\E$/i, keys %Image::ExifTool::Shortcuts::Main;
5701 1173 ▶ if ($match) {
Branch: 1 branch
BranchTrueFalseTotal
if ($match) { } 17 1156 1173
5702 17 ▶ if ($excl) {
Branch: 2 branches
BranchTrueFalseTotal
if ($excl) { } 0 17 17
elsif (length $pre or length $post or $v) { } 1 16 17
5703 # entry starts with '-', so exclude all tags in this shortcut
5704 0 foreach (@{$Image::ExifTool::Shortcuts::Main{$match}}) {
5705 0 ▶ /^-/ and next; # ignore excluded exclude tags
Branch: 1 branch
BranchTrueFalseTotal
/^-/ and next 0 0 0
5706 # group of expanded tag takes precedence
5707 0 ▶ if ($pre and /(.+:)(.+)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pre and /(.+:)(.+)/) { } 0 0 0
Condition0%0/3
$pre and /(.+:)(.+)/
!ll&&!rl&&r
000
MC/DC0%0/2
$pre and /(.+:)(.+)/
$pre /(.+:)(.+)/
Truth table0%0/3
A and B
A= $preB= /(.+:)(.+)/
ABresult
0X0
100
111
5708 0 push @expandedTags, "$excl$_";
5709 } else {
5710 0 push @expandedTags, "$excl$pre$_";
5711 }
5712 }
5713 ▶ } elsif (length $pre or length $post or $v) {
Condition66%4/6
length $pre or length $post or $v
l!l&&r!l&&!r
1016
length $pre or length $post
l!l&&r!l&&!r
1016
MC/DC33%1/3
length $pre or length $post or $v
length $pre length $post $v
Truth table50%2/4
A or B or C
A= length $preB= length $postC= $v
ABCresult
1XX1
01X1
0011
0000
5714 1 foreach (@{$Image::ExifTool::Shortcuts::Main{$match}}) {
5715 12 /(-?)(.+:)?(.+)/;
5716 12 ▶ if ($2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($2) { } 0 12 12
5717 # group from expanded tag takes precedence
5718 0 push @expandedTags, "$_$v$post";
5719 } else {
5720 12 push @expandedTags, "$1$pre$3$v$post";
5721 }
5722 }
5723 } else {
5724 16 push @expandedTags, @{$Image::ExifTool::Shortcuts::Main{$match}};
5725 }
5726 } else {
5727 1156 push @expandedTags, "$excl$pre$tag$v$post";
5728 }
5729 1173 ▶ last unless @post;
Branch: 1 branch
BranchTrueFalseTotal
unless @post 1173 0 1173
5730 0 $post = shift @post;
5731 }
5732 }
5733 528 @$tagList = @expandedTags;
5734 }
5735  
5736 #------------------------------------------------------------------------------
5737 # Add hash of Composite tags to our composites
5738 # Inputs: 0) hash reference to table of Composite tags to add or module name,
5739 # 1) override existing tag definition
5740 sub AddCompositeTags($;$)
5741 637 ▶{
Subroutine AddCompositeTags: called CC=32 SCAR=36.3
Pod undocumented
5742 637 local $_;
5743 637 my ($add, $override) = @_;
5744 637 my ($module, $prefix, $tagID);
5745 637 ▶ unless (ref $add) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $add) { } 0 637 637
5746 637 ($prefix = $add) =~ s/.*:://;
5747 637 $module = $add;
5748 637 $add .= '::Composite';
5749 113 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
5750 637 $add = \%$add;
5751 637 $prefix .= '-';
5752 } else {
5753 0 $prefix = 'UserDefined-';
5754 }
5755 637 my $defaultGroups = $$add{GROUPS};
5756 637 my $compTable = GetTagTable('Image::ExifTool::Composite');
5757  
5758 # make sure default groups are defined in families 0 and 1
5759 637 ▶ if ($defaultGroups) {
Branch: 1 branch
BranchTrueFalseTotal
if ($defaultGroups) { } 525 112 637
5760 525 ▶ $$defaultGroups{0} or $$defaultGroups{0} = 'Composite';
Branch: 1 branch
BranchTrueFalseTotal
$defaultGroups->{0} or $defaultGroups->{0} = "Composite" 1 524 525
5761 525 ▶ $$defaultGroups{1} or $$defaultGroups{1} = 'Composite';
Branch: 1 branch
BranchTrueFalseTotal
$defaultGroups->{1} or $defaultGroups->{1} = "Composite" 4 521 525
5762 525 ▶ $$defaultGroups{2} or $$defaultGroups{2} = 'Other';
Branch: 1 branch
BranchTrueFalseTotal
$defaultGroups->{2} or $defaultGroups->{2} = "Other" 525 0 525
5763 } else {
5764 112 $defaultGroups = $$add{GROUPS} = { 0 => 'Composite', 1 => 'Composite', 2 => 'Other' };
5765 }
5766 637 SetupTagTable($add); # generate Name, TagID, etc
5767 637 foreach $tagID (sort keys %$add) {
5768 6301 ▶ next if $specialTags{$tagID}; # must skip special tags
Branch: 1 branch
BranchTrueFalseTotal
if $Image::ExifTool::specialTags{$tagID} 640 5661 6301
5769 5661 my $tagInfo = $$add{$tagID};
5770 5661 my $new = $prefix . $tagID; # new tag ID for Composite table
5771 5661 ▶ $$tagInfo{Module} = $module if $$tagInfo{Writable};
Branch: 1 branch
BranchTrueFalseTotal
if $tagInfo->{"Writable"} 1233 4428 5661
5772 5661 ▶ $$tagInfo{Override} = 1 if $override and not defined $$tagInfo{Override};
Branch: 1 branch
BranchTrueFalseTotal
if $override and not defined $tagInfo->{"Override"} 0 5661 5661
Condition33%1/3
$override and not defined $tagInfo->{"Override"}
!ll&&!rl&&r
566100
MC/DC0%0/2
$override and not defined $tagInfo->{"Override"}
$override not defined $tagInfo->{"Override"}
Truth table33%1/3
A and not(B)
A= $overrideB= not defined $tagInfo->{"Override"}
ABresult
0X0
100
111
5773 5661 $$tagInfo{IsComposite} = 1;
5774 # handle Composite tags with the same name
5775 5661 ▶ if ($compositeID{$tagID}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($compositeID{$tagID}) 364 5297 5661
5776 # determine if we want to override this tag
5777 # (=0 keep both, >0 override, <0 keep existing)
5778 364 ▶ my $over = ($$tagInfo{Override} || 0) - ($$compTable{$compositeID{$tagID}[0]}{Override} || 0);
Condition50%2/4
$tagInfo->{'Override'} || 0
l!l
0364
$$compTable{$compositeID{$tagID}[0]}{'Override'} || 0
l!l
0364
MC/DC0%0/1
$tagInfo->{'Override'} || 0
$tagInfo->{'Override'}
MC/DC0%0/1
$$compTable{$compositeID{$tagID}[0]}{'Override'} || 0
$$compTable{$compositeID{$tagID}[0]}{'Override'}
Truth table50%1/2
A
A= $tagInfo->{'Override'}
Aresult
11
00
Truth table50%1/2
A
A= $$compTable{$compositeID{$tagID}[0]}{'Override'}
Aresult
11
00
5779 364 ▶ next if $over < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $over < 0 0 364 364
5780 364 ▶ if ($over) {
Branch: 1 branch
BranchTrueFalseTotal
if ($over) 0 364 364
5781 # remove existing tags with this ID
5782 0 delete $$compTable{$_} foreach @{$compositeID{$tagID}};
5783 0 delete $compositeID{$tagID};
5784 }
5785 }
5786 # make sure new TagID is unique by adding index if necessary
5787 # (could only happen for UserDefined tags now that module name is added to tag ID)
5788 5661 my $n = 0;
5789 5661 ▶ while ($$compTable{$new}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($compTable->{$new}) 0 5661 5661
5790 0 ▶ $new =~ s/-\d+$// if $n++;
Branch: 1 branch
BranchTrueFalseTotal
if $n++ 0 0 0
5791 0 $new .= "-$n";
5792 }
5793 # use new ID and save it so we can use it in TagLookup
5794 5661 ▶ $$tagInfo{NewTagID} = $new unless $tagID eq $new;
Branch: 1 branch
BranchTrueFalseTotal
unless $tagID eq $new 5661 0 5661
5795  
5796 # add new ID to lookup of Composite tag ID's
5797 5661 ▶ $compositeID{$tagID} = [ ] unless $compositeID{$tagID};
Branch: 1 branch
BranchTrueFalseTotal
unless $compositeID{$tagID} 5297 364 5661
5798 5661 unshift @{$compositeID{$tagID}}, $new; # (most recent one first)
5799  
5800 # convert scalar Require/Desire/Inhibit entries
5801 5661 my ($type, @hashes, @scalars, %used);
5802 5661 foreach $type ('Require','Desire','Inhibit') {
5803 16983 ▶ my $req = $$tagInfo{$type} or next;
Branch: 1 branch
BranchTrueFalseTotal
my $req = $tagInfo->{$type} or next 7484 9499 16983
5804 7484 ▶ push @{ref($req) eq 'HASH' ? \@hashes : \@scalars}, $type;
Branch: 1 branch
BranchTrueFalseTotal
ref $req eq 'HASH' ? : 6472 1012 7484
5805 }
5806 5661 ▶ if (@scalars) {
Branch: 1 branch
BranchTrueFalseTotal
if (@scalars) 1012 4649 5661
5807 # make lookup for indices that are used
5808 1012 foreach $type (@hashes) {
5809 113 $used{$_} = 1 foreach keys %{$$tagInfo{$type}};
5810 }
5811 1012 my $next = 0;
5812 1012 foreach $type (@scalars) {
5813 1012 ▶ ++$next while $used{$next};
Branch: 1 branch
BranchTrueFalseTotal
$used{$next} and do { ++$next } 0 1012 1012
5814 1012 $$tagInfo{$type} = { $next++ => $$tagInfo{$type} };
5815 }
5816 }
5817 # add this Composite tag to our main Composite table
5818 5661 $$tagInfo{Table} = $compTable;
5819 # (use the original TagID, even if we changed it, so don't do this:)
5820 5661 $$tagInfo{TagID} = $new;
5821 # save tag under new ID in Composite table
5822 5661 $$compTable{$new} = $tagInfo;
5823 # set all default groups in tag
5824 5661 my $groups = $$tagInfo{Groups};
5825 5661 ▶ $groups or $groups = $$tagInfo{Groups} = { };
Branch: 1 branch
BranchTrueFalseTotal
$groups or $groups = ($tagInfo->{"Groups"} = {}) 3173 2488 5661
5826 # fill in default groups
5827 5661 foreach (keys %$defaultGroups) {
5828 16983 ▶ $$groups{$_} or $$groups{$_} = $$defaultGroups{$_};
Branch: 1 branch
BranchTrueFalseTotal
$groups->{$_} or $groups->{$_} = $defaultGroups->{$_} 4303 12680 16983
5829 }
5830 # set flag indicating group list was built
5831 5661 $$tagInfo{GotGroups} = 1;
5832 }
5833 }
5834  
5835 #------------------------------------------------------------------------------
5836 # Add tags to TagLookup (used for writing)
5837 # Inputs: 0) source hash of tag definitions, 1) name of destination tag table
5838 sub AddTagsToLookup($$)
5839 1 ▶{
Subroutine AddTagsToLookup: called CC=3 SCAR=12.0
Pod undocumented
5840 1 my ($tagHash, $table) = @_;
5841 1 ▶ if (defined &Image::ExifTool::TagLookup::AddTags) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined &Image::ExifTool::TagLookup::AddTags) { } 0 1 1
elsif (not $Image::ExifTool::pluginTags{$tagHash}) { } 1 0 1
5842 0 Image::ExifTool::TagLookup::AddTags($tagHash, $table);
5843 } elsif (not $Image::ExifTool::pluginTags{$tagHash}) {
5844 # queue these tags until TagLookup is loaded
5845 1 push @Image::ExifTool::pluginTags, [ $tagHash, $table ];
5846 # set flag so we don't load same tags twice
5847 1 $Image::ExifTool::pluginTags{$tagHash} = 1;
5848 }
5849 }
5850  
5851 #------------------------------------------------------------------------------
5852 # Expand tagInfo Flags
5853 # Inputs: 0) tagInfo hash ref
5854 # Notes: $$tagInfo{Flags} must be defined to call this routine
5855 sub ExpandFlags($)
5856 5049 ▶{
Subroutine ExpandFlags: called CC=5 SCAR=17.5
Pod undocumented
5857 5049 my $tagInfo = shift;
5858 5049 my $flags = $$tagInfo{Flags};
5859 5049 ▶ if (ref $flags eq 'ARRAY') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $flags eq 'ARRAY') { } 2621 2428 5049
elsif (ref $flags eq 'HASH') { } 0 2428 2428
5860 2621 foreach (@$flags) {
5861 7008 $$tagInfo{$_} = 1;
5862 }
5863 } elsif (ref $flags eq 'HASH') {
5864 0 my $key;
5865 0 foreach $key (keys %$flags) {
5866 0 $$tagInfo{$key} = $$flags{$key};
5867 }
5868 } else {
5869 2428 $$tagInfo{$flags} = 1;
5870 }
5871 }
5872  
5873 #------------------------------------------------------------------------------
5874 # Set up tag table (must be done once for each tag table used)
5875 # Inputs: 0) Reference to tag table
5876 # Notes: - generates 'Name' field from key if it doesn't exist
5877 # - stores 'Table' pointer and 'TagID' value
5878 # - expands 'Flags' for quick lookup
5879 sub SetupTagTable($)
5880 5462 ▶{
Subroutine SetupTagTable: called CC=11 SCAR=24.0
Pod undocumented
5881 5462 my $tagTablePtr = shift;
5882 5462 my $avoid = $$tagTablePtr{AVOID};
5883 5462 my ($tagID, $tagInfo);
5884 5462 foreach $tagID (TagTableKeys($tagTablePtr)) {
5885 236056 my @infoArray = GetTagInfoList($tagTablePtr,$tagID);
5886 # process conditional tagInfo arrays
5887 236056 foreach $tagInfo (@infoArray) {
5888 259041 $$tagInfo{Table} = $tagTablePtr;
5889 259041 $$tagInfo{TagID} = $tagID;
5890 259041 ▶ $$tagInfo{Name} or $$tagInfo{Name} = MakeTagName($tagID);
Branch: 1 branch
BranchTrueFalseTotal
$tagInfo->{"Name"} or $tagInfo->{"Name"} = &MakeTagName($tagID) 220096 38945 259041
5891 259041 ▶ $$tagInfo{Flags} and ExpandFlags($tagInfo);
Branch: 1 branch
BranchTrueFalseTotal
$tagInfo->{"Flags"} and &ExpandFlags($tagInfo) 4989 254052 259041
5892 259041 ▶ $$tagInfo{Avoid} = $avoid if defined $avoid;
Branch: 1 branch
BranchTrueFalseTotal
if defined $avoid 9508 249533 259041
5893 # calculate BitShift from Mask if necessary
5894 259041 ▶ if ($$tagInfo{Mask} and not defined $$tagInfo{BitShift}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tagInfo->{"Mask"} and not defined $tagInfo->{"BitShift"}) 3091 255950 259041
Condition100%3/3
$tagInfo->{"Mask"} and not defined $tagInfo->{"BitShift"}
!ll&&!rl&&r
25594913091
MC/DC100%2/2
$tagInfo->{"Mask"} and not defined $tagInfo->{"BitShift"}
$tagInfo->{"Mask"} not defined $tagInfo->{"BitShift"}
Truth table100%3/3
A and not(B)
A= $tagInfo->{"Mask"}B= not defined $tagInfo->{"BitShift"}
ABresult
0X0
100
111
5895 3091 my ($mask, $bitShift) = ($$tagInfo{Mask}, 0);
5896 3091 ▶ ++$bitShift until $mask & (1 << $bitShift);
Branch: 1 branch
BranchTrueFalseTotal
$mask & 1 << $bitShift or do { ++$bitShift } 3091 8632 11723
5897 3091 $$tagInfo{BitShift} = $bitShift;
5898 }
5899 }
5900 236056 ▶ next unless @infoArray > 1;
Branch: 1 branch
BranchTrueFalseTotal
unless @infoArray > 1 232123 3933 236056
5901 # add an "Index" member to each tagInfo in a list
5902 3933 my $index = 0;
5903 3933 foreach $tagInfo (@infoArray) {
5904 26918 $$tagInfo{Index} = $index++;
5905 }
5906 }
5907 }
5908  
5909 #------------------------------------------------------------------------------
5910 # Is this a PC system?
5911 # Returns: true for PC systems
5912 # uses lookup for O/S names which may use a backslash as a directory separator
5913 # (ref File::Spec of PathTools-3.2701)
5914 113 my %isPC = (MSWin32 => 1, os2 => 1, dos => 1, NetWare => 1, symbian => 1, cygwin => 1);
5915 sub IsPC()
5916 0 ▶{
Subroutine IsPC: not called CC=1 SCAR=6.9
Pod undocumented
5917 0 return $isPC{$^O};
5918 }
5919  
5920 #------------------------------------------------------------------------------
5921 # Utilities to check for numerical types
5922 # Inputs: 0) value; Returns: true if value is a numerical type
5923 # Notes: May change commas to decimals in floats for use in other locales
5924 8233 ▶sub IsFloat($) {
Subroutine IsFloat: called CC=3 SCAR=12.5
Pod undocumented
5925 8233 ▶ return 1 if $_[0] =~ /^[+-]?(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/;
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] =~ /^[+-]?(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/ 5714 2519 8233
5926 # allow comma separators (for other locales)
5927 2519 ▶ return 0 unless $_[0] =~ /^[+-]?(?=\d|,\d)\d*(,\d*)?([Ee]([+-]?\d+))?$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $_[0] =~ /^[+-]?(?=\d|,\d)\d*(,\d*)?([Ee]([+-]?\d+))?$/ 2519 0 2519
5928 0 $_[0] =~ tr/,/./; # but translate ',' to '.'
5929 0 return 1;
5930 }
5931 20366 ▶sub IsInt($) { return scalar($_[0] =~ /^[+-]?\d+$/); }
Subroutine IsInt: called CC=1 SCAR=0.0
Pod undocumented
5932 3369 ▶sub IsHex($) { return scalar($_[0] =~ /^(0x)?[0-9a-f]{1,8}$/i); }
Subroutine IsHex: called CC=1 SCAR=0.0
Pod undocumented
5933 16 ▶sub IsRational($) { return scalar($_[0] =~ m{^[-+]?\d+/\d+$}); }
Subroutine IsRational: called CC=1 SCAR=0.0
Pod undocumented
5934  
5935 # round floating point value to specified number of significant digits
5936 # Inputs: 0) value, 1) number of sig digits; Returns: rounded number
5937 sub RoundFloat($$)
5938 3522 ▶{
Subroutine RoundFloat: called CC=1 SCAR=0.0
Pod undocumented
5939 3522 my ($val, $sig) = @_;
5940 3522 return sprintf("%.${sig}g", $val);
5941 }
5942  
5943 # Convert strings to floating point numbers (or undef)
5944 # Inputs: 0-N) list of strings (may be undef)
5945 # Returns: last value converted
5946 sub ToFloat(@)
5947 995 ▶{
Subroutine ToFloat: called CC=4 SCAR=13.9
Pod undocumented
5948 995 local $_;
5949 995 foreach (@_) {
5950 10612 ▶ next unless defined $_;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_ 6653 3959 10612
5951 # (add 0 to convert "0.0" to "0" for tests)
5952 3959 ▶ $_ = /((?:[+-]?)(?=\d|\.\d)\d*(?:\.\d*)?(?:[Ee](?:[+-]?\d+))?)/ ? $1 + 0 : undef;
Branch: 1 branch
BranchTrueFalseTotal
/((?:[+-]?)(?=\d|\.\d)\d*(?:\.\d*)?(?:[Ee](?:[+-]?\d+))?)/ ? : 3952 7 3959
5953 }
5954 995 return $_[-1];
5955 }
5956  
5957 #------------------------------------------------------------------------------
5958 # Utility routines to for reading binary data values from file
5959  
5960 113 my %unpackMotorola = ( S => 'n', L => 'N', C => 'C', c => 'c' );
5961 113 my %unpackIntel = ( S => 'v', L => 'V', C => 'C', c => 'c' );
5962 113 my %unpackRev = ( N => 'V', V => 'N', C => 'C', n => 'v', v => 'n', c => 'c' );
5963  
5964 # the following 4 variables are defined in 'use vars' instead of using 'my'
5965 # because mod_perl 5.6.1 apparently has a problem with setting file-scope 'my'
5966 # variables from within subroutines (ref communication with Pavel Merdin):
5967 # $swapBytes - set if EXIF header is not native byte ordering
5968 # $swapWords - swap 32-bit words in doubles (ARM quirk)
5969 113 $currentByteOrder = 'MM'; # current byte ordering ('II' or 'MM')
5970 113 %unpackStd = %unpackMotorola;
5971  
5972 # Swap bytes in data if necessary
5973 # Inputs: 0) data, 1) number of bytes
5974 # Returns: swapped data
5975 sub SwapBytes($$)
5976 1366 ▶{
Subroutine SwapBytes: called CC=3 SCAR=11.0
Pod undocumented
5977 1366 ▶ return $_[0] unless $swapBytes;
Branch: 1 branch
BranchTrueFalseTotal
unless $Image::ExifTool::swapBytes 1154 212 1366
5978 212 my ($val, $bytes) = @_;
5979 212 my $newVal = '';
5980 212 ▶ $newVal .= substr($val, $bytes, 1) while $bytes--;
Branch: 1 branch
BranchTrueFalseTotal
$bytes-- and do { $newVal .= substr($val, $bytes, 1) } 1444 212 1656
5981 212 return $newVal;
5982 }
5983 # Swap words. Inputs: 8 bytes of data, Returns: swapped data
5984 sub SwapWords($)
5985 1302 ▶{
Subroutine SwapWords: called CC=3 SCAR=15.4
Pod undocumented
5986 1302 ▶ return $_[0] unless $swapWords and length($_[0]) == 8;
Branch: 1 branch
BranchTrueFalseTotal
unless $Image::ExifTool::swapWords and length $_[0] == 8 1302 0 1302
Condition33%1/3
$Image::ExifTool::swapWords and length $_[0] == 8
!ll&&!rl&&r
130200
MC/DC0%0/2
$Image::ExifTool::swapWords and length $_[0] == 8
$Image::ExifTool::swapWords length $_[0] == 8
Truth table33%1/3
A and B
A= $Image::ExifTool::swapWordsB= length $_[0] == 8
ABresult
0X0
100
111
5987 0 return substr($_[0],4,4) . substr($_[0],0,4)
5988 }
5989  
5990 # Unpack value, letting unpack() handle byte swapping
5991 # Inputs: 0) unpack template, 1) data reference, 2) offset
5992 # Returns: unpacked number
5993 # - uses value of %unpackStd to determine the unpack template
5994 # - can only be called for 'S' or 'L' templates since these are the only
5995 # templates for which you can specify the byte ordering.
5996 sub DoUnpackStd(@)
5997 163368 ▶{
Subroutine DoUnpackStd: called CC=2 SCAR=6.9
Pod undocumented
5998 163368 ▶ $_[2] and return unpack("x$_[2] $unpackStd{$_[0]}", ${$_[1]});
Branch: 1 branch
BranchTrueFalseTotal
$_[2] and return unpack("x$_[2] $Image::ExifTool::unpackStd{$_[0]}", ${$_[1];}) 158515 4853 163368
5999 4853 return unpack($unpackStd{$_[0]}, ${$_[1]});
6000 }
6001 # same, but with reversed byte order
6002 sub DoUnpackRev(@)
6003 12 ▶{
Subroutine DoUnpackRev: called CC=2 SCAR=8.4
Pod undocumented
6004 12 my $fmt = $unpackRev{$unpackStd{$_[0]}};
6005 12 ▶ $_[2] and return unpack("x$_[2] $fmt", ${$_[1]});
Branch: 1 branch
BranchTrueFalseTotal
$_[2] and return unpack("x$_[2] $fmt", ${$_[1];}) 12 0 12
6006 0 return unpack($fmt, ${$_[1]});
6007 }
6008 # Pack value
6009 # Inputs: 0) template, 1) value, 2) data ref (or undef), 3) offset (if data ref)
6010 # Returns: packed value
6011 sub DoPackStd(@)
6012 31736 ▶{
Subroutine DoPackStd: called CC=2 SCAR=6.9
Pod undocumented
6013 31736 my $val = pack($unpackStd{$_[0]}, $_[1]);
6014 31736 ▶ $_[2] and substr(${$_[2]}, $_[3], length($val)) = $val;
Branch: 1 branch
BranchTrueFalseTotal
$_[2] and substr(${$_[2];}, $_[3], length $val) = $val 7720 24016 31736
6015 31736 return $val;
6016 }
6017 # same, but with reversed byte order
6018 sub DoPackRev(@)
6019 0 ▶{
Subroutine DoPackRev: not called CC=2 SCAR=17.9
Pod undocumented
6020 0 my $val = pack($unpackRev{$unpackStd{$_[0]}}, $_[1]);
6021 0 ▶ $_[2] and substr(${$_[2]}, $_[3], length($val)) = $val;
Branch: 1 branch
BranchTrueFalseTotal
$_[2] and substr(${$_[2];}, $_[3], length $val) = $val 0 0 0
6022 0 return $val;
6023 }
6024  
6025 # Unpack value, handling the byte swapping manually
6026 # Inputs: 0) # bytes, 1) unpack template, 2) data reference, 3) offset
6027 # Returns: unpacked number
6028 # - uses value of $swapBytes to determine byte ordering
6029 sub DoUnpack(@)
6030 27969 ▶{
Subroutine DoUnpack: called CC=4 SCAR=13.9
Pod undocumented
6031 27969 my ($bytes, $template, $dataPt, $pos) = @_;
6032 27969 my $val;
6033 27969 ▶ if ($swapBytes) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Image::ExifTool::swapBytes) { } 5448 22521 27969
6034 5448 $val = '';
6035 5448 ▶ $val .= substr($$dataPt,$pos+$bytes,1) while $bytes--;
Branch: 1 branch
BranchTrueFalseTotal
$bytes-- and do { $val .= substr($$dataPt, $pos + $bytes, 1) } 20284 5448 25732
6036 } else {
6037 22521 $val = substr($$dataPt,$pos,$bytes);
6038 }
6039 27969 ▶ defined($val) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $val or return undef 27969 0 27969
6040 27969 return unpack($template,$val);
6041 }
6042  
6043 # Unpack double value
6044 # Inputs: 0) unpack template, 1) data reference, 2) offset
6045 # Returns: unpacked number
6046 sub DoUnpackDbl(@)
6047 1236 ▶{
Subroutine DoUnpackDbl: called CC=2 SCAR=7.0
Pod undocumented
6048 1236 my ($template, $dataPt, $pos) = @_;
6049 1236 my $val = substr($$dataPt,$pos,8);
6050 1236 ▶ defined($val) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $val or return undef 1236 0 1236
6051 # swap bytes and 32-bit words (ARM quirk) if necessary, then unpack value
6052 1236 return unpack($template, SwapWords(SwapBytes($val, 8)));
6053 }
6054  
6055 # Inputs: 0) data reference, 1) offset into data
6056 135 ▶sub Get8s($$) { return DoUnpackStd('c', @_); }
Subroutine Get8s: called CC=1 SCAR=0.0
Pod undocumented
6057 8006 ▶sub Get8u($$) { return DoUnpackStd('C', @_); }
Subroutine Get8u: called CC=1 SCAR=0.0
Pod undocumented
6058 15000 ▶sub Get16s($$) { return DoUnpack(2, 's', @_); }
Subroutine Get16s: called CC=1 SCAR=0.0
Pod undocumented
6059 78835 ▶sub Get16u($$) { return DoUnpackStd('S', @_); }
Subroutine Get16u: called CC=1 SCAR=0.0
Pod undocumented
6060 12274 ▶sub Get32s($$) { return DoUnpack(4, 'l', @_); }
Subroutine Get32s: called CC=1 SCAR=0.0
Pod undocumented
6061 76392 ▶sub Get32u($$) { return DoUnpackStd('L', @_); }
Subroutine Get32u: called CC=1 SCAR=0.0
Pod undocumented
6062 695 ▶sub GetFloat($$) { return DoUnpack(4, 'f', @_); }
Subroutine GetFloat: called CC=1 SCAR=0.0
Pod undocumented
6063 1236 ▶sub GetDouble($$) { return DoUnpackDbl('d', @_); }
Subroutine GetDouble: called CC=1 SCAR=0.0
Pod undocumented
6064 12 ▶sub Get16uRev($$) { return DoUnpackRev('S', @_); }
Subroutine Get16uRev: called CC=1 SCAR=0.0
Pod undocumented
6065 0 ▶sub Get32uRev($$) { return DoUnpackRev('L', @_); }
Subroutine Get32uRev: not called CC=1 SCAR=6.9
Pod undocumented
6066  
6067 # rationals may be a floating point number, 'inf' or 'undef'
6068 113 my ($ratNumer, $ratDenom);
6069 sub GetRational32s($$)
6070 12 ▶{
Subroutine GetRational32s: called CC=3 SCAR=12.5
Pod undocumented
6071 12 my ($dataPt, $pos) = @_;
6072 12 $ratNumer = Get16s($dataPt,$pos);
6073 12 ▶ $ratDenom = Get16s($dataPt, $pos + 2) or return $ratNumer ? 'inf' : 'undef';
Branch: 2 branches
BranchTrueFalseTotal
$ratDenom = &Get16s($dataPt, $pos + 2) or return $ratNumer ? "inf" : "undef" 12 0 12
$ratNumer ? : 0 0 0
6074 # round off to a reasonable number of significant figures
6075 12 return RoundFloat($ratNumer / $ratDenom, 7);
6076 }
6077 sub GetRational32u($$)
6078 12 ▶{
Subroutine GetRational32u: called CC=3 SCAR=12.5
Pod undocumented
6079 12 my ($dataPt, $pos) = @_;
6080 12 $ratNumer = Get16u($dataPt,$pos);
6081 12 ▶ $ratDenom = Get16u($dataPt, $pos + 2) or return $ratNumer ? 'inf' : 'undef';
Branch: 2 branches
BranchTrueFalseTotal
$ratDenom = &Get16u($dataPt, $pos + 2) or return $ratNumer ? "inf" : "undef" 12 0 12
$ratNumer ? : 0 0 0
6082 12 return RoundFloat($ratNumer / $ratDenom, 7);
6083 }
6084 sub GetRational64s($$)
6085 690 ▶{
Subroutine GetRational64s: called CC=3 SCAR=12.5
Pod undocumented
6086 690 my ($dataPt, $pos) = @_;
6087 690 $ratNumer = Get32s($dataPt,$pos);
6088 690 ▶ $ratDenom = Get32s($dataPt, $pos + 4) or return $ratNumer ? 'inf' : 'undef';
Branch: 2 branches
BranchTrueFalseTotal
$ratDenom = &Get32s($dataPt, $pos + 4) or return $ratNumer ? "inf" : "undef" 690 0 690
$ratNumer ? : 0 0 0
6089 690 return RoundFloat($ratNumer / $ratDenom, 10);
6090 }
6091 sub GetRational64u($$)
6092 2840 ▶{
Subroutine GetRational64u: called CC=3 SCAR=11.0
Pod undocumented
6093 2840 my ($dataPt, $pos) = @_;
6094 2840 $ratNumer = Get32u($dataPt,$pos);
6095 2840 ▶ $ratDenom = Get32u($dataPt, $pos + 4) or return $ratNumer ? 'inf' : 'undef';
Branch: 2 branches
BranchTrueFalseTotal
$ratDenom = &Get32u($dataPt, $pos + 4) or return $ratNumer ? "inf" : "undef" 2808 32 2840
$ratNumer ? : 0 32 32
6096 2808 return RoundFloat($ratNumer / $ratDenom, 10);
6097 }
6098 sub GetFixed16s($$)
6099 18 ▶{
Subroutine GetFixed16s: called CC=2 SCAR=7.1
Pod undocumented
6100 18 my ($dataPt, $pos) = @_;
6101 18 my $val = Get16s($dataPt, $pos) / 0x100;
6102 18 ▶ return int($val * 1000 + ($val<0 ? -0.5 : 0.5)) / 1000;
Branch: 1 branch
BranchTrueFalseTotal
$val < 0 ? : 0 18 18
6103 }
6104 sub GetFixed16u($$)
6105 0 ▶{
Subroutine GetFixed16u: not called CC=1 SCAR=6.9
Pod undocumented
6106 0 my ($dataPt, $pos) = @_;
6107 0 return int((Get16u($dataPt, $pos) / 0x100) * 1000 + 0.5) / 1000;
6108 }
6109 sub GetFixed32s($$)
6110 1889 ▶{
Subroutine GetFixed32s: called CC=2 SCAR=6.9
Pod undocumented
6111 1889 my ($dataPt, $pos) = @_;
6112 1889 my $val = Get32s($dataPt, $pos) / 0x10000;
6113 # remove insignificant digits
6114 1889 ▶ return int($val * 1e5 + ($val>0 ? 0.5 : -0.5)) / 1e5;
Branch: 1 branch
BranchTrueFalseTotal
$val > 0 ? : 1255 634 1889
6115 }
6116 sub GetFixed32u($$)
6117 216 ▶{
Subroutine GetFixed32u: called CC=1 SCAR=0.0
Pod undocumented
6118 216 my ($dataPt, $pos) = @_;
6119 # remove insignificant digits
6120 216 return int((Get32u($dataPt, $pos) / 0x10000) * 1e5 + 0.5) / 1e5;
6121 }
6122 # Inputs: 0) value, 1) data ref, 2) offset
6123 5 ▶sub Set8s(@) { return DoPackStd('c', @_); }
Subroutine Set8s: called CC=1 SCAR=0.0
Pod undocumented
6124 308 ▶sub Set8u(@) { return DoPackStd('C', @_); }
Subroutine Set8u: called CC=1 SCAR=0.0
Pod undocumented
6125 12729 ▶sub Set16u(@) { return DoPackStd('S', @_); }
Subroutine Set16u: called CC=1 SCAR=0.0
Pod undocumented
6126 18694 ▶sub Set32u(@) { return DoPackStd('L', @_); }
Subroutine Set32u: called CC=1 SCAR=0.0
Pod undocumented
6127 0 ▶sub Set16uRev(@) { return DoPackRev('S', @_); }
Subroutine Set16uRev: not called CC=1 SCAR=6.9
Pod undocumented
6128  
6129 #------------------------------------------------------------------------------
6130 # Get current byte order ('II' or 'MM')
6131 14749 ▶sub GetByteOrder() { return $currentByteOrder; }
Subroutine GetByteOrder: called CC=1 SCAR=0.0
Pod undocumented
6132  
6133 #------------------------------------------------------------------------------
6134 # Set byte ordering
6135 # Inputs: 0) 'MM'=motorola, 'II'=intel (will translate 'BigEndian', 'LittleEndian')
6136 # Returns: 1 on success
6137 sub SetByteOrder($)
6138 16310 ▶{
Subroutine SetByteOrder: called CC=8 SCAR=21.4
Pod undocumented
6139 16310 my $order = shift;
6140  
6141 16310 ▶ if ($order eq 'MM') { # big endian (Motorola)
Branch: 4 branches
BranchTrueFalseTotal
if ($order eq 'MM') { } 8653 7657 16310
elsif ($order eq 'II') { } 7460 197 7657
elsif ($order =~ /^Big/i) { } 16 181 197
elsif ($order =~ /^Little/i) { } 12 169 181
6142 8653 %unpackStd = %unpackMotorola;
6143 } elsif ($order eq 'II') { # little endian (Intel)
6144 7460 %unpackStd = %unpackIntel;
6145 } elsif ($order =~ /^Big/i) {
6146 16 $order = 'MM';
6147 16 %unpackStd = %unpackMotorola;
6148 } elsif ($order =~ /^Little/i) {
6149 12 $order = 'II';
6150 12 %unpackStd = %unpackIntel;
6151 } else {
6152 169 return 0;
6153 }
6154 16141 my $val = unpack('S','A ');
6155 16141 my $nativeOrder;
6156 16141 ▶ if ($val == 0x4120) { # big endian
Branch: 2 branches
BranchTrueFalseTotal
if ($val == 16672) { } 0 16141 16141
elsif ($val == 8257) { } 16141 0 16141
6157 0 $nativeOrder = 'MM';
6158 } elsif ($val == 0x2041) { # little endian
6159 16141 $nativeOrder = 'II';
6160 } else {
6161 0 warn sprintf("Unknown native byte order! (pattern %x)\n",$val);
6162 0 return 0;
6163 }
6164 16141 $currentByteOrder = $order; # save current byte order
6165  
6166 # swap bytes if our native CPU byte ordering is not the same as the EXIF
6167 16141 $swapBytes = ($order ne $nativeOrder);
6168  
6169 # little-endian ARM has big-endian words for doubles (thanks Riku Voipio)
6170 # (Note: Riku's patch checked for '0ff3', but I think it should be 'f03f' since
6171 # 1 is '000000000000f03f' on an x86 -- so check for both, but which is correct?)
6172 16141 my $pack1d = pack('d', 1);
6173 16141 ▶ $swapWords = ($pack1d eq "\0\0\x0f\xf3\0\0\0\0" or
Condition33%1/3
$pack1d eq "\000\000\cO\363\000\000\000\000" || $pack1d eq "\000\000\360?\000\000\000\000"
l!l&&r!l&&!r
0016141
MC/DC0%0/2
$pack1d eq "\000\000\cO\363\000\000\000\000" || $pack1d eq "\000\000\360?\000\000\000\000"
$pack1d eq "\000\000\cO\363\000\000\000\000" $pack1d eq "\000\000\360?\000\000\000\000"
Truth table33%1/3
A || B
A= $pack1d eq "\000\000\cO\363\000\000\000\000"B= $pack1d eq "\000\000\360?\000\000\000\000"
ABresult
1X1
011
000
6174 $pack1d eq "\0\0\xf0\x3f\0\0\0\0");
6175 16141 return 1;
6176 }
6177  
6178 #------------------------------------------------------------------------------
6179 # Change byte order
6180 sub ToggleByteOrder()
6181 39 ▶{
Subroutine ToggleByteOrder: called CC=2 SCAR=6.9
Pod undocumented
6182 39 ▶ SetByteOrder(GetByteOrder() eq 'II' ? 'MM' : 'II');
Branch: 1 branch
BranchTrueFalseTotal
&GetByteOrder() eq 'II' ? : 4 35 39
6183 }
6184  
6185 #------------------------------------------------------------------------------
6186 # hash lookups for reading values from data
6187 113 my %formatSize = (
6188 int8s => 1,
6189 int8u => 1,
6190 int16s => 2,
6191 int16u => 2,
6192 int16uRev => 2,
6193 int32s => 4,
6194 int32u => 4,
6195 int32uRev => 4,
6196 int64s => 8,
6197 int64u => 8,
6198 rational32s => 4,
6199 rational32u => 4,
6200 rational64s => 8,
6201 rational64u => 8,
6202 fixed16s => 2,
6203 fixed16u => 2,
6204 fixed32s => 4,
6205 fixed32u => 4,
6206 fixed64s => 8,
6207 float => 4,
6208 double => 8,
6209 extended => 10,
6210 unicode => 2,
6211 complex => 8,
6212 string => 1,
6213 binary => 1,
6214 'undef' => 1,
6215 ifd => 4,
6216 ifd64 => 8,
6217 ue7 => 1,
6218 utf8 => 1, # (Exif 3.0)
6219 );
6220 113 my %readValueProc = (
6221 int8s => \&Get8s,
6222 int8u => \&Get8u,
6223 int16s => \&Get16s,
6224 int16u => \&Get16u,
6225 int16uRev => \&Get16uRev,
6226 int32s => \&Get32s,
6227 int32u => \&Get32u,
6228 int32uRev => \&Get32uRev,
6229 int64s => \&Get64s,
6230 int64u => \&Get64u,
6231 rational32s => \&GetRational32s,
6232 rational32u => \&GetRational32u,
6233 rational64s => \&GetRational64s,
6234 rational64u => \&GetRational64u,
6235 fixed16s => \&GetFixed16s,
6236 fixed16u => \&GetFixed16u,
6237 fixed32s => \&GetFixed32s,
6238 fixed32u => \&GetFixed32u,
6239 fixed64s => \&GetFixed64s,
6240 float => \&GetFloat,
6241 double => \&GetDouble,
6242 extended => \&GetExtended,
6243 ifd => \&Get32u,
6244 ifd64 => \&Get64u,
6245 );
6246 # lookup for all rational types
6247 113 my %isRational = (
6248 rational32u => 1,
6249 rational32s => 1,
6250 rational64u => 1,
6251 rational64s => 1,
6252 );
6253 1600 ▶sub FormatSize($) { return $formatSize{$_[0]}; }
Subroutine FormatSize: called CC=1 SCAR=0.0
Pod undocumented
6254  
6255 #------------------------------------------------------------------------------
6256 # Read value from binary data (with current byte ordering)
6257 # Inputs: 0) data reference, 1) value offset, 2) format string,
6258 # 3) number of values (or undef to use all data),
6259 # 4) valid data length relative to offset (or undef to use all data),
6260 # 5) optional pointer to returned rational
6261 # Returns: converted value, or undefined if data isn't there
6262 # or list of values in list context
6263 sub ReadValue($$$;$$$)
6264 37363 ▶{
Subroutine ReadValue: called CC=16 SCAR=27.8
Pod undocumented
6265 37363 my ($dataPt, $offset, $format, $count, $size, $ratPt) = @_;
6266  
6267 37363 my $len = $formatSize{$format};
6268 37363 ▶ unless ($len) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($len) 0 37363 37363
6269 0 warn "Unknown format $format";
6270 0 $len = 1;
6271 }
6272 37363 ▶ $size = length($$dataPt) - $offset unless defined $size;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $size 0 37363 37363
6273 37363 ▶ unless ($count) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($count) 1417 35946 37363
6274 1417 ▶ return '' if defined $count or $size < $len;
Branch: 1 branch
BranchTrueFalseTotal
if defined $count or $size < $len 29 1388 1417
Condition100%3/3
defined $count or $size < $len
l!l&&r!l&&!r
8211388
MC/DC100%2/2
defined $count or $size < $len
defined $count $size < $len
Truth table100%3/3
A or B
A= defined $countB= $size < $len
ABresult
1X1
011
000
6275 1388 $count = int($size / $len);
6276 }
6277 # make sure entry is inside data
6278 37334 ▶ if ($len * $count > $size) {
Branch: 1 branch
BranchTrueFalseTotal
if ($len * $count > $size) 3 37331 37334
6279 3 $count = int($size / $len); # shorten count if necessary
6280 3 ▶ $count < 1 and return undef; # return undefined if no data
Branch: 1 branch
BranchTrueFalseTotal
$count < 1 and return undef 3 0 3
6281 }
6282 37331 my @vals;
6283 37331 my $proc = $readValueProc{$format};
6284 37331 ▶ if (not $proc) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $proc) { } 6623 30708 37331
elsif ($isRational{$format} and $ratPt) { } 3132 27576 30708
6285 # handle undef/binary/string (also unsupported unicode/complex)
6286 6623 $vals[0] = substr($$dataPt, $offset, $count * $len);
6287 # truncate string at null terminator if necessary
6288 6623 ▶ $vals[0] =~ s/\0.*//s if $format eq 'string';
Branch: 1 branch
BranchTrueFalseTotal
if $format eq "string" 3895 2728 6623
6289 ▶ } elsif ($isRational{$format} and $ratPt) {
Condition100%3/3
$isRational{$format} and $ratPt
!ll&&!rl&&r
27500763132
MC/DC100%2/2
$isRational{$format} and $ratPt
$isRational{$format} $ratPt
Truth table100%3/3
A and B
A= $isRational{$format}B= $ratPt
ABresult
0X0
100
111
6290 # store rationals separately as string fractions
6291 3132 my @rat;
6292 3132 for (;;) {
6293 3466 push @vals, &$proc($dataPt, $offset);
6294 3466 push @rat, "$ratNumer/$ratDenom";
6295 3466 ▶ last if --$count <= 0;
Branch: 1 branch
BranchTrueFalseTotal
if --$count <= 0 3132 334 3466
6296 334 $offset += $len;
6297 }
6298 3132 $$ratPt = join(' ',@rat);
6299 } else {
6300 27576 for (;;) {
6301 50479 push @vals, &$proc($dataPt, $offset);
6302 50479 ▶ last if --$count <= 0;
Branch: 1 branch
BranchTrueFalseTotal
if --$count <= 0 27576 22903 50479
6303 22903 $offset += $len;
6304 }
6305 }
6306 37331 ▶ return @vals if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 412 36919 37331
6307 36919 ▶ return join(' ', @vals) if @vals > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @vals > 1 3713 33206 36919
6308 33206 return $vals[0];
6309 }
6310  
6311 #------------------------------------------------------------------------------
6312 # Decode string with specified encoding
6313 # Inputs: 0) ExifTool object ref, 1) string to decode
6314 # 2) source character set name (undef for current Charset)
6315 # 3) optional source byte order (2-byte and 4-byte fixed-width sets only)
6316 # 4) optional destination character set (defaults to Charset setting)
6317 # 5) optional destination byte order (2-byte and 4-byte fixed-width only)
6318 # Returns: string in destination encoding
6319 # Note: ExifTool ref may be undef if character both character sets are provided
6320 # (but in this case no warnings will be issued)
6321 sub Decode($$$;$$$)
6322 6494 ▶{
Subroutine Decode: called CC=13 SCAR=29.8
Pod undocumented
6323 6494 my ($self, $val, $from, $fromOrder, $to, $toOrder) = @_;
6324 6494 ▶ $from or $from = $$self{OPTIONS}{Charset};
Branch: 1 branch
BranchTrueFalseTotal
$from or $from = $self->{"OPTIONS"}{"Charset"} 6382 112 6494
6325 6494 ▶ $to or $to = $$self{OPTIONS}{Charset};
Branch: 1 branch
BranchTrueFalseTotal
$to or $to = $self->{"OPTIONS"}{"Charset"} 294 6200 6494
6326 6494 ▶ if ($from ne $to and length $val) {
Branch: 1 branch
BranchTrueFalseTotal
if ($from ne $to and length $val) 1165 5329 6494
Condition100%3/3
$from ne $to and length $val
!ll&&!rl&&r
5318111165
MC/DC100%2/2
$from ne $to and length $val
$from ne $to length $val
Truth table100%3/3
A and B
A= $from ne $toB= length $val
ABresult
0X0
100
111
6327 1165 require Image::ExifTool::Charset;
6328 1165 my $cs1 = $Image::ExifTool::Charset::csType{$from};
6329 1165 my $cs2 = $Image::ExifTool::Charset::csType{$to};
6330 1165 ▶ if ($cs1 and $cs2 and not $cs2 & 0x002) {
Branch: 2 branches
BranchTrueFalseTotal
if ($cs1 and $cs2 and not $cs2 & 2) { } 1165 0 1165
elsif ($self) { } 0 0 0
Condition33%2/6
$cs1 and $cs2 and not $cs2 & 2
!ll&&!rl&&r
001165
$cs1 and $cs2
!ll&&!rl&&r
001165
MC/DC0%0/3
$cs1 and $cs2 and not $cs2 & 2
$cs1 $cs2 not $cs2 & 2
Truth table25%1/4
A and B and not(C)
A= $cs1B= $cs2C= not $cs2 & 2
ABCresult
0XX0
10X0
1100
1111
6331 # treat as straight ASCII if no character will need remapping
6332 1165 ▶ if (($cs1 | $cs2) & 0x680 or $val =~ /[\x80-\xff]/) {
Branch: 1 branch
BranchTrueFalseTotal
if (($cs1 | $cs2) & 1664 or $val =~ /[\x80-\xff]/) 825 340 1165
Condition100%3/3
($cs1 | $cs2) & 1664 or $val =~ /[\x80-\xff]/
l!l&&r!l&&!r
73293340
MC/DC100%2/2
($cs1 | $cs2) & 1664 or $val =~ /[\x80-\xff]/
($cs1 | $cs2) & 1664 $val =~ /[\x80-\xff]/
Truth table100%3/3
A or B
A= ($cs1 | $cs2) & 1664B= $val =~ /[\x80-\xff]/
ABresult
1X1
011
000
6333 825 my $uni = Image::ExifTool::Charset::Decompose($self, $val, $from, $fromOrder);
6334 825 $val = Image::ExifTool::Charset::Recompose($self, $uni, $to, $toOrder);
6335 }
6336 } elsif ($self) {
6337 0 ▶ my $set = $cs1 ? $to : $from;
Branch: 1 branch
BranchTrueFalseTotal
$cs1 ? : 0 0 0
6338 0 ▶ unless ($$self{"DecodeWarn$set"}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($$self{"DecodeWarn$set"}) 0 0 0
6339 0 $self->Warn("Unsupported character set ($set)");
6340 0 $$self{"DecodeWarn$set"} = 1;
6341 }
6342 }
6343 }
6344 6494 return $val;
6345 }
6346  
6347 #------------------------------------------------------------------------------
6348 # Encode string (in Charset encoding) to specified encoding
6349 # Inputs: 0) ExifTool object ref, 1) string, 2) destination character set name,
6350 # 3) optional destination byte order (2-byte and 4-byte fixed-width sets only)
6351 # Returns: string in specified encoding
6352 sub Encode($$;$$)
6353 110 ▶{
Subroutine Encode: called CC=1 SCAR=0.0
Pod undocumented
6354 110 my ($self, $val, $to, $toOrder) = @_;
6355 110 return $self->Decode($val, undef, undef, $to, $toOrder);
6356 }
6357  
6358 #------------------------------------------------------------------------------
6359 # Decode bit mask
6360 # Inputs: 0) value to decode, 1) Reference to hash for decoding (or undef)
6361 # 2) optional bits per word (defaults to 32)
6362 sub DecodeBits($$;$)
6363 181 ▶{
Subroutine DecodeBits: called CC=9 SCAR=22.0
Pod undocumented
6364 181 my ($vals, $lookup, $bits) = @_;
6365 181 ▶ $bits or $bits = 32;
Branch: 1 branch
BranchTrueFalseTotal
$bits or $bits = 32 40 141 181
6366 181 my ($val, $i, @bitList);
6367 181 my $num = 0;
6368 181 foreach $val (split ' ', $vals) {
6369 249 ▶ for ($i=0; $i<$bits; ++$i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $bits) 6240 249 6489
6370 6240 ▶ next unless $val & (1 << $i);
Branch: 1 branch
BranchTrueFalseTotal
unless $val & 1 << $i 6092 148 6240
6371 148 my $n = $i + $num;
6372 148 ▶ if (not $lookup) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $lookup) { } 19 129 148
elsif ($lookup->{$n}) { } 123 6 129
6373 19 push @bitList, $n;
6374 } elsif ($$lookup{$n}) {
6375 123 push @bitList, $$lookup{$n};
6376 } else {
6377 6 push @bitList, "[$n]";
6378 }
6379 }
6380 249 $num += $bits;
6381 }
6382 181 ▶ return '(none)' unless @bitList;
Branch: 1 branch
BranchTrueFalseTotal
unless @bitList 80 101 181
6383 101 ▶ return join($lookup ? ', ' : ',', @bitList);
Branch: 1 branch
BranchTrueFalseTotal
$lookup ? : 82 19 101
6384 }
6385  
6386 #------------------------------------------------------------------------------
6387 # Validate an extracted image and repair if necessary
6388 # Inputs: 0) ExifTool object reference, 1) image reference, 2) tag name or key
6389 # Returns: image reference or undef if it wasn't valid
6390 # Note: should be called from RawConv, not ValueConv
6391 sub ValidateImage($$$)
6392 208 ▶{
Subroutine ValidateImage: called CC=6 SCAR=19.0
Pod undocumented
6393 208 my ($self, $imagePt, $tag) = @_;
6394 208 ▶ return undef if $$imagePt eq 'none';
Branch: 1 branch
BranchTrueFalseTotal
if $$imagePt eq "none" 0 208 208
6395 208 ▶ unless ($$imagePt =~ /^(Binary data|\xff\xd8\xff)/ or
Branch: 1 branch
BranchTrueFalseTotal
unless ($$imagePt =~ /^(Binary data|\xff\xd8\xff)/ or $$imagePt =~ s/^.(\xd8\xff\xdb)/\377$1/s or $self->Options("IgnoreMinorErrors")) 124 84 208
Condition83%5/6
$$imagePt =~ /^(Binary data|\xff\xd8\xff)/ or $$imagePt =~ s/^.(\xd8\xff\xdb)/\377$1/s or $self->Options("IgnoreMinorErrors")
l!l&&r!l&&!r
7410124
$$imagePt =~ /^(Binary data|\xff\xd8\xff)/ or $$imagePt =~ s/^.(\xd8\xff\xdb)/\377$1/s
l!l&&r!l&&!r
740134
MC/DC66%2/3
$$imagePt =~ /^(Binary data|\xff\xd8\xff)/ or $$imagePt =~ s/^.(\xd8\xff\xdb)/\377$1/s or $self->Options("IgnoreMinorErrors")
$$imagePt =~ /^(Binary data|\xff\xd8\xff)/ $$imagePt =~ s/^.(\xd8\xff\xdb)/\377$1/s $self->Options("IgnoreMinorErrors")
Truth table75%3/4
A or B or C
A= $$imagePt =~ /^(Binary data|\xff\xd8\xff)/B= $$imagePt =~ s/^.(\xd8\xff\xdb)/\377$1/sC= $self->Options("IgnoreMinorErrors")
ABCresult
1XX1
01X1
0011
0000
6396 # the first byte of the preview of some Minolta cameras is wrong,
6397 # so check for this and set it back to 0xff if necessary
6398 $$imagePt =~ s/^.(\xd8\xff\xdb)/\xff$1/s or
6399 $self->Options('IgnoreMinorErrors'))
6400 {
6401 # issue warning only if the tag was specifically requested
6402 124 ▶ if ($$self{REQ_TAG_LOOKUP}{lc GetTagName($tag)}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"REQ_TAG_LOOKUP"}{lc &GetTagName($tag)}) 0 124 124
6403 0 $self->Warn("$tag is not a valid JPEG image",1);
6404 0 return undef;
6405 }
6406 }
6407 208 return $imagePt;
6408 }
6409  
6410 #------------------------------------------------------------------------------
6411 # Validate a tag name argument (including group name and wildcards, etc)
6412 # Inputs: 0) tag name
6413 # Returns: true if tag name is valid
6414 # - a tag name may contain [-_A-Za-z0-9], but may not start with [-0-9]
6415 # - tag names may contain wildcards [?*], and end with a hash [#]
6416 # - may have group name prefixes (which may have family number prefix), separated by colons
6417 # - a group name may be zero or more characters
6418 sub ValidTagName($)
6419 54 ▶{
Subroutine ValidTagName: called CC=1 SCAR=0.0
Pod undocumented
6420 54 my $tag = shift;
6421 54 return $tag =~ /^(([-\w]*|\d*\*):)*[_a-zA-Z?*][-\w?*]*#?$/;
6422 }
6423  
6424 #------------------------------------------------------------------------------
6425 # Generate a valid tag name based on the tag ID or name
6426 # Inputs: 0) tag ID or name
6427 # Returns: valid tag name
6428 sub MakeTagName($)
6429 39041 ▶{
Subroutine MakeTagName: called CC=3 SCAR=11.0
Pod undocumented
6430 39041 my $name = shift;
6431 39041 $name =~ tr/-_a-zA-Z0-9//dc; # remove illegal characters
6432 39041 $name = ucfirst $name; # capitalize first letter
6433 # must at least 2 characters long and not start with - or 0-9-
6434 39041 ▶ $name = "Tag$name" if length($name) < 2 or $name =~ /^[-0-9]/;
Branch: 1 branch
BranchTrueFalseTotal
if length $name < 2 or $name =~ /^[-0-9]/ 1 39040 39041
Condition66%2/3
length $name < 2 or $name =~ /^[-0-9]/
l!l&&r!l&&!r
0139040
MC/DC50%1/2
length $name < 2 or $name =~ /^[-0-9]/
length $name < 2 $name =~ /^[-0-9]/
Truth table66%2/3
A or B
A= length $name < 2B= $name =~ /^[-0-9]/
ABresult
1X1
011
000
6435 39041 return $name;
6436 }
6437  
6438 #------------------------------------------------------------------------------
6439 # Make description from a tag name
6440 # Inputs: 0) tag name 1) optional tagID to add at end of description
6441 # Returns: description
6442 sub MakeDescription($;$)
6443 11317 ▶{
Subroutine MakeDescription: called CC=4 SCAR=13.9
Pod undocumented
6444 11317 my ($tag, $tagID) = @_;
6445 # start with the tag name and force first letter to be upper case
6446 11317 my $desc = ucfirst($tag);
6447 # translate underlines to spaces
6448 11317 $desc =~ tr/_/ /;
6449 # remove hex TagID from name (to avoid inserting spaces in the number)
6450 11317 ▶ $desc =~ s/ (0x[\da-f]+)$//i and $tagID = $1 unless defined $tagID;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $tagID 10214 1103 11317
Condition66%4/6
defined $tagID || $desc =~ s/ (0x[\da-f]+)$//i && ($tagID = $1)
l!l
1103102140
$desc =~ s/ (0x[\da-f]+)$//i and $tagID = $1
!ll
1020590
MC/DC0%0/3
defined $tagID || $desc =~ s/ (0x[\da-f]+)$//i && ($tagID = $1)
defined $tagID $desc =~ s/ (0x[\da-f]+)$//i $tagID = $1
Truth table0%0/4
A || B and C
A= defined $tagIDB= $desc =~ s/ (0x[\da-f]+)$//iC= $tagID = $1
ABCresult
1XX1
0111
00X0
0100
6451 # put a space between lower/UPPER case and lower/number combinations
6452 11317 $desc =~ s/([a-z])([A-Z\d])/$1 $2/g;
6453 # put a space between acronyms and words
6454 11317 $desc =~ s/([A-Z])([A-Z][a-z])/$1 $2/g;
6455 # put spaces after numbers (if more than one character follows the number)
6456 11317 $desc =~ s/(\d)([A-Z]\S)/$1 $2/g;
6457 # add TagID to description
6458 11317 ▶ $desc .= ' ' . $tagID if defined $tagID;
Branch: 1 branch
BranchTrueFalseTotal
if defined $tagID 1112 10205 11317
6459 11317 return $desc;
6460 }
6461  
6462 #------------------------------------------------------------------------------
6463 # Get descriptions for all tags in an array
6464 # Inputs: 0) ExifTool ref, 1) reference to list of tag keys
6465 # Returns: reference to hash lookup for descriptions
6466 # Note: Returned descriptions are NOT escaped by ESCAPE_PROC
6467 sub GetDescriptions($$)
6468 0 ▶{
Subroutine GetDescriptions: not called CC=2 SCAR=17.9
Pod undocumented
6469 0 local $_;
6470 0 my ($self, $tags) = @_;
6471 0 my %desc;
6472 0 my $oldEscape = $$self{ESCAPE_PROC};
6473 0 delete $$self{ESCAPE_PROC};
6474 0 $desc{$_} = $self->GetDescription($_) foreach @$tags;
6475 0 $$self{ESCAPE_PROC} = $oldEscape;
6476 0 return \%desc;
6477 }
6478  
6479 #------------------------------------------------------------------------------
6480 # Apply filter to value(s) if necessary
6481 # Inputs: 0) ExifTool ref, 1) filter expression, 2) reference to value to filter
6482 # Returns: true unless a filter returned undef; changes value if necessary
6483 sub Filter($$$)
6484 13310 ▶{
Subroutine Filter: called CC=12 SCAR=27.9
Pod documented
6485 13310 local $_;
6486 13310 my ($self, $filter, $valPt) = @_;
6487 13310 ▶ return 1 unless defined $filter and defined $$valPt;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $filter and defined $$valPt 12847 463 13310
Condition66%2/3
defined $filter and defined $$valPt
!ll&&!rl&&r
128470463
MC/DC50%1/2
defined $filter and defined $$valPt
defined $filter defined $$valPt
Truth table66%2/3
A and B
A= defined $filterB= defined $$valPt
ABresult
0X0
100
111
6488 463 my $rtnVal;
6489 463 ▶ if (not ref $$valPt) {
Branch: 4 branches
BranchTrueFalseTotal
if (not ref $$valPt) { } 447 16 463
elsif (ref $$valPt eq 'SCALAR') { } 12 4 16
elsif (ref $$valPt eq 'ARRAY') { } 4 0 4
elsif (ref $$valPt eq 'HASH') { } 0 0 0
6490 447 $_ = $$valPt;
6491 #### eval Filter ($_, $self)
6492 447 eval $filter;
6493 447 ▶ if (defined $_) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_) 447 0 447
6494 447 $$valPt = $_;
6495 447 $rtnVal = 1;
6496 }
6497 } elsif (ref $$valPt eq 'SCALAR') {
6498 12 my $val = $$$valPt; # make a copy to avoid filtering twice
6499 12 $rtnVal = $self->Filter($filter, \$val);
6500 12 $$valPt = \$val;
6501 } elsif (ref $$valPt eq 'ARRAY') {
6502 4 my @val = @{$$valPt}; # make a copy to avoid filtering twice
6503 4 ▶ $self->Filter($filter, \$_) and $rtnVal = 1 foreach @val;
Branch: 1 branch
BranchTrueFalseTotal
$self->Filter($filter, \$_) and $rtnVal = 1 9 0 9
6504 4 $$valPt = \@val;
6505 } elsif (ref $$valPt eq 'HASH') {
6506 0 my %val = %{$$valPt}; # make a copy to avoid filtering twice
6507 0 ▶ $self->Filter($filter, \$val{$_}) and $rtnVal = 1 foreach keys %val;
Branch: 1 branch
BranchTrueFalseTotal
$self->Filter($filter, \$val{$_}) and $rtnVal = 1 0 0 0
6508 0 $$valPt = \%val;
6509 } else {
6510 0 $rtnVal = 1;
6511 }
6512 463 return $rtnVal;
6513 }
6514  
6515 #------------------------------------------------------------------------------
6516 # Return printable value
6517 # Inputs: 0) ExifTool object reference
6518 # 1) value to print, 2) line length limit (undef defaults to 60, 0=unlimited)
6519 # Returns: Printable string
6520 sub Printable($;$)
6521 590 ▶{
Subroutine Printable: called CC=10 SCAR=27.5
Pod undocumented
6522 590 my ($self, $outStr, $maxLen) = @_;
6523 590 ▶ return '(undef)' unless defined $outStr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $outStr 0 590 590
6524 590 ▶ ref $outStr eq 'SCALAR' and return '(Binary data '.length($$outStr).' bytes)';
Branch: 1 branch
BranchTrueFalseTotal
ref $outStr eq "SCALAR" and return '(Binary data ' . length($$outStr) . ' bytes)' 0 590 590
6525 590 $outStr =~ tr/\x01-\x1f\x7f-\xff/./;
6526 590 $outStr =~ s/\x00//g;
6527 590 my $verbose = $$self{OPTIONS}{Verbose};
6528 590 ▶ if ($verbose < 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($verbose < 4) { } 590 0 590
6529 590 ▶ if ($maxLen) {
Branch: 2 branches
BranchTrueFalseTotal
if ($maxLen) { } 589 1 590
elsif (defined $maxLen) { } 1 0 1
6530 589 ▶ $maxLen = 20 if $maxLen < 20; # minimum length is 20
Branch: 1 branch
BranchTrueFalseTotal
if $maxLen < 20 0 589 589
6531 } elsif (defined $maxLen) {
6532 1 $maxLen = length $outStr; # 0 is unlimited
6533 } else {
6534 0 $maxLen = 60; # default maximum is 60
6535 }
6536 } else {
6537 0 $maxLen = length $outStr;
6538 # limit to 2048 characters if verbose < 5
6539 0 ▶ $maxLen = 2048 if $maxLen > 2048 and $verbose < 5;
Branch: 1 branch
BranchTrueFalseTotal
if $maxLen > 2048 and $verbose < 5 0 0 0
Condition0%0/3
$maxLen > 2048 and $verbose < 5
!ll&&!rl&&r
000
MC/DC0%0/2
$maxLen > 2048 and $verbose < 5
$maxLen > 2048 $verbose < 5
Truth table0%0/3
A and B
A= $maxLen > 2048B= $verbose < 5
ABresult
0X0
100
111
6540 }
6541  
6542 # limit length if necessary
6543 590 ▶ $outStr = substr($outStr,0,$maxLen-6) . '[snip]' if length($outStr) > $maxLen;
Branch: 1 branch
BranchTrueFalseTotal
if length $outStr > $maxLen 8 582 590
6544 590 return $outStr;
6545 }
6546  
6547 #------------------------------------------------------------------------------
6548 # Convert date/time from Exif format
6549 # Inputs: 0) ExifTool object reference, 1) Date/time in EXIF format
6550 # Returns: Formatted date/time string
6551 sub ConvertDateTime($$)
6552 1846 ▶{
Subroutine ConvertDateTime: called CC=52 SCAR=69.5
Pod undocumented
6553 1846 my ($self, $date) = @_;
6554 1846 my $fmt = $$self{OPTIONS}{DateFormat};
6555 1846 my $shift = $$self{OPTIONS}{GlobalTimeShift};
6556 1846 ▶ if ($shift) {
Branch: 1 branch
BranchTrueFalseTotal
if ($shift) 8 1838 1846
6557 8 my $offset = $$self{GLOBAL_TIME_OFFSET};
6558 8 my ($g, $t, $dir, @matches);
6559 8 ▶ if ($shift =~ s/^((\d?[A-Z][-\w]*\w:)*)([A-Z][-\w]*\w)([-+])//i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($shift =~ s/^((\d?[A-Z][-\w]*\w:)*)([A-Z][-\w]*\w)([-+])//i) { } 0 8 8
6560 0 ▶ ($g, $t, $dir) = ($1, $3, ($4 eq '-' ? -1 : 1));
Branch: 1 branch
BranchTrueFalseTotal
$4 eq '-' ? : 0 0 0
6561 } else {
6562 8 ▶ $dir = ($shift =~ s/^([-+])// and $1 eq '-') ? -1 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$shift =~ s/^([-+])// && $1 eq '-' ? : 8 0 8
Condition33%1/3
$shift =~ s/^([-+])// and $1 eq "-"
!ll&&!rl&&r
008
MC/DC0%0/2
$shift =~ s/^([-+])// and $1 eq "-"
$shift =~ s/^([-+])// $1 eq "-"
Truth table33%1/3
A and B
A= $shift =~ s/^([-+])//B= $1 eq "-"
ABresult
0X0
100
111
6563 }
6564 8 ▶ unless ($offset) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($offset) 1 7 8
6565 1 $offset = $$self{GLOBAL_TIME_OFFSET} = { };
6566 # (see forum16692 for a discussion about why this code was added)
6567 1 ▶ if ($t) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t) 0 1 1
6568 # determine initial shift from specified tag
6569 0 @matches = sort grep(/^$t( \(|$)/i, keys %{$$self{VALUE}});
6570 0 ▶ if ($g and @matches) {
Branch: 1 branch
BranchTrueFalseTotal
if ($g and @matches) 0 0 0
Condition0%0/3
$g and @matches
!ll&&!rl&&r
000
MC/DC0%0/2
$g and @matches
$g @matches
Truth table0%0/3
A and B
A= $gB= @matches
ABresult
0X0
100
111
6571 0 $g =~ s/:$//;
6572 0 @matches = $self->GroupMatches($g, \@matches);
6573 }
6574 }
6575 1 ▶ if (not @matches and $$self{TAGS_FROM_FILE} and $$self{OPTIONS}{RequestTags}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not @matches and $self->{"TAGS_FROM_FILE"} and $self->{"OPTIONS"}{"RequestTags"}) 0 1 1
Condition33%2/6
not @matches and $self->{"TAGS_FROM_FILE"} and $self->{"OPTIONS"}{"RequestTags"}
!ll&&!rl&&r
100
not @matches and $self->{"TAGS_FROM_FILE"}
!ll&&!rl&&r
010
MC/DC0%0/3
not @matches and $self->{"TAGS_FROM_FILE"} and $self->{"OPTIONS"}{"RequestTags"}
not @matches $self->{"TAGS_FROM_FILE"} $self->{"OPTIONS"}{"RequestTags"}
Truth table25%1/4
not(A) and B and C
A= not @matchesB= $self->{"TAGS_FROM_FILE"}C= $self->{"OPTIONS"}{"RequestTags"}
ABCresult
0XX0
10X0
1100
1111
6576 # determine initial shift from first requested date/time tag
6577 0 my @reqDate = grep /date/i, @{$$self{OPTIONS}{RequestTags}};
6578 0 ▶ while (@reqDate) {
Branch: 1 branch
BranchTrueFalseTotal
if (@reqDate) 0 0 0
6579 0 $t = shift @reqDate;
6580 0 @matches = sort grep(/^$t( \(|$)/i, keys %{$$self{VALUE}});
6581 0 my $ti = $$self{TAG_INFO};
6582 0 ▶ for (; @matches; shift @matches) {
Branch: 1 branch
BranchTrueFalseTotal
if (@matches) 0 0 0
6583 # select the first tag that calls this routine in its PrintConv
6584 0 ▶ next unless $$ti{$matches[0]}{PrintConv};
Branch: 1 branch
BranchTrueFalseTotal
unless $$ti{$matches[0]}{"PrintConv"} 0 0 0
6585 0 ▶ next unless $$ti{$matches[0]}{PrintConv} =~ /ConvertDateTime/;
Branch: 1 branch
BranchTrueFalseTotal
unless $$ti{$matches[0]}{"PrintConv"} =~ /ConvertDateTime/ 0 0 0
6586 0 undef @reqDate;
6587 0 last;
6588 }
6589 }
6590 }
6591 1 ▶ if (@matches) {
Branch: 1 branch
BranchTrueFalseTotal
if (@matches) 0 1 1
6592 0 my $val = $self->GetValue($matches[0], 'ValueConv');
6593 0 ▶ ShiftTime($val, $shift, $dir, $offset) if defined $val;
Branch: 1 branch
BranchTrueFalseTotal
if defined $val 0 0 0
6594 }
6595 }
6596 8 ShiftTime($date, $shift, $dir, $offset);
6597 }
6598 # only convert date if a format was specified and the date is recognizable
6599 1846 ▶ if ($fmt) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fmt) 5 1841 1846
6600 # separate time zone if it exists
6601 5 my $tz;
6602 5 ▶ $date =~ s/([-+]\d{2}:\d{2}|Z)$// and $tz = $1;
Branch: 1 branch
BranchTrueFalseTotal
$date =~ s/([-+]\d{2}:\d{2}|Z)$// and $tz = $1 4 1 5
6603 # a few cameras use incorrect date/time formatting:
6604 # - slashes instead of colons in date (RolleiD330, ImpressCam)
6605 # - date/time values separated by colon instead of space (Polariod, Sanyo, Sharp, Vivitar)
6606 # - single-digit seconds with leading space (HP scanners)
6607 5 my @a = reverse ($date =~ /\d+/g); # be very flexible about date/time format
6608 5 ▶ if (@a and $a[-1] >= 1000 and $a[-1] < 3000 and eval { require POSIX }) {
Branch: 2 branches
BranchTrueFalseTotal
if (@a and $a[-1] >= 1000 and $a[-1] < 3000 and eval { do { require POSIX } }) { } 5 0 5
elsif ($self->{'OPTIONS'}{'StrictDate'}) { } 0 0 0
Condition33%3/9
@a and $a[-1] >= 1000 and $a[-1] < 3000 and eval { do { require POSIX } }
!ll&&!rl&&r
005
@a and $a[-1] >= 1000 and $a[-1] < 3000
!ll&&!rl&&r
005
@a and $a[-1] >= 1000
!ll&&!rl&&r
005
MC/DC0%0/4
@a and $a[-1] >= 1000 and $a[-1] < 3000 and eval { do { require POSIX } }
@a $a[-1] >= 1000 $a[-1] < 3000 eval { do { require POSIX } }
Truth table20%1/5
A and B and C and D
A= @aB= $a[-1] >= 1000C= $a[-1] < 3000D= eval { do { require POSIX } }
ABCDresult
0XXX0
10XX0
110X0
11100
11111
6609 5 ▶ shift @a while @a > 6; # remove superfluous entries
Branch: 1 branch
BranchTrueFalseTotal
@a > 6 and do { shift @a } 0 5 5
6610 5 ▶ unshift @a, 1 while @a < 3; # add month and day if necessary
Branch: 1 branch
BranchTrueFalseTotal
@a < 3 and do { unshift @a, 1 } 0 5 5
6611 5 ▶ unshift @a, 0 while @a < 6; # add h,m,s if necessary
Branch: 1 branch
BranchTrueFalseTotal
@a < 6 and do { unshift @a, 0 } 0 5 5
6612 5 $a[4] -= 1; # base month is 1
6613 # parse our %f fractional seconds first (and round up seconds if necessary)
6614 # - if there are multiple %f codes, they all get the same number of digits as the first
6615 5 ▶ if ($fmt =~ /%(-?)\.?(\d*)f/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fmt =~ /%(-?)\.?(\d*)f/) 0 5 5
6616 0 my ($neg, $dig) = ($1, $2);
6617 0 ▶ my $frac = $date =~ /(\.\d+)/ ? $1 : '';
Branch: 1 branch
BranchTrueFalseTotal
$date =~ /(\.\d+)/ ? : 0 0 0
6618 0 ▶ if (not $frac) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $frac) { } 0 0 0
elsif (length $dig) { } 0 0 0
6619 0 ▶ $frac = '.' . ('0' x $dig) if $dig;
Branch: 1 branch
BranchTrueFalseTotal
if $dig 0 0 0
6620 } elsif (length $dig) {
6621 0 ▶ if ($dig+1 > length($frac)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($dig + 1 > length $frac) { } 0 0 0
elsif ($dig + 1 < length $frac) { } 0 0 0
6622 0 $frac .= '0' x ($dig+1-length($frac));
6623 } elsif ($dig+1 < length($frac)) {
6624 0 $frac = sprintf("%.${dig}f", $frac);
6625 0 ▶ while ($frac =~ s/^(\d)// and $1 ne '0') {
Branch: 1 branch
BranchTrueFalseTotal
if ($frac =~ s/^(\d)// and $1 ne 0) 0 0 0
Condition0%0/3
$frac =~ s/^(\d)// and $1 ne 0
!ll&&!rl&&r
000
MC/DC0%0/2
$frac =~ s/^(\d)// and $1 ne 0
$frac =~ s/^(\d)// $1 ne 0
Truth table0%0/3
A and B
A= $frac =~ s/^(\d)//B= $1 ne 0
ABresult
0X0
100
111
6626 # this is a pain, but we must round up to the next second
6627 0 ▶ ++$a[0] < 60 and last;
Branch: 1 branch
BranchTrueFalseTotal
++$a[0] < 60 and last 0 0 0
6628 0 $a[0] = 0;
6629 0 ▶ ++$a[1] < 60 and last;
Branch: 1 branch
BranchTrueFalseTotal
++$a[1] < 60 and last 0 0 0
6630 0 $a[1] = 0;
6631 0 ▶ ++$a[2] < 24 and last;
Branch: 1 branch
BranchTrueFalseTotal
++$a[2] < 24 and last 0 0 0
6632 0 $a[2] = 0;
6633 0 require 'Image/ExifTool/Shift.pl';
6634 0 ▶ ++$a[3] <= DaysInMonth($a[4]+1, $a[5]) and last;
Branch: 1 branch
BranchTrueFalseTotal
++$a[3] <= DaysInMonth($a[4] + 1, $a[5]) and last 0 0 0
6635 0 $a[3] = 1;
6636 0 ▶ ++$a[4] < 12 and last;
Branch: 1 branch
BranchTrueFalseTotal
++$a[4] < 12 and last 0 0 0
6637 0 $a[4] = 0;
6638 0 ++$a[5];
6639 0 last; # (this was a goto)
6640 }
6641 }
6642 }
6643 0 ▶ $neg and $frac =~ s/^\.//;
Branch: 1 branch
BranchTrueFalseTotal
$neg and $frac =~ s/^\.// 0 0 0
6644 0 $fmt =~ s/(^|[^%])((%%)*)%-?\.?\d*f/$1$2$frac/g;
6645 }
6646 # parse %z and %s ourself (to handle time zones properly)
6647 5 ▶ if ($fmt =~ /%:?[sz]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fmt =~ /%:?[sz]/) 0 5 5
6648 # use system time zone unless otherwise specified
6649 0 ▶ $tz = TimeZoneString(\@a, TimeLocal(@a)) if not $tz and eval { require Time::Local };
Branch: 1 branch
BranchTrueFalseTotal
if not $tz and eval { do { require Time::Local } } 0 0 0
Condition0%0/3
not $tz and eval { do { require Time::Local } }
!ll&&!rl&&r
000
MC/DC0%0/2
not $tz and eval { do { require Time::Local } }
not $tz eval { do { require Time::Local } }
Truth table0%0/3
not(A) and B
A= not $tzB= eval { do { require Time::Local } }
ABresult
0X0
100
111
6650 # remove colon, setting to UTC if time zone is not numeric
6651 0 ▶ $tz = '+00:00' unless $tz and $tz=~/^[-+]\d{2}:\d{2}$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $tz and $tz =~ /^[-+]\d{2}:\d{2}$/ 0 0 0
Condition0%0/3
$tz and $tz =~ /^[-+]\d{2}:\d{2}$/
!ll&&!rl&&r
000
MC/DC0%0/2
$tz and $tz =~ /^[-+]\d{2}:\d{2}$/
$tz $tz =~ /^[-+]\d{2}:\d{2}$/
Truth table0%0/3
A and B
A= $tzB= $tz =~ /^[-+]\d{2}:\d{2}$/
ABresult
0X0
100
111
6652 0 $fmt =~ s/(^|[^%])((%%)*)%:z/$1$2$tz/g; # convert '%:z' format codes
6653 0 $tz =~ s/://;
6654 0 $fmt =~ s/(^|[^%])((%%)*)%z/$1$2$tz/g; # convert '%z' format codes
6655 0 ▶ if ($fmt =~ /%s/ and eval { require Time::Local }) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fmt =~ /%s/ and eval { do { require Time::Local } }) 0 0 0
Condition0%0/3
$fmt =~ /%s/ and eval { do { require Time::Local } }
!ll&&!rl&&r
000
MC/DC0%0/2
$fmt =~ /%s/ and eval { do { require Time::Local } }
$fmt =~ /%s/ eval { do { require Time::Local } }
Truth table0%0/3
A and B
A= $fmt =~ /%s/B= eval { do { require Time::Local } }
ABresult
0X0
100
111
6656 # calculate seconds since the Epoch, UTC
6657 0 my $s = Time::Local::timegm(@a) - 60 * ($tz - int($tz/100) * 40);
6658 0 $fmt =~ s/(^|[^%])((%%)*)%s/$1$2$s/g; # convert '%s' format codes
6659 }
6660 }
6661 5 $a[5] -= 1900; # strftime year starts from 1900
6662 5 $date = POSIX::strftime($fmt, @a); # generate the formatted date/time
6663 # apparently strftime can set the UTF-8 flag (argh!), so reset this if necessary
6664 5 ▶ $self->Sanitize(\$date) if $fmt =~ /[\x80-\xff]/;
Branch: 1 branch
BranchTrueFalseTotal
if $fmt =~ /[\x80-\xff]/ 0 5 5
6665 } elsif ($$self{OPTIONS}{StrictDate}) {
6666 0 undef $date;
6667 }
6668 }
6669 1846 return $date;
6670 }
6671  
6672 #------------------------------------------------------------------------------
6673 # Print conversion for time span value
6674 # Inputs: 0) time ticks, 1) number of seconds per tick (default 1)
6675 # Returns: readable time
6676 sub ConvertTimeSpan($;$)
6677 3 ▶{
Subroutine ConvertTimeSpan: called CC=11 SCAR=27.9
Pod undocumented
6678 3 my ($val, $mult) = @_;
6679 3 ▶ if (Image::ExifTool::IsFloat($val) and $val != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (&IsFloat($val) and $val != 0) 3 0 3
Condition33%1/3
&IsFloat($val) and $val != 0
!ll&&!rl&&r
003
MC/DC0%0/2
&IsFloat($val) and $val != 0
&IsFloat($val) $val != 0
Truth table33%1/3
A and B
A= &IsFloat($val)B= $val != 0
ABresult
0X0
100
111
6680 3 ▶ $val *= $mult if $mult;
Branch: 1 branch
BranchTrueFalseTotal
if $mult 2 1 3
6681 3 ▶ if ($val < 60) {
Branch: 3 branches
BranchTrueFalseTotal
if ($val < 60) { } 0 3 3
elsif ($val < 3600) { } 3 0 3
elsif ($val < 86400) { } 0 0 0
6682 0 $val = "$val seconds";
6683 } elsif ($val < 3600) {
6684 3 ▶ my $fmt = ($mult and $mult >= 60) ? '%d' : '%.1f';
Branch: 1 branch
BranchTrueFalseTotal
$mult && $mult >= 60 ? : 2 1 3
Condition66%2/3
$mult and $mult >= 60
!ll&&!rl&&r
102
MC/DC50%1/2
$mult and $mult >= 60
$mult $mult >= 60
Truth table66%2/3
A and B
A= $multB= $mult >= 60
ABresult
0X0
100
111
6685 3 ▶ my $s = ($val == 60 and $mult) ? '' : 's';
Branch: 1 branch
BranchTrueFalseTotal
$val == 60 && $mult ? : 1 2 3
Condition66%2/3
$val == 60 and $mult
!ll&&!rl&&r
201
MC/DC50%1/2
$val == 60 and $mult
$val == 60 $mult
Truth table66%2/3
A and B
A= $val == 60B= $mult
ABresult
0X0
100
111
6686 3 $val = sprintf("$fmt minute$s", $val / 60);
6687 } elsif ($val < 24 * 3600) {
6688 0 $val = sprintf("%.1f hours", $val / 3600);
6689 } else {
6690 0 $val = sprintf("%.1f days", $val / (24 * 3600));
6691 }
6692 }
6693 3 return $val;
6694 }
6695  
6696 #------------------------------------------------------------------------------
6697 # Patched timelocal() that fixes ActivePerl timezone bug
6698 # Inputs/Returns: same as timelocal()
6699 # Notes: must 'require Time::Local' before calling this routine.
6700 # Also note that year should be full year, and not relative to 1900 as with localtime
6701 sub TimeLocal(@)
6702 36 ▶{
Subroutine TimeLocal: called CC=2 SCAR=9.9
Pod undocumented
6703 36 my $tm = Time::Local::timelocal(@_);
6704 36 ▶ if ($^O eq 'MSWin32') {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq "MSWin32") 0 36 36
6705 # patch for ActivePerl timezone bug
6706 0 my @t2 = localtime($tm);
6707 0 $t2[5] += 1900;
6708 0 my $t2 = Time::Local::timelocal(@t2);
6709 # adjust timelocal() return value to be consistent with localtime()
6710 0 $tm += $tm - $t2;
6711 }
6712 36 return $tm;
6713 }
6714  
6715 #------------------------------------------------------------------------------
6716 # Get time zone in minutes
6717 # Inputs: 0) localtime array ref, 1) gmtime array ref
6718 # Returns: time zone offset in minutes
6719 sub GetTimeZone($$)
6720 967 ▶{
Subroutine GetTimeZone: called CC=6 SCAR=25.9
Pod undocumented
6721 967 my ($tm, $gm) = @_;
6722 # compute the number of minutes between localtime and gmtime
6723 967 my $min = $$tm[2] * 60 + $$tm[1] - ($$gm[2] * 60 + $$gm[1]);
6724 967 ▶ if ($$tm[3] != $$gm[3]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tm->[3] != $gm->[3]) 0 967 967
6725 # account for case where one date wraps to the first of the next month
6726 0 ▶ $$gm[3] = $$tm[3] - ($$tm[3]==1 ? 1 : -1) if abs($$tm[3]-$$gm[3]) != 1;
Branch: 2 branches
BranchTrueFalseTotal
if abs $tm->[3] - $gm->[3] != 1 0 0 0
$tm->[3] == 1 ? : 0 0 0
6727 # adjust for the +/- one day difference
6728 0 $min += ($$tm[3] - $$gm[3]) * 24 * 60;
6729 }
6730 # MirBSD patch to round to the nearest 30 minutes because
6731 # it includes leap seconds in localtime but not gmtime
6732 967 ▶ $min = int($min / 30 + ($min > 0 ? 0.5 : -0.5)) * 30 if $^O eq 'mirbsd';
Branch: 2 branches
BranchTrueFalseTotal
if $^O eq "mirbsd" 0 967 967
$min > 0 ? : 0 0 0
6733 967 return $min;
6734 }
6735  
6736 #------------------------------------------------------------------------------
6737 # Get time zone string
6738 # Inputs: 0) time zone offset in minutes
6739 # or 0) localtime array ref, 1) corresponding time value
6740 # Returns: time zone string ("+/-HH:MM")
6741 sub TimeZoneString($;$)
6742 1008 ▶{
Subroutine TimeZoneString: called CC=3 SCAR=11.0
Pod undocumented
6743 1008 my $min = shift;
6744 1008 ▶ if (ref $min) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $min) 967 41 1008
6745 967 my @gm = gmtime(shift);
6746 967 $min = GetTimeZone($min, \@gm);
6747 }
6748 1008 my $sign = '+';
6749 1008 ▶ $min < 0 and $sign = '-', $min = -$min;
Branch: 1 branch
BranchTrueFalseTotal
$min < 0 and $sign = "-", $min = -$min 1 1007 1008
6750 1008 $min = int($min + 0.5); # round off to nearest minute
6751 1008 my $h = int($min / 60);
6752 1008 return sprintf('%s%.2d:%.2d', $sign, $h, $min - $h * 60);
6753 }
6754  
6755 #------------------------------------------------------------------------------
6756 # Convert Unix time to EXIF date/time string
6757 # Inputs: 0) Unix time value, 1) non-zero to convert to local time, 2) number of
6758 # digits after the decimal for fractional seconds, negative to trim
6759 # trailing zeros, or undef to use SystemTimeRes
6760 # Returns: EXIF date/time string (with timezone for local times)
6761 sub ConvertUnixTime($;$$)
6762 1070 ▶{
Subroutine ConvertUnixTime: called CC=11 SCAR=24.3
Pod undocumented
6763 1070 my ($time, $toLocal, $dec) = @_;
6764 1070 ▶ return '0000:00:00 00:00:00' if $time == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $time == 0 1 1069 1070
6765 1069 my (@tm, $tz, $trim);
6766 1069 ▶ $dec = $static_vars{SystemTimeRes} || 0 unless defined $dec;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $dec 1057 12 1069
Condition50%1/2
$Image::ExifTool::static_vars{'SystemTimeRes'} || 0
l!l
01057
MC/DC0%0/1
$Image::ExifTool::static_vars{'SystemTimeRes'} || 0
$Image::ExifTool::static_vars{'SystemTimeRes'}
Truth table50%1/2
A
A= $Image::ExifTool::static_vars{'SystemTimeRes'}
Aresult
11
00
6767 1069 ▶ $dec < 0 and $dec = -$dec, $trim = 1;
Branch: 1 branch
BranchTrueFalseTotal
$dec < 0 and $dec = -$dec, $trim = 1 1 1068 1069
6768 1069 my $itime = int($time);
6769 1069 my $frac = $time - $itime;
6770 1069 ▶ $frac < 0 and $frac += 1, $itime -= 1;
Branch: 1 branch
BranchTrueFalseTotal
$frac < 0 and $frac += 1, $itime -= 1 0 1069 1069
6771 1069 $dec = sprintf('%.*f', $dec, $frac);
6772 # remove number before decimal and increment integer time if necessary
6773 1069 ▶ $dec =~ s/^(\d)// and $1 eq '1' and $itime += 1;
Branch: 1 branch
BranchTrueFalseTotal
$dec =~ s/^(\d)// and $1 eq 1 and $itime += 1 7 1062 1069
Condition66%2/3
$dec =~ s/^(\d)// and $1 eq 1
!ll&&!rl&&r
010627
MC/DC50%1/2
$dec =~ s/^(\d)// and $1 eq 1
$dec =~ s/^(\d)// $1 eq 1
Truth table66%2/3
A and B
A= $dec =~ s/^(\d)//B= $1 eq 1
ABresult
0X0
100
111
6774 1069 ▶ $dec =~ s/\.?0+$// if $trim; # trim trailing zeros if specified
Branch: 1 branch
BranchTrueFalseTotal
if $trim 1 1068 1069
6775 1069 ▶ if (not $toLocal) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $toLocal) { } 164 905 1069
elsif ($Image::ExifTool::static_vars{'KeepUTCTime'}) { } 0 905 905
6776 164 @tm = gmtime($itime);
6777 164 $tz = '';
6778 } elsif ($static_vars{KeepUTCTime}) {
6779 0 @tm = gmtime($itime);
6780 0 $tz = 'Z';
6781 } else {
6782 905 @tm = localtime($itime);
6783 905 $tz = TimeZoneString(\@tm, $itime);
6784 }
6785 1069 my $str = sprintf("%4d:%.2d:%.2d %.2d:%.2d:%.2d$dec%s",
6786 $tm[5]+1900, $tm[4]+1, $tm[3], $tm[2], $tm[1], $tm[0], $tz);
6787 1069 return $str;
6788 }
6789  
6790 #------------------------------------------------------------------------------
6791 # Get Unix time from EXIF-formatted date/time string with optional timezone
6792 # Inputs: 0) EXIF date/time string, 1) non-zero if time is local, or 2 to assume UTC
6793 # Returns: Unix time (seconds since 0:00 GMT Jan 1, 1970) or undefined on error
6794 sub GetUnixTime($;$)
6795 176 ▶{
Subroutine GetUnixTime: called CC=12 SCAR=26.4
Pod undocumented
6796 176 my ($timeStr, $isLocal) = @_;
6797 176 ▶ return 0 if $timeStr eq '0000:00:00 00:00:00';
Branch: 1 branch
BranchTrueFalseTotal
if $timeStr eq "0000:00:00 00:00:00" 0 176 176
6798 176 my @tm = ($timeStr =~ /^(\d+)[-:](\d+)[-:](\d+)\s+(\d+):(\d+):(\d+)(.*)/);
6799 176 ▶ return undef unless @tm == 7;
Branch: 1 branch
BranchTrueFalseTotal
unless @tm == 7 0 176 176
6800 176 ▶ unless (eval { require Time::Local }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (eval { do { require Time::Local } }) 0 176 176
6801 0 warn "Time::Local is not installed\n";
6802 0 return undef;
6803 }
6804 176 my ($tzStr, $tzSec) = (pop(@tm), 0);
6805 # use specified timezone offset (if given) instead of local system time
6806 # if we are converting a local time value
6807 176 ▶ if ($isLocal) {
Branch: 1 branch
BranchTrueFalseTotal
if ($isLocal) 127 49 176
6808 127 ▶ if ($tzStr =~ /(?:Z|([-+])(\d+):(\d+))/i) {
Branch: 2 branches
BranchTrueFalseTotal
if ($tzStr =~ /(?:Z|([-+])(\d+):(\d+))/i) { } 127 0 127
elsif ($isLocal eq '2') { } 0 0 0
6809 # use specified timezone if one exists
6810 127 ▶ $tzSec = ($2 * 60 + $3) * ($1 eq '-' ? -60 : 60) if $1;
Branch: 2 branches
BranchTrueFalseTotal
if $1 121 6 127
$1 eq '-' ? : 62 59 121
6811 127 undef $isLocal; # convert using GMT corrected for specified timezone
6812 } elsif ($isLocal eq '2') {
6813 0 undef $isLocal;
6814 }
6815 }
6816 176 $tm[1] -= 1; # convert month
6817 176 @tm = reverse @tm; # change to order required by timelocal()
6818 176 ▶ my $val = $isLocal ? TimeLocal(@tm) : Time::Local::timegm(@tm) - $tzSec;
Branch: 1 branch
BranchTrueFalseTotal
$isLocal ? : 0 176 176
6819 # handle fractional seconds
6820 174 ▶ $val += $1 if $tzStr and $tzStr =~ /^(\.\d+)/;
Branch: 1 branch
BranchTrueFalseTotal
if $tzStr and $tzStr =~ /^(\.\d+)/ 5 169 174
Condition100%3/3
$tzStr and $tzStr =~ /^(\.\d+)/
!ll&&!rl&&r
471225
MC/DC100%2/2
$tzStr and $tzStr =~ /^(\.\d+)/
$tzStr $tzStr =~ /^(\.\d+)/
Truth table100%3/3
A and B
A= $tzStrB= $tzStr =~ /^(\.\d+)/
ABresult
0X0
100
111
6821 174 return $val;
6822 }
6823  
6824 #------------------------------------------------------------------------------
6825 # Print conversion for file size
6826 # Inputs: 0) file size in bytes, 1) optional ExifTool ref
6827 # Returns: converted file size
6828 sub ConvertFileSize($;$)
6829 313 ▶{
Subroutine ConvertFileSize: called CC=15 SCAR=40.7
Pod undocumented
6830 313 my ($val, $et) = @_;
6831 313 ▶ if ($et and $$et{OPTIONS}{ByteUnit} eq 'Binary') {
Branch: 1 branch
BranchTrueFalseTotal
if ($et and $et->{'OPTIONS'}{'ByteUnit'} eq 'Binary') { } 0 313 313
Condition66%2/3
$et and $et->{"OPTIONS"}{"ByteUnit"} eq "Binary"
!ll&&!rl&&r
43090
MC/DC0%0/2
$et and $et->{"OPTIONS"}{"ByteUnit"} eq "Binary"
$et $et->{"OPTIONS"}{"ByteUnit"} eq "Binary"
Truth table66%2/3
A and B
A= $etB= $et->{"OPTIONS"}{"ByteUnit"} eq "Binary"
ABresult
0X0
100
111
6832 0 ▶ $val < 2048 and return "$val bytes";
Branch: 1 branch
BranchTrueFalseTotal
$val < 2048 and return "$val bytes" 0 0 0
6833 0 ▶ $val < 10240 and return sprintf('%.1f KiB', $val / 1024);
Branch: 1 branch
BranchTrueFalseTotal
$val < 10240 and return sprintf("%.1f KiB", $val / 1024) 0 0 0
6834 0 ▶ $val < 2097152 and return sprintf('%.0f KiB', $val / 1024);
Branch: 1 branch
BranchTrueFalseTotal
$val < 2097152 and return sprintf("%.0f KiB", $val / 1024) 0 0 0
6835 0 ▶ $val < 10485760 and return sprintf('%.1f MiB', $val / 1048576);
Branch: 1 branch
BranchTrueFalseTotal
$val < 10485760 and return sprintf("%.1f MiB", $val / 1048576) 0 0 0
6836 0 ▶ $val < 2147483648 and return sprintf('%.0f MiB', $val / 1048576);
Branch: 1 branch
BranchTrueFalseTotal
$val < 2147483648 and return sprintf("%.0f MiB", $val / 1048576) 0 0 0
6837 0 ▶ $val < 10737418240 and return sprintf('%.1f GiB', $val / 1073741824);
Branch: 1 branch
BranchTrueFalseTotal
$val < '10737418240' and return sprintf("%.1f GiB", $val / 1073741824) 0 0 0
6838 0 return sprintf('%.0f GiB', $val / 1073741824);
6839 } else {
6840 313 ▶ $val < 2000 and return "$val bytes";
Branch: 1 branch
BranchTrueFalseTotal
$val < 2000 and return "$val bytes" 111 202 313
6841 202 ▶ $val < 10000 and return sprintf('%.1f kB', $val / 1000);
Branch: 1 branch
BranchTrueFalseTotal
$val < 10000 and return sprintf("%.1f kB", $val / 1000) 150 52 202
6842 52 ▶ $val < 2000000 and return sprintf('%.0f kB', $val / 1000);
Branch: 1 branch
BranchTrueFalseTotal
$val < 2000000 and return sprintf("%.0f kB", $val / 1000) 48 4 52
6843 4 ▶ $val < 10000000 and return sprintf('%.1f MB', $val / 1000000);
Branch: 1 branch
BranchTrueFalseTotal
$val < 10000000 and return sprintf("%.1f MB", $val / 1000000) 3 1 4
6844 1 ▶ $val < 2000000000 and return sprintf('%.0f MB', $val / 1000000);
Branch: 1 branch
BranchTrueFalseTotal
$val < 2000000000 and return sprintf("%.0f MB", $val / 1000000) 1 0 1
6845 0 ▶ $val < 10000000000 and return sprintf('%.1f GB', $val / 1000000000);
Branch: 1 branch
BranchTrueFalseTotal
$val < '10000000000' and return sprintf("%.1f GB", $val / 1000000000) 0 0 0
6846 0 return sprintf('%.0f GB', $val / 1000000000);
6847 }
6848 }
6849  
6850 #------------------------------------------------------------------------------
6851 # Convert seconds to duration string (handles negative durations)
6852 # Inputs: 0) floating point seconds
6853 # Returns: duration string in form "S.SS s", "H:MM:SS" or "DD days HH:MM:SS"
6854 sub ConvertDuration($)
6855 130 ▶{
Subroutine ConvertDuration: called CC=6 SCAR=18.7
Pod undocumented
6856 130 my $time = shift;
6857 130 ▶ return $time unless IsFloat($time);
Branch: 1 branch
BranchTrueFalseTotal
unless &IsFloat($time) 0 130 130
6858 130 ▶ return '0 s' if $time == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $time == 0 69 61 130
6859 61 ▶ my $sign = ($time > 0 ? '' : (($time = -$time), '-'));
Branch: 1 branch
BranchTrueFalseTotal
$time > 0 ? : 61 0 61
6860 61 ▶ return sprintf("$sign%.2f s", $time) if $time < 30;
Branch: 1 branch
BranchTrueFalseTotal
if $time < 30 57 4 61
6861 4 $time += 0.5; # to round off to nearest second
6862 4 my $h = int($time / 3600);
6863 4 $time -= $h * 3600;
6864 4 my $m = int($time / 60);
6865 4 $time -= $m * 60;
6866 4 ▶ if ($h > 24) {
Branch: 1 branch
BranchTrueFalseTotal
if ($h > 24) 0 4 4
6867 0 my $d = int($h / 24);
6868 0 $h -= $d * 24;
6869 0 $sign = "$sign$d days ";
6870 }
6871 4 return sprintf("$sign%d:%.2d:%.2d", $h, $m, int($time));
6872 }
6873  
6874 #------------------------------------------------------------------------------
6875 # Print conversion for bitrate values
6876 # Inputs: 0) bitrate in bits per second
6877 # Returns: human-readable bitrate string
6878 # Notes: returns input value without formatting if it isn't numerical
6879 sub ConvertBitrate($)
6880 20 ▶{
Subroutine ConvertBitrate: called CC=5 SCAR=16.2
Pod undocumented
6881 20 my $bitrate = shift;
6882 20 ▶ IsFloat($bitrate) or return $bitrate;
Branch: 1 branch
BranchTrueFalseTotal
&IsFloat($bitrate) or return $bitrate 20 0 20
6883 20 my @units = ('bps', 'kbps', 'Mbps', 'Gbps');
6884 20 for (;;) {
6885 38 my $units = shift @units;
6886 38 ▶ $bitrate >= 1000 and @units and $bitrate /= 1000, next;
Branch: 1 branch
BranchTrueFalseTotal
$bitrate >= 1000 and @units and $bitrate /= 1000, next 18 20 38
Condition66%2/3
$bitrate >= 1000 and @units
!ll&&!rl&&r
20018
MC/DC50%1/2
$bitrate >= 1000 and @units
$bitrate >= 1000 @units
Truth table66%2/3
A and B
A= $bitrate >= 1000B= @units
ABresult
0X0
100
111
6887 20 ▶ my $fmt = $bitrate < 100 ? '%.3g' : '%.0f';
Branch: 1 branch
BranchTrueFalseTotal
$bitrate < 100 ? : 13 7 20
6888 20 return sprintf("$fmt $units", $bitrate);
6889 }
6890 }
6891  
6892 #------------------------------------------------------------------------------
6893 # Convert file name for printing
6894 # Inputs: 0) ExifTool ref, 1) file name in CharsetFileName character set
6895 # Returns: converted file name in external character set
6896 sub ConvertFileName($$)
6897 1010 ▶{
Subroutine ConvertFileName: called CC=2 SCAR=7.0
Pod undocumented
6898 1010 my ($self, $val) = @_;
6899 1010 my $enc = $$self{OPTIONS}{CharsetFileName};
6900 1010 ▶ $val = $self->Decode($val, $enc) if $enc;
Branch: 1 branch
BranchTrueFalseTotal
if $enc 0 1010 1010
6901 1010 return $val;
6902 }
6903  
6904 #------------------------------------------------------------------------------
6905 # Inverse conversion for file name (encode in CharsetFileName)
6906 # Inputs: 0) ExifTool ref, 1) file name in external character set
6907 # Returns: file name in CharsetFileName character set
6908 sub InverseFileName($$)
6909 1 ▶{
Subroutine InverseFileName: called CC=2 SCAR=7.0
Pod undocumented
6910 1 my ($self, $val) = @_;
6911 1 my $enc = $$self{OPTIONS}{CharsetFileName};
6912 1 ▶ $val = $self->Encode($val, $enc) if $enc;
Branch: 1 branch
BranchTrueFalseTotal
if $enc 0 1 1
6913 1 $val =~ tr/\\/\//; # make sure we are using forward slashes
6914 1 return $val;
6915 }
6916  
6917 #------------------------------------------------------------------------------
6918 # Limit length of long values (to be used in PrintConv)
6919 # Inputs: 0) string value, 1) ExifTool ref
6920 # Returns: length-limited value
6921 sub LimitLongValues($$)
6922 416 ▶{
Subroutine LimitLongValues: called CC=3 SCAR=11.0
Pod documented
6923 416 my ($str, $self) = @_;
6924 416 my $lim = $$self{OPTIONS}{LimitLongValues};
6925 416 ▶ if (length($str) > $lim and $lim >= 5) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $str > $lim and $lim >= 5) 48 368 416
Condition66%2/3
length $str > $lim and $lim >= 5
!ll&&!rl&&r
368048
MC/DC50%1/2
length $str > $lim and $lim >= 5
length $str > $lim $lim >= 5
Truth table66%2/3
A and B
A= length $str > $limB= $lim >= 5
ABresult
0X0
100
111
6926 48 $str = substr($str,0,$lim-5) . "[...]";
6927 }
6928 416 return $str;
6929 }
6930  
6931 #------------------------------------------------------------------------------
6932 # Save information for HTML dump
6933 # Inputs: 0) ExifTool hash ref, 1) start offset, 2) data size
6934 # 3) comment string, 4) tool tip (or SAME), 5) flags, 6) IFD name
6935 sub HDump($$$$;$$$)
6936 0 ▶{
Subroutine HDump: not called CC=8 SCAR=42.8
Pod undocumented
6937 0 my $self = shift;
6938 0 ▶ $$self{HTML_DUMP} or return;
Branch: 1 branch
BranchTrueFalseTotal
$self->{"HTML_DUMP"} or return 0 0 0
6939 0 my ($pos, $len, $com, $tip, $flg, $ifd) = @_;
6940 0 ▶ $pos += $$self{BASE} if $$self{BASE};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"BASE"} 0 0 0
6941 # skip structural data blocks which have been removed from the middle of this dump
6942 # (SkipData list contains ordered [start,end+1] offsets to skip)
6943 0 ▶ if ($$self{SkipData}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"SkipData"}) 0 0 0
6944 0 my $end = $pos + $len;
6945 0 my $skip;
6946 0 foreach $skip (@{$$self{SkipData}}) {
6947 0 ▶ $end <= $$skip[0] and last;
Branch: 1 branch
BranchTrueFalseTotal
$end <= $skip->[0] and last 0 0 0
6948 0 ▶ $pos >= $$skip[1] and $pos += $$skip[1] - $$skip[0], next;
Branch: 1 branch
BranchTrueFalseTotal
$pos >= $skip->[1] and $pos += $skip->[1] - $skip->[0], next 0 0 0
6949 0 ▶ if ($pos != $$skip[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pos != $skip->[0]) 0 0 0
6950 0 $$self{HTML_DUMP}->Add($pos, $$skip[0]-$pos, $com, $tip, $flg, $ifd);
6951 0 $len -= $$skip[0] - $pos;
6952 0 $tip = 'SAME';
6953 }
6954 0 $pos = $$skip[1];
6955 }
6956 }
6957 0 $$self{HTML_DUMP}->Add($pos, $len, $com, $tip, $flg, $ifd);
6958 }
6959  
6960 #------------------------------------------------------------------------------
6961 # Identify trailer ending at specified offset from end of file
6962 # Inputs: 0) RAF reference, 1) offset from end of file (0 by default)
6963 # Returns: Trailer info hash (with RAF and DirName set),
6964 # or undef if no recognized trailer was found
6965 # Notes: leaves file position unchanged
6966 sub IdentifyTrailer($$;$)
6967 585 ▶{
Subroutine IdentifyTrailer: called CC=20 SCAR=31.9
Pod undocumented
6968 585 my ($self, $raf, $offset) = @_;
6969 585 ▶ $offset or $offset = 0;
Branch: 1 branch
BranchTrueFalseTotal
$offset or $offset = 0 182 403 585
6970 585 my $pos = $raf->Tell();
6971 585 my ($buff, $type, $len);
6972 585 ▶ while ($raf->Seek(-$offset, 2) and ($len = $raf->Tell()) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($raf->Seek(-$offset, 2) and ($len = $raf->Tell) > 0) 585 0 585
Condition33%1/3
$raf->Seek(-$offset, 2) and ($len = $raf->Tell) > 0
!ll&&!rl&&r
00585
MC/DC0%0/2
$raf->Seek(-$offset, 2) and ($len = $raf->Tell) > 0
$raf->Seek(-$offset, 2) ($len = $raf->Tell) > 0
Truth table33%1/3
A and B
A= $raf->Seek(-$offset, 2)B= ($len = $raf->Tell) > 0
ABresult
0X0
100
111
6973 # read up to 64 bytes before specified offset from end of file
6974 585 ▶ $len = 64 if $len > 64;
Branch: 1 branch
BranchTrueFalseTotal
if $len > 64 585 0 585
6975 585 ▶ $raf->Seek(-$len, 1) and $raf->Read($buff, $len) == $len or last;
Branch: 1 branch
BranchTrueFalseTotal
$raf->Seek(-$len, 1) and $raf->Read($buff, $len) == $len or last 585 0 585
Condition33%1/3
$raf->Seek(-$len, 1) and $raf->Read($buff, $len) == $len
!ll&&!rl&&r
00585
MC/DC0%0/2
$raf->Seek(-$len, 1) and $raf->Read($buff, $len) == $len
$raf->Seek(-$len, 1) $raf->Read($buff, $len) == $len
Truth table33%1/3
A and B
A= $raf->Seek(-$len, 1)B= $raf->Read($buff, $len) == $len
ABresult
0X0
100
111
6976 585 ▶ if ($buff =~ /AXS(!|\*).{8}$/s) {
Branch: 11 branches
BranchTrueFalseTotal
if ($buff =~ /AXS(!|\*).{8}$/s) { } 29 556 585
elsif ($buff =~ /\xa1\xb2\xc3\xd4$/) { } 29 527 556
elsif ($buff =~ /cbipcbbl$/) { } 34 493 527
elsif ($buff =~ /^CANON OPTIONAL DATA\0/) { } 41 452 493
elsif ($buff =~ /~\0\x04\0zmie~\0\0\x06.{4}[\x10\x18]\x04$/s or $buff =~ /~\0\x04\0zmie~\0\0\x0a.{8}[\x10\x18]\x08$/s) { } 26 426 452
elsif ($buff =~ /\0\0(QDIOBS|SEFT)$/) { } 26 400 426
elsif ($buff =~ /8db42d694ccc418790edff439fe026bf$/s) { } 0 400 400
elsif ($buff =~ m[\0{6}/NIKON APP$]) { } 0 400 400
elsif ($buff =~ /\xff{4}\x1b\*9HWfu\x84\x93\xa2\xb1$/) { } 26 374 400
elsif ($buff =~ /jxrs...\0$/s) { } 0 374 374
elsif ($self->{'ProcessGoogleTrailer'}) { } 1 373 374
6977 29 $type = 'AFCP';
6978 } elsif ($buff =~ /\xa1\xb2\xc3\xd4$/) {
6979 29 $type = 'FotoStation';
6980 } elsif ($buff =~ /cbipcbbl$/) {
6981 34 $type = 'PhotoMechanic';
6982 } elsif ($buff =~ /^CANON OPTIONAL DATA\0/) {
6983 41 $type = 'CanonVRD';
6984 ▶ } elsif ($buff =~ /~\0\x04\0zmie~\0\0\x06.{4}[\x10\x18]\x04$/s or
Condition66%2/3
$buff =~ /~\0\x04\0zmie~\0\0\x06.{4}[\x10\x18]\x04$/s or $buff =~ /~\0\x04\0zmie~\0\0\x0a.{8}[\x10\x18]\x08$/s
l!l&&r!l&&!r
260426
MC/DC50%1/2
$buff =~ /~\0\x04\0zmie~\0\0\x06.{4}[\x10\x18]\x04$/s or $buff =~ /~\0\x04\0zmie~\0\0\x0a.{8}[\x10\x18]\x08$/s
$buff =~ /~\0\x04\0zmie~\0\0\x06.{4}[\x10\x18]\x04$/s $buff =~ /~\0\x04\0zmie~\0\0\x0a.{8}[\x10\x18]\x08$/s
Truth table66%2/3
A or B
A= $buff =~ /~\0\x04\0zmie~\0\0\x06.{4}[\x10\x18]\x04$/sB= $buff =~ /~\0\x04\0zmie~\0\0\x0a.{8}[\x10\x18]\x08$/s
ABresult
1X1
011
000
6985 $buff =~ /~\0\x04\0zmie~\0\0\x0a.{8}[\x10\x18]\x08$/s)
6986 {
6987 26 $type = 'MIE';
6988 } elsif ($buff =~ /\0\0(QDIOBS|SEFT)$/) {
6989 26 $type = 'Samsung';
6990 } elsif ($buff =~ /8db42d694ccc418790edff439fe026bf$/s) {
6991 0 $type = 'Insta360';
6992 } elsif ($buff =~ m(\0{6}/NIKON APP$)) {
6993 0 $type = 'NikonApp';
6994 } elsif ($buff =~ /\xff{4}\x1b\*9HWfu\x84\x93\xa2\xb1$/) {
6995 26 $type = 'Vivo';
6996 } elsif ($buff =~ /jxrs...\0$/s) {
6997 0 $type = 'OnePlus';
6998 } elsif ($$self{ProcessGoogleTrailer}) {
6999 # check for Google trailer information if specific XMP tags exist
7000 1 $type = 'Google';
7001 }
7002 585 last;
7003 }
7004 585 $raf->Seek($pos, 0); # restore original file position
7005 585 ▶ return $type ? { RAF => $raf, DirName => $type } : undef;
Branch: 1 branch
BranchTrueFalseTotal
$type ? : 212 373 585
7006 }
7007  
7008 #------------------------------------------------------------------------------
7009 # Read/rewrite trailer information (including multiple trailers)
7010 # Inputs: 0) ExifTool object ref, 1) DirInfo ref:
7011 # - requires RAF and DirName
7012 # - OutFile is a scalar reference for writing
7013 # - scans from current file position for each trailer if ScanForTrailer is set
7014 # (current file position is just after JPEG EOF for a JPEG image)
7015 # Returns: 1 if trailer was processed or couldn't be processed (or written OK)
7016 # 0 if trailer was recognized but offsets need fixing (or write error)
7017 # - DirName, DirLen, DataPos, Offset, Fixup and OutFile are updated
7018 # - preserves current file position and byte order
7019 sub ProcessTrailers($$)
7020 78 ▶{
Subroutine ProcessTrailers: called CC=31 SCAR=36.4
Pod undocumented
7021 78 my ($self, $dirInfo) = @_;
7022 78 my $dirName = $$dirInfo{DirName};
7023 78 my $outfile = $$dirInfo{OutFile};
7024 78 ▶ my $offset = $$dirInfo{Offset} || 0;
Condition50%1/2
$dirInfo->{'Offset'} || 0
l!l
078
MC/DC0%0/1
$dirInfo->{'Offset'} || 0
$dirInfo->{'Offset'}
Truth table50%1/2
A
A= $dirInfo->{'Offset'}
Aresult
11
00
7025 78 my $fixup = $$dirInfo{Fixup};
7026 78 my $raf = $$dirInfo{RAF};
7027 78 my $pos = $raf->Tell();
7028 78 my $byteOrder = GetByteOrder();
7029 78 my $success = 1;
7030 78 my $path = $$self{PATH};
7031  
7032 # get position of end of file
7033 78 $raf->Seek(0,2);
7034 78 $$self{FileEnd} = $raf->Tell();
7035  
7036 78 for (;;) { # loop through all trailers
7037 232 $raf->Seek($pos);
7038 232 my ($proc, $outBuff);
7039 # trailer-processing procs residing in modules of a different name
7040 my $module = {
7041 Insta360 => 'QuickTimeStream.pl',
7042 NikonApp => 'Nikon.pm',
7043 Vivo => 'Trailer.pm',
7044 OnePlus => 'Trailer.pm',
7045 Google => 'Trailer.pm',
7046 232 ▶ }->{$dirName} || "$dirName.pm";
Condition100%2/2
{'Insta360', 'QuickTimeStream.pl', 'NikonApp', 'Nikon.pm', 'Vivo', 'Trailer.pm', 'OnePlus', 'Trailer.pm', 'Google', 'Trailer.pm'}->{$dirName} || "$dirName.pm"
l!l
47185
MC/DC100%1/1
{'Insta360', 'QuickTimeStream.pl', 'NikonApp', 'Nikon.pm', 'Vivo', 'Trailer.pm', 'OnePlus', 'Trailer.pm', 'Google', 'Trailer.pm'}->{$dirName} || "$dirName.pm"
{'Insta360', 'QuickTimeStream.pl', 'NikonApp', 'Nikon.pm', 'Vivo', 'Trailer.pm', 'OnePlus', 'Trailer.pm', 'Google', 'Trailer.pm'}->{$dirName}
Truth table100%2/2
A
A= {'Insta360', 'QuickTimeStream.pl', 'NikonApp', 'Nikon.pm', 'Vivo', 'Trailer.pm', 'OnePlus', 'Trailer.pm', 'Google', 'Trailer.pm'}->{$dirName}
Aresult
11
00
7047 232 require "Image/ExifTool/$module";
7048 232 $module =~ s/(Stream)?\..*//; # remove extension and change QuickTimeStream to QuickTime
7049 232 $proc = "Image::ExifTool::${module}::Process$dirName";
7050 232 ▶ if ($outfile) {
Branch: 1 branch
BranchTrueFalseTotal
if ($outfile) 57 175 232
7051 # write to local buffer so we can add trailer in proper order later
7052 57 ▶ $$outfile and $$dirInfo{OutFile} = \$outBuff, $outBuff = '';
Branch: 1 branch
BranchTrueFalseTotal
$$outfile and $dirInfo->{"OutFile"} = \$outBuff, $outBuff = "" 42 15 57
7053 # must generate new fixup if necessary so we can shift
7054 # the old fixup separately after we prepend this trailer
7055 57 delete $$dirInfo{Fixup};
7056 }
7057 232 delete $$dirInfo{DirLen}; # reset trailer length
7058 232 $$dirInfo{Offset} = $offset; # set offset from end of file
7059 232 $$dirInfo{Trailer} = 1; # set Trailer flag in case proc cares
7060 # add trailer and DirName to SubDirectory PATH
7061 232 push @$path, 'Trailer', $dirName;
7062 #
7063 # Call proc to read or write this trailer
7064 #
7065 # Proc inputs:
7066 # 0) ExifTool ref, with FileEnd set, and TrailerStart possibly set (start of all trailers)
7067 # 1) DirInfo with the following elements:
7068 # DirName - name of this trailer
7069 # RAF - RAF reference
7070 # Offset - positive offset from end of this trailer to the end of file
7071 # OutFile - (write mode) scalar reference for output buffer consisting of an empty string
7072 # Trailer - flag set so proc knows we are processing a trailer (if it cares)
7073 # Fixup - optional fixup for pointers in trailer
7074 # ScanForTrailer - set if we should now scan for the trailer start. For JPEG
7075 # images the ExifTool TrailerStart member will also be set, but for TIFF
7076 # images TrailerStart will only be set when writing, so the proc should
7077 # scan from the current file position when reading in a TIFF image.
7078 # Proc returns in read mode (OutFile not set):
7079 # 1 = success
7080 # 0 = error processing trailer (no warning will be issued and remaining trailers will be ignored)
7081 # -1 = must scan from TrailerStart since length can not be determined
7082 # (in which case this routine will be called again later when TrailerStart is known)
7083 # Proc returns in write mode:
7084 # 1 = success (and proc updates OutFile with the trailer to write, or empty string to delete)
7085 # 0 = error processing trailer (will issue minor error)
7086 # -1 = caller to copy or delete the trailer as-is (from TrailerStart if DataPos isn't set)
7087 # - TrailerStart will always be set in write mode
7088 # - the write routine will not be called if all trailers are being deleted
7089 # Proc sets the following elements of $dirInfo in both read and write mode:
7090 # DataPos - file position for start of this trailer
7091 # DirLen - length of this trailer (subsequent trailers are not processed if this is not set)
7092 # Fixup - for any pointers in the trailer that need adjusting
7093 #
7094 113 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
7095 232 my $result = &$proc($self, $dirInfo);
7096 113 ▶ use strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
7097  
7098 # restore PATH (pop last 2 items)
7099 232 splice @$path, -2;
7100  
7101 232 my ($dataPos, $dirLen) = @$dirInfo{'DataPos','DirLen'};
7102 232 ▶ if ($outfile) {
Branch: 2 branches
BranchTrueFalseTotal
if ($outfile) { } 57 175 232
elsif ($result < 0) { } 20 155 175
7103 57 ▶ if ($result < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($result < 0) 7 50 57
7104 # copy or delete the trailer ourself
7105 7 $result = 1;
7106 7 ▶ if ($$self{TrailerStart}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"TrailerStart"}) 7 0 7
7107 7 ▶ $dataPos or $dataPos = $$self{TrailerStart};
Branch: 1 branch
BranchTrueFalseTotal
$dataPos or $dataPos = $self->{"TrailerStart"} 7 0 7
7108 7 ▶ $dirLen or $dirLen = $$self{FileEnd} - $offset - $dataPos;
Branch: 1 branch
BranchTrueFalseTotal
$dirLen or $dirLen = $self->{"FileEnd"} - $offset - $dataPos 7 0 7
7109 }
7110 7 ▶ if ($$self{DEL_GROUP}{Trailer} or $$self{DEL_GROUP}{$dirName}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'DEL_GROUP'}{'Trailer'} or $self->{'DEL_GROUP'}{$dirName}) { } 0 7 7
elsif ($dataPos and $dirLen) { } 7 0 7
Condition33%1/3
$self->{"DEL_GROUP"}{"Trailer"} or $self->{"DEL_GROUP"}{$dirName}
l!l&&r!l&&!r
007
MC/DC0%0/2
$self->{"DEL_GROUP"}{"Trailer"} or $self->{"DEL_GROUP"}{$dirName}
$self->{"DEL_GROUP"}{"Trailer"} $self->{"DEL_GROUP"}{$dirName}
Truth table33%1/3
A or B
A= $self->{"DEL_GROUP"}{"Trailer"}B= $self->{"DEL_GROUP"}{$dirName}
ABresult
1X1
011
000
7111 0 ▶ my $bytes = $dirLen ? " ($dirLen bytes)" : '';
Branch: 1 branch
BranchTrueFalseTotal
$dirLen ? : 0 0 0
7112 0 $self->VPrint(0, "Deleting $dirName trailer$bytes\n");
7113 0 ++$$self{CHANGED};
7114 ▶ } elsif ($dataPos and $dirLen) {
Condition33%1/3
$dataPos and $dirLen
!ll&&!rl&&r
007
MC/DC0%0/2
$dataPos and $dirLen
$dataPos $dirLen
Truth table33%1/3
A and B
A= $dataPosB= $dirLen
ABresult
0X0
100
111
7115 7 $self->VPrint(0, "Copying $dirName trailer ($dirLen bytes)\n");
7116 $result = 0 unless $raf->Seek($dataPos) and
7117 7 ▶ $raf->Read(${$$dirInfo{OutFile}}, $dirLen) == $dirLen;
Branch: 1 branch
BranchTrueFalseTotal
unless $raf->Seek($dataPos) and $raf->Read(${$$dirInfo{"OutFile"};}, $dirLen) == $dirLen 0 7 7
Condition33%1/3
$raf->Seek($dataPos) and $raf->Read(${$$dirInfo{"OutFile"};}, $dirLen) == $dirLen
!ll&&!rl&&r
007
MC/DC0%0/2
$raf->Seek($dataPos) and $raf->Read(${$$dirInfo{"OutFile"};}, $dirLen) == $dirLen
$raf->Seek($dataPos) $raf->Read(${$$dirInfo{"OutFile"};}, $dirLen) == $dirLen
Truth table33%1/3
A and B
A= $raf->Seek($dataPos)B= $raf->Read(${$$dirInfo{"OutFile"};}, $dirLen) == $dirLen
ABresult
0X0
100
111
7118 } else {
7119 0 $result = 0;
7120 }
7121 }
7122 57 ▶ if ($result > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($result > 0) { } 57 0 57
7123 57 ▶ if ($outBuff) {
Branch: 1 branch
BranchTrueFalseTotal
if ($outBuff) 40 17 57
7124 # write trailers to OutFile in original order
7125 40 $$outfile = $outBuff . $$outfile;
7126 # must adjust old fixup start if it exists
7127 40 ▶ $$fixup{Start} += length($outBuff) if $fixup;
Branch: 1 branch
BranchTrueFalseTotal
if $fixup 33 7 40
7128 40 $outBuff = ''; # free memory
7129 }
7130 57 ▶ if ($$dirInfo{Fixup}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dirInfo->{"Fixup"}) 15 42 57
7131 15 ▶ if ($fixup) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fixup) 7 8 15
7132 # add fixup for subsequent trailers to the fixup for this trailer
7133 # (but first we must adjust for the new start position)
7134 7 $$fixup{Shift} += $$dirInfo{Fixup}{Start};
7135 7 $$fixup{Start} -= $$dirInfo{Fixup}{Start};
7136 7 $$dirInfo{Fixup}->AddFixup($fixup);
7137 }
7138 15 $fixup = $$dirInfo{Fixup}; # save fixup
7139 }
7140 } else {
7141 0 ▶ $success = 0 if $self->Error("Error rewriting $dirName trailer", 2);
Branch: 1 branch
BranchTrueFalseTotal
if $self->Error("Error rewriting $dirName trailer", 2) 0 0 0
7142 0 last;
7143 }
7144 } elsif ($result < 0) {
7145 # can't continue if we must scan for this trailer
7146 20 $success = 0;
7147 20 last;
7148 }
7149 212 ▶ last unless $result > 0 and $dirLen;
Branch: 1 branch
BranchTrueFalseTotal
unless $result > 0 and $dirLen 1 211 212
Condition66%2/3
$result > 0 and $dirLen
!ll&&!rl&&r
10211
MC/DC50%1/2
$result > 0 and $dirLen
$result > 0 $dirLen
Truth table66%2/3
A and B
A= $result > 0B= $dirLen
ABresult
0X0
100
111
7150 211 $offset += $dirLen;
7151 211 ▶ last if $dataPos and $$self{TrailerStart} and $dataPos <= $$self{TrailerStart};
Branch: 1 branch
BranchTrueFalseTotal
if $dataPos and $self->{"TrailerStart"} and $dataPos <= $self->{"TrailerStart"} 29 182 211
Condition83%5/6
$dataPos and $self->{"TrailerStart"} and $dataPos <= $self->{"TrailerStart"}
!ll&&!rl&&r
2715529
$dataPos and $self->{"TrailerStart"}
!ll&&!rl&&r
027184
MC/DC66%2/3
$dataPos and $self->{"TrailerStart"} and $dataPos <= $self->{"TrailerStart"}
$dataPos $self->{"TrailerStart"} $dataPos <= $self->{"TrailerStart"}
Truth table75%3/4
A and B and C
A= $dataPosB= $self->{"TrailerStart"}C= $dataPos <= $self->{"TrailerStart"}
ABCresult
0XX0
10X0
1100
1111
7152 # look for next trailer
7153 182 my $nextTrail = $self->IdentifyTrailer($raf, $offset);
7154 # process Google trailer after all others if necessary and not done already
7155 182 ▶ unless ($nextTrail) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($nextTrail) 28 154 182
7156 28 ▶ last unless $$self{ProcessGoogleTrailer};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"ProcessGoogleTrailer"} 28 0 28
7157 0 $nextTrail = { DirName => 'Google', RAF => $raf };
7158 }
7159 154 $dirName = $$dirInfo{DirName} = $$nextTrail{DirName};
7160 }
7161 78 SetByteOrder($byteOrder); # restore original byte order
7162 78 $raf->Seek($pos); # restore original file position
7163 78 $$dirInfo{OutFile} = $outfile; # restore original outfile
7164 78 $$dirInfo{Offset} = $offset; # return offset from EOF to start of first trailer
7165 78 $$dirInfo{Fixup} = $fixup; # return fixup information
7166 78 return $success;
7167 }
7168  
7169 #------------------------------------------------------------------------------
7170 # JPEG constants
7171  
7172 # JPEG marker names
7173 113 %jpegMarker = (
7174 0x00 => 'NULL',
7175 0x01 => 'TEM',
7176 0xc0 => 'SOF0', # to SOF15, with a few exceptions below
7177 0xc4 => 'DHT',
7178 0xc8 => 'JPGA',
7179 0xcc => 'DAC',
7180 0xd0 => 'RST0', # to RST7
7181 0xd8 => 'SOI',
7182 0xd9 => 'EOI',
7183 0xda => 'SOS',
7184 0xdb => 'DQT',
7185 0xdc => 'DNL',
7186 0xdd => 'DRI',
7187 0xde => 'DHP',
7188 0xdf => 'EXP',
7189 0xe0 => 'APP0', # to APP15
7190 0xf0 => 'JPG0',
7191 0xfe => 'COM',
7192 );
7193  
7194 # lookup for size of JPEG marker length word
7195 # (2 bytes assumed unless specified here)
7196 113 my %markerLenBytes = (
7197 0x00 => 0, 0x01 => 0,
7198 0xd0 => 0, 0xd1 => 0, 0xd2 => 0, 0xd3 => 0, 0xd4 => 0, 0xd5 => 0, 0xd6 => 0, 0xd7 => 0,
7199 0xd8 => 0, 0xd9 => 0, 0xda => 0,
7200 # J2C
7201 0x30 => 0, 0x31 => 0, 0x32 => 0, 0x33 => 0, 0x34 => 0, 0x35 => 0, 0x36 => 0, 0x37 => 0,
7202 0x38 => 0, 0x39 => 0, 0x3a => 0, 0x3b => 0, 0x3c => 0, 0x3d => 0, 0x3e => 0, 0x3f => 0,
7203 0x4f => 0,
7204 0x92 => 0, 0x93 => 0,
7205 # J2C extensions
7206 0x74 => 4, 0x75 => 4, 0x77 => 4,
7207 );
7208  
7209 #------------------------------------------------------------------------------
7210 # Get JPEG marker name
7211 # Inputs: 0) Jpeg number
7212 # Returns: marker name
7213 sub JpegMarkerName($)
7214 3200 ▶{
Subroutine JpegMarkerName: called CC=4 SCAR=14.6
Pod undocumented
7215 3200 my $marker = shift;
7216 3200 my $markerName = $jpegMarker{$marker};
7217 3200 ▶ unless ($markerName) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($markerName) 1180 2020 3200
7218 1180 $markerName = $jpegMarker{$marker & 0xf0};
7219 1180 ▶ if ($markerName and $markerName =~ /^([A-Z]+)\d+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($markerName and $markerName =~ /^([A-Z]+)\d+$/) { } 1180 0 1180
Condition33%1/3
$markerName and $markerName =~ /^([A-Z]+)\d+$/
!ll&&!rl&&r
001180
MC/DC0%0/2
$markerName and $markerName =~ /^([A-Z]+)\d+$/
$markerName $markerName =~ /^([A-Z]+)\d+$/
Truth table33%1/3
A and B
A= $markerNameB= $markerName =~ /^([A-Z]+)\d+$/
ABresult
0X0
100
111
7220 1180 $markerName = $1 . ($marker & 0x0f);
7221 } else {
7222 0 $markerName = sprintf("marker 0x%.2x", $marker);
7223 }
7224 }
7225 3200 return $markerName;
7226 }
7227  
7228 #------------------------------------------------------------------------------
7229 # Adjust directory start position
7230 # Inputs: 0) dirInfo ref, 1) start offset
7231 # 2) Base for offsets (relative to DataPos, defaults to absolute Base of 0)
7232 sub DirStart($$;$)
7233 582 ▶{
Subroutine DirStart: called CC=2 SCAR=6.9
Pod undocumented
7234 582 my ($dirInfo, $start, $base) = @_;
7235 582 $$dirInfo{DirStart} = $start;
7236 582 $$dirInfo{DirLen} -= $start;
7237 582 ▶ if (defined $base) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $base) 279 303 582
7238 279 $$dirInfo{Base} = $$dirInfo{DataPos} + $base;
7239 279 $$dirInfo{DataPos} = -$base; # (relative to Base!)
7240 }
7241 }
7242  
7243 #------------------------------------------------------------------------------
7244 # Extract metadata from a jpg image
7245 # Inputs: 0) ExifTool object reference, 1) dirInfo ref with RAF set
7246 # 2) tag table ref to process JPEG-like metadata
7247 # Returns: 1 on success, 0 if this wasn't a valid JPEG file
7248 sub ProcessJPEG($$;$)
7249 251 ▶{
Subroutine ProcessJPEG: called CC=414 SCAR=96.4
Pod undocumented
7250 251 local $_;
7251 251 my ($self, $dirInfo, $optionalTagTable) = @_;
7252 251 my $options = $$self{OPTIONS};
7253 251 my $verbose = $$options{Verbose};
7254 251 my $out = $$options{TextOut};
7255 251 ▶ my $fast = $$options{FastScan} || 0;
Condition100%2/2
$options->{'FastScan'} || 0
l!l
2249
MC/DC100%1/1
$options->{'FastScan'} || 0
$options->{'FastScan'}
Truth table100%2/2
A
A= $options->{'FastScan'}
Aresult
11
00
7256 251 my $raf = $$dirInfo{RAF};
7257 251 my $req = $$self{REQ_TAG_LOOKUP};
7258 251 my $htmlDump = $$self{HTML_DUMP};
7259 251 my %dumpParms = ( Out => $out, Prefix => $$self{INDENT} );
7260 251 my ($ch, $s, $length, $hash, $hashsize, $indent);
7261 251 my ($success, $wantTrailer, $trailInfo, $foundSOS, $gotSize, %jumbfChunk);
7262 251 my (@iccChunk, $iccChunkCount, $iccChunksTotal, @flirChunk, $flirCount, $flirTotal);
7263 251 my ($preview, $scalado, @dqt, $subSampling, $dumpEnd, %extendedXMP);
7264  
7265 251 ($indent = $$self{INDENT}) =~ s/ $//;
7266 251 ▶ unless ($raf) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($raf) 0 251 251
7267 0 $raf = File::RandomAccess->new($$dirInfo{DataPt});
7268 0 $self->VerboseDir('JPEG', undef, length(${$$dirInfo{DataPt}}));
7269 }
7270 # get pointer to hash object if it exists and we are the top-level JPEG or JP2
7271 251 ▶ if ($$self{FILE_TYPE} =~ /^(JPEG|JP2)$/ and not $$self{DOC_NUM}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"FILE_TYPE"} =~ /^(JPEG|JP2)$/ and not $self->{"DOC_NUM"}) 242 9 251
Condition100%3/3
$self->{"FILE_TYPE"} =~ /^(JPEG|JP2)$/ and not $self->{"DOC_NUM"}
!ll&&!rl&&r
72242
MC/DC100%2/2
$self->{"FILE_TYPE"} =~ /^(JPEG|JP2)$/ and not $self->{"DOC_NUM"}
$self->{"FILE_TYPE"} =~ /^(JPEG|JP2)$/ not $self->{"DOC_NUM"}
Truth table100%3/3
A and not(B)
A= $self->{"FILE_TYPE"} =~ /^(JPEG|JP2)$/B= not $self->{"DOC_NUM"}
ABresult
0X0
100
111
7272 242 $hash = $$self{ImageDataHash};
7273 242 $hashsize = 0;
7274 }
7275 # check to be sure this is a valid JPG (or J2C, or EXV) file
7276 251 ▶ if ($raf->Read($s, 2) == 2 and $s =~ /^\xff[\xd8\x4f\x01]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($raf->Read($s, 2) == 2 and $s =~ /^\xff[\xd8\x4f\x01]/) { } 251 0 251
Condition33%1/3
$raf->Read($s, 2) == 2 and $s =~ /^\xff[\xd8\x4f\x01]/
!ll&&!rl&&r
00251
MC/DC0%0/2
$raf->Read($s, 2) == 2 and $s =~ /^\xff[\xd8\x4f\x01]/
$raf->Read($s, 2) == 2 $s =~ /^\xff[\xd8\x4f\x01]/
Truth table33%1/3
A and B
A= $raf->Read($s, 2) == 2B= $s =~ /^\xff[\xd8\x4f\x01]/
ABresult
0X0
100
111
7277 251 undef $optionalTagTable;
7278 } else {
7279 0 ▶ return 0 unless $optionalTagTable and $s =~ /^\xff[\xe0-\xef]/;
Branch: 1 branch
BranchTrueFalseTotal
unless $optionalTagTable and $s =~ /^\xff[\xe0-\xef]/ 0 0 0
Condition0%0/3
$optionalTagTable and $s =~ /^\xff[\xe0-\xef]/
!ll&&!rl&&r
000
MC/DC0%0/2
$optionalTagTable and $s =~ /^\xff[\xe0-\xef]/
$optionalTagTable $s =~ /^\xff[\xe0-\xef]/
Truth table0%0/3
A and B
A= $optionalTagTableB= $s =~ /^\xff[\xe0-\xef]/
ABresult
0X0
100
111
7280 0 ▶ $raf->Seek(-2, 1) or $self->Error('Seek error'), return 1;
Branch: 1 branch
BranchTrueFalseTotal
$raf->Seek(-2, 1) or $self->Error("Seek error"), (return 1) 0 0 0
7281 }
7282 251 ▶ if ($s eq "\xff\x01") {
Branch: 1 branch
BranchTrueFalseTotal
if ($s eq "\377\1") 2 249 251
7283 2 ▶ return 0 unless $raf->Read($s, 5) == 5 and $s eq 'Exiv2';
Branch: 1 branch
BranchTrueFalseTotal
unless $raf->Read($s, 5) == 5 and $s eq "Exiv2" 0 2 2
Condition33%1/3
$raf->Read($s, 5) == 5 and $s eq "Exiv2"
!ll&&!rl&&r
002
MC/DC0%0/2
$raf->Read($s, 5) == 5 and $s eq "Exiv2"
$raf->Read($s, 5) == 5 $s eq "Exiv2"
Truth table33%1/3
A and B
A= $raf->Read($s, 5) == 5B= $s eq "Exiv2"
ABresult
0X0
100
111
7284 2 $$self{FILE_TYPE} = 'EXV';
7285 }
7286 251 my $appBytes = 0;
7287 251 my $calcImageLen = $$req{jpegimagelength};
7288 251 ▶ if ($$options{RequestAll} and $$options{RequestAll} > 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($options->{"RequestAll"} and $options->{"RequestAll"} > 2) 0 251 251
Condition66%2/3
$options->{"RequestAll"} and $options->{"RequestAll"} > 2
!ll&&!rl&&r
209420
MC/DC0%0/2
$options->{"RequestAll"} and $options->{"RequestAll"} > 2
$options->{"RequestAll"} $options->{"RequestAll"} > 2
Truth table66%2/3
A and B
A= $options->{"RequestAll"}B= $options->{"RequestAll"} > 2
ABresult
0X0
100
111
7289 0 $calcImageLen = 1;
7290 }
7291 251 ▶ if (not $$self{VALUE}{FileType} or ($$self{DOC_NUM} and $$options{ExtractEmbedded})) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->{"VALUE"}{"FileType"} or $self->{"DOC_NUM"} and $options->{"ExtractEmbedded"}) 243 8 251
Condition66%4/6
not $self->{"VALUE"}{"FileType"} or $self->{"DOC_NUM"} and $options->{"ExtractEmbedded"}
l!l&&r!l&&!r
24308
$self->{"DOC_NUM"} and $options->{"ExtractEmbedded"}
!ll&&!rl&&r
620
MC/DC33%1/3
not $self->{"VALUE"}{"FileType"} or $self->{"DOC_NUM"} and $options->{"ExtractEmbedded"}
not $self->{"VALUE"}{"FileType"} $self->{"DOC_NUM"} $options->{"ExtractEmbedded"}
Truth table75%3/4
not(A) or B and C
A= not $self->{"VALUE"}{"FileType"}B= $self->{"DOC_NUM"}C= $options->{"ExtractEmbedded"}
ABCresult
1XX1
0111
00X0
0100
7292 243 $self->SetFileType(); # set FileType tag
7293 243 ▶ return 1 if $fast > 2; # don't process file when FastScan > 2
Branch: 1 branch
BranchTrueFalseTotal
if $fast > 2 1 242 243
7294 242 $$self{LOW_PRIORITY_DIR}{IFD1} = 1; # lower priority of IFD1 tags
7295 }
7296 250 ▶ $$raf{NoBuffer} = 1 if $self->Options('FastScan'); # disable buffering in FastScan mode
Branch: 1 branch
BranchTrueFalseTotal
if $self->Options("FastScan") 1 249 250
7297  
7298 250 ▶ $dumpParms{MaxLen} = 128 if $verbose < 4;
Branch: 1 branch
BranchTrueFalseTotal
if $verbose < 4 250 0 250
7299 250 ▶ if ($htmlDump and not $optionalTagTable) {
Branch: 1 branch
BranchTrueFalseTotal
if ($htmlDump and not $optionalTagTable) 0 250 250
Condition33%1/3
$htmlDump and not $optionalTagTable
!ll&&!rl&&r
25000
MC/DC0%0/2
$htmlDump and not $optionalTagTable
$htmlDump not $optionalTagTable
Truth table33%1/3
A and not(B)
A= $htmlDumpB= not $optionalTagTable
ABresult
0X0
100
111
7300 0 $dumpEnd = $raf->Tell();
7301 0 ▶ my ($n, $t, $m) = $s eq 'Exiv2' ? (7,'EXV','TEM') : (2,'JPEG','SOI');
Branch: 1 branch
BranchTrueFalseTotal
$s eq 'Exiv2' ? : 0 0 0
7302 0 my $pos = $dumpEnd - $n;
7303 0 ▶ $self->HDump(0, $pos, '[unknown header]') if $pos;
Branch: 1 branch
BranchTrueFalseTotal
if $pos 0 0 0
7304 0 $self->HDump($pos, $n, "$t header", "$m Marker");
7305 }
7306 250 my $path = $$self{PATH};
7307 250 my $pn = scalar @$path;
7308  
7309 # set input record separator to 0xff (the JPEG marker) to make reading quicker
7310 250 local $/ = "\xff";
7311  
7312 250 my ($nextMarker, $nextSegDataPt, $nextSegPos, $combinedSegData, $firstSegPos, @skipData);
7313  
7314 # read file until we reach an end of image (EOI) or start of scan (SOS)
7315 250 Marker: for (;;) {
7316 # set marker and data pointer for current segment
7317 2217 my $marker = $nextMarker;
7318 2217 ▶ last if $marker and $marker < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $marker and $marker < 0 0 2217 2217
Condition66%2/3
$marker and $marker < 0
!ll&&!rl&&r
27119460
MC/DC0%0/2
$marker and $marker < 0
$marker $marker < 0
Truth table66%2/3
A and B
A= $markerB= $marker < 0
ABresult
0X0
100
111
7319 2217 my $segDataPt = $nextSegDataPt;
7320 2217 my $segPos = $nextSegPos;
7321 2217 my $skipped;
7322 2217 undef $nextMarker;
7323 2217 undef $nextSegDataPt;
7324 #
7325 # read ahead to the next segment unless we have reached EOI, SOS or SOD
7326 #
7327 2217 ▶ until ($marker and ($marker==0xd9 or ($marker==0xda and not $wantTrailer and not $hash) or
Branch: 1 branch
BranchTrueFalseTotal
unless ($marker and $marker == 217 || $marker == 218 && !$wantTrailer && !$hash || $marker == 147) 1946 271 2217
Condition86%13/15
$marker and $marker == 217 || $marker == 218 && !$wantTrailer && !$hash || $marker == 147
!ll&&!rl&&r
2711675271
$marker == 217 or $marker == 218 and not $wantTrailer and not $hash or $marker == 147
l!l&&r!l&&!r
27011675
$marker == 217 or $marker == 218 and not $wantTrailer and not $hash
l!l&&r!l&&!r
232471676
$marker == 218 and not $wantTrailer and not $hash
!ll&&!rl&&r
16760247
$marker == 218 and not $wantTrailer
!ll&&!rl&&r
16760247
MC/DC66%4/6
$marker and $marker == 217 || $marker == 218 && !$wantTrailer && !$hash || $marker == 147
$marker $marker == 217 $marker == 218 not $wantTrailer not $hash $marker == 147
Truth table55%5/9
A and B or C and not(D) and not(E) or F
A= $markerB= $marker == 217C= $marker == 218D= not $wantTrailerE= not $hashF= $marker == 147
ABCDEFresult
0XXXXX0
100XX00
1010X00
1011000
11XXXX1
10111X1
100XX11
1010X11
1011011
7328 $marker==0x93))
7329 {
7330 # read up to next marker (JPEG markers begin with 0xff)
7331 1946 my $buff;
7332 1946 ▶ unless ($raf->ReadLine($buff)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($raf->ReadLine($buff)) 0 1946 1946
7333 0 ▶ last Marker unless $optionalTagTable;
Branch: 1 branch
BranchTrueFalseTotal
unless $optionalTagTable 0 0 0
7334 0 $nextMarker = -1;
7335 0 $success = 1;
7336 0 last;
7337 }
7338 1946 $skipped = length($buff) - 1;
7339 # JPEG markers can be padded with unlimited 0xff's
7340 1946 for (;;) {
7341 1946 ▶ $raf->Read($ch, 1) or last Marker;
Branch: 1 branch
BranchTrueFalseTotal
$raf->Read($ch, 1) or last Marker 1946 0 1946
7342 1946 $nextMarker = ord($ch);
7343 1946 ▶ last unless $nextMarker == 0xff;
Branch: 1 branch
BranchTrueFalseTotal
unless $nextMarker == 255 1946 0 1946
7344 0 ++$skipped;
7345 }
7346 # read segment data if it exists
7347 1946 ▶ if (not defined $markerLenBytes{$nextMarker}) {
Branch: 3 branches
BranchTrueFalseTotal
if (not defined $markerLenBytes{$nextMarker}) { } 1675 271 1946
elsif ($markerLenBytes{$nextMarker} == 4) { } 0 271 271
elsif ($hash and defined $marker and $marker == 0 || $marker == 218 || $marker >= 208 && $marker <= 215) { } 0 542 542
7348 # read record length word
7349 1675 ▶ last Marker unless $raf->Read($s, 2) == 2;
Branch: 1 branch
BranchTrueFalseTotal
unless $raf->Read($s, 2) == 2 0 1675 1675
7350 1675 my $len = unpack('n',$s); # get data length
7351 1675 ▶ last Marker unless defined($len) and $len >= 2;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $len and $len >= 2 0 1675 1675
Condition33%1/3
defined $len and $len >= 2
!ll&&!rl&&r
001675
MC/DC0%0/2
defined $len and $len >= 2
defined $len $len >= 2
Truth table33%1/3
A and B
A= defined $lenB= $len >= 2
ABresult
0X0
100
111
7352 1675 $nextSegPos = $raf->Tell();
7353 1675 $len -= 2; # subtract size of length word
7354 1675 ▶ last Marker unless $raf->Read($buff, $len) == $len;
Branch: 1 branch
BranchTrueFalseTotal
unless $raf->Read($buff, $len) == $len 0 1675 1675
7355 1675 $nextSegDataPt = \$buff; # set pointer to our next data
7356 } elsif ($markerLenBytes{$nextMarker} == 4) {
7357 # handle J2C extensions with 4-byte length word
7358 0 ▶ last Marker unless $raf->Read($s, 4) == 4;
Branch: 1 branch
BranchTrueFalseTotal
unless $raf->Read($s, 4) == 4 0 0 0
7359 0 my $len = unpack('N',$s); # get data length
7360 0 ▶ last Marker unless defined($len) and $len >= 4;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $len and $len >= 4 0 0 0
Condition0%0/3
defined $len and $len >= 4
!ll&&!rl&&r
000
MC/DC0%0/2
defined $len and $len >= 4
defined $len $len >= 4
Truth table0%0/3
A and B
A= defined $lenB= $len >= 4
ABresult
0X0
100
111
7361 0 $nextSegPos = $raf->Tell();
7362 0 $len -= 4; # subtract size of length word
7363 0 ▶ last Marker unless $raf->Seek($len, 1);
Branch: 1 branch
BranchTrueFalseTotal
unless $raf->Seek($len, 1) 0 0 0
7364 ▶ } elsif ($hash and defined $marker and ($marker == 0x00 or $marker == 0xda or
Condition13%2/15
$hash and defined $marker and $marker == 0 || $marker == 218 || $marker >= 208 && $marker <= 215
!ll&&!rl&&r
27100
$hash and defined $marker
!ll&&!rl&&r
27100
$marker == 0 or $marker == 218 or $marker >= 208 and $marker <= 215
l!l&&r!l&&!r
000
$marker == 0 or $marker == 218
l!l&&r!l&&!r
000
$marker >= 208 and $marker <= 215
!ll&&!rl&&r
000
MC/DC0%0/6
$hash and defined $marker and $marker == 0 || $marker == 218 || $marker >= 208 && $marker <= 215
$hash defined $marker $marker == 0 $marker == 218 $marker >= 208 $marker <= 215
Truth table14%1/7
A and B and C or D or E and F
A= $hashB= defined $markerC= $marker == 0D= $marker == 218E= $marker >= 208F= $marker <= 215
ABCDEFresult
0XXXXX0
10XXXX0
11000X0
1100100
111XXX1
1101XX1
1100111
7365 ($marker >= 0xd0 and $marker <= 0xd7)))
7366 {
7367 # calculate hash for image data (includes leading ff d9 but not trailing ff da)
7368 0 $hash->add("\xff" . chr($marker));
7369 0 my $n = $skipped - (length($buff) - 1); # number of extra 0xff's
7370 0 ▶ if (not $n) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $n) { } 0 0 0
elsif ($n > 1) { } 0 0 0
7371 0 $buff = substr($buff, 0, -1); # remove trailing 0xff
7372 } elsif ($n > 1) {
7373 0 $buff .= "\xff" x ($n - 1); # add back extra 0xff's
7374 }
7375 0 $hash->add($buff);
7376 0 $hashsize += $skipped + 2;
7377 }
7378 # read second segment too if this was the first
7379 1946 ▶ next Marker unless defined $marker;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $marker 271 1675 1946
7380 1675 last;
7381 }
7382 # set some useful variables for the current segment
7383 1946 my $markerName = JpegMarkerName($marker);
7384 1946 $$path[$pn] = $markerName;
7385 # issue warning if we skipped some garbage
7386 1946 ▶ if ($skipped and not $foundSOS and $markerName ne 'SOS') {
Branch: 1 branch
BranchTrueFalseTotal
if ($skipped and not $foundSOS and $markerName ne "SOS") 0 1946 1946
Condition33%2/6
$skipped and not $foundSOS and $markerName ne "SOS"
!ll&&!rl&&r
194600
$skipped and not $foundSOS
!ll&&!rl&&r
194600
MC/DC0%0/3
$skipped and not $foundSOS and $markerName ne "SOS"
$skipped not $foundSOS $markerName ne "SOS"
Truth table25%1/4
A and not(B) and C
A= $skippedB= not $foundSOSC= $markerName ne "SOS"
ABCresult
0XX0
10X0
1100
1111
7387 0 $self->Warn("Skipped unknown $skipped bytes after JPEG $markerName segment", 1);
7388 0 ▶ if ($htmlDump) {
Branch: 1 branch
BranchTrueFalseTotal
if ($htmlDump) 0 0 0
7389 0 $self->HDump($nextSegPos-4-$skipped, $skipped, "[unknown $skipped bytes]", undef, 0x08);
7390 0 $dumpEnd = $nextSegPos - 4;
7391 }
7392 }
7393 #
7394 # parse the current segment
7395 #
7396 # handle SOF markers: SOF0-SOF15, except DHT(0xc4), JPGA(0xc8) and DAC(0xcc)
7397 1946 ▶ if (($marker & 0xf0) == 0xc0 and ($marker == 0xc0 or $marker & 0x03)) {
Branch: 6 branches
BranchTrueFalseTotal
if (($marker & 240) == 192 and $marker == 192 || $marker & 3) { } 247 1699 1946
elsif ($marker == 217) { } 23 1676 1699
elsif ($marker == 218) { } 247 1429 1676
elsif ($marker == 147) { } 1 1428 1429
elsif (defined $markerLenBytes{$marker}) { } 0 1428 1428
elsif ($marker == 219 and length $$segDataPt and $req->{'jpegdigest'} || $req->{'jpegqualityestimate'} || $options->{'RequestAll'} && $options->{'RequestAll'} > 2) { } 1 2811 2812
Condition83%5/6
($marker & 240) == 192 and $marker == 192 || $marker & 3
!ll&&!rl&&r
1449250247
$marker == 192 or $marker & 3
l!l&&r!l&&!r
2470250
MC/DC66%2/3
($marker & 240) == 192 and $marker == 192 || $marker & 3
($marker & 240) == 192 $marker == 192 $marker & 3
Truth table75%3/4
A and B or C
A= ($marker & 240) == 192B= $marker == 192C= $marker & 3
ABCresult
0XX0
1000
11X1
1011
7398 247 $length = length $$segDataPt;
7399 247 ▶ if ($verbose) {
Branch: 2 branches
BranchTrueFalseTotal
if ($verbose) { } 2 245 247
elsif ($htmlDump) { } 0 245 245
7400 2 print $out "${indent}JPEG $markerName ($length bytes):\n";
7401 2 ▶ HexDump($segDataPt, undef, %dumpParms, Addr=>$segPos) if $verbose>2;
Branch: 1 branch
BranchTrueFalseTotal
if $verbose > 2 1 1 2
7402 } elsif ($htmlDump) {
7403 0 $self->HDump($segPos-4, $length+4, "[JPEG $markerName]", undef, 0x08);
7404 0 $dumpEnd = $segPos + $length;
7405 }
7406 247 ▶ next if $length < 6 or $gotSize;
Branch: 1 branch
BranchTrueFalseTotal
if $length < 6 or $gotSize 0 247 247
Condition33%1/3
$length < 6 or $gotSize
l!l&&r!l&&!r
00247
MC/DC0%0/2
$length < 6 or $gotSize
$length < 6 $gotSize
Truth table33%1/3
A or B
A= $length < 6B= $gotSize
ABresult
1X1
011
000
7407 247 $gotSize = 1; # (ignore subsequent SOF segments in probably corrupted JPEG)
7408 # extract some useful information
7409 247 my ($p, $h, $w, $n) = unpack('Cn2C', $$segDataPt);
7410 247 my $sof = GetTagTable('Image::ExifTool::JPEG::SOF');
7411 247 $self->HandleTag($sof, 'ImageWidth', $w);
7412 247 $self->HandleTag($sof, 'ImageHeight', $h);
7413 247 $self->HandleTag($sof, 'EncodingProcess', $marker - 0xc0);
7414 247 $self->HandleTag($sof, 'BitsPerSample', $p);
7415 247 $self->HandleTag($sof, 'ColorComponents', $n);
7416 247 ▶ next unless $n == 3 and $length >= 15;
Branch: 1 branch
BranchTrueFalseTotal
unless $n == 3 and $length >= 15 0 247 247
Condition33%1/3
$n == 3 and $length >= 15
!ll&&!rl&&r
00247
MC/DC0%0/2
$n == 3 and $length >= 15
$n == 3 $length >= 15
Truth table33%1/3
A and B
A= $n == 3B= $length >= 15
ABresult
0X0
100
111
7417 247 my ($i, $hmin, $hmax, $vmin, $vmax);
7418 # loop through all components to determine sampling frequency
7419 247 $subSampling = '';
7420 247 ▶ for ($i=0; $i<$n; ++$i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $n) 741 247 988
7421 741 my $sf = Get8u($segDataPt, 7 + 3 * $i);
7422 741 $subSampling .= sprintf('%.2x', $sf);
7423 # isolate horizontal and vertical components
7424 741 my ($hf, $vf) = ($sf >> 4, $sf & 0x0f);
7425 741 ▶ unless ($i) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($i) 247 494 741
7426 247 $hmin = $hmax = $hf;
7427 247 $vmin = $vmax = $vf;
7428 247 next;
7429 }
7430 # determine min/max frequencies
7431 494 ▶ $hmin = $hf if $hf < $hmin;
Branch: 1 branch
BranchTrueFalseTotal
if $hf < $hmin 247 247 494
7432 494 ▶ $hmax = $hf if $hf > $hmax;
Branch: 1 branch
BranchTrueFalseTotal
if $hf > $hmax 0 494 494
7433 494 ▶ $vmin = $vf if $vf < $vmin;
Branch: 1 branch
BranchTrueFalseTotal
if $vf < $vmin 246 248 494
7434 494 ▶ $vmax = $vf if $vf > $vmax;
Branch: 1 branch
BranchTrueFalseTotal
if $vf > $vmax 0 494 494
7435 }
7436 247 ▶ if ($hmin and $vmin) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hmin and $vmin) 247 0 247
Condition33%1/3
$hmin and $vmin
!ll&&!rl&&r
00247
MC/DC0%0/2
$hmin and $vmin
$hmin $vmin
Truth table33%1/3
A and B
A= $hminB= $vmin
ABresult
0X0
100
111
7437 247 my ($hs, $vs) = ($hmax / $hmin, $vmax / $vmin);
7438 247 $self->HandleTag($sof, 'YCbCrSubSampling', "$hs $vs");
7439 }
7440 247 next;
7441 } elsif ($marker == 0xd9) { # EOI
7442 23 pop @$path;
7443 23 ▶ $verbose and print $out "${indent}JPEG EOI\n";
Branch: 1 branch
BranchTrueFalseTotal
$verbose and print $out "${indent}JPEG EOI\n" 1 22 23
7444 23 my $pos = $raf->Tell();
7445 23 ▶ $$self{TrailerStart} = $pos unless $$self{DOC_NUM};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"DOC_NUM"} 23 0 23
7446 23 ▶ if ($htmlDump and $dumpEnd) {
Branch: 1 branch
BranchTrueFalseTotal
if ($htmlDump and $dumpEnd) 0 23 23
Condition33%1/3
$htmlDump and $dumpEnd
!ll&&!rl&&r
2300
MC/DC0%0/2
$htmlDump and $dumpEnd
$htmlDump $dumpEnd
Truth table33%1/3
A and B
A= $htmlDumpB= $dumpEnd
ABresult
0X0
100
111
7447 0 $self->HDump($dumpEnd, $pos-2-$dumpEnd, '[JPEG Image Data]', undef, 0x08);
7448 0 $self->HDump($pos-2, 2, 'JPEG EOI', undef);
7449 0 $dumpEnd = 0;
7450 }
7451 23 ▶ if ($foundSOS or $$self{FILE_TYPE} eq 'EXV') {
Branch: 1 branch
BranchTrueFalseTotal
if ($foundSOS or $self->{'FILE_TYPE'} eq 'EXV') { } 23 0 23
Condition66%2/3
$foundSOS or $self->{"FILE_TYPE"} eq "EXV"
l!l&&r!l&&!r
2120
MC/DC0%0/2
$foundSOS or $self->{"FILE_TYPE"} eq "EXV"
$foundSOS $self->{"FILE_TYPE"} eq "EXV"
Truth table66%2/3
A or B
A= $foundSOSB= $self->{"FILE_TYPE"} eq "EXV"
ABresult
1X1
011
000
7452 23 $success = 1;
7453 } else {
7454 0 $self->Warn('Missing JPEG SOS');
7455 }
7456 23 ▶ if ($$req{trailer}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($req->{"trailer"}) 0 23 23
7457 # read entire trailer into memory
7458 0 ▶ if ($raf->Seek(0,2)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($raf->Seek(0, 2)) { } 0 0 0
7459 0 my $len = $raf->Tell() - $pos;
7460 0 ▶ if ($len) {
Branch: 1 branch
BranchTrueFalseTotal
if ($len) 0 0 0
7461 0 my $buff;
7462 0 $raf->Seek($pos, 0);
7463 0 ▶ $self->FoundTag(Trailer => \$buff) if $raf->Read($buff,$len) == $len;
Branch: 1 branch
BranchTrueFalseTotal
if $raf->Read($buff, $len) == $len 0 0 0
7464 0 $raf->Seek($pos, 0);
7465 }
7466 } else {
7467 0 $self->Warn('Error seeking in file');
7468 }
7469 }
7470 # we are here because we are looking for trailer information
7471 23 ▶ if ($wantTrailer) {
Branch: 1 branch
BranchTrueFalseTotal
if ($wantTrailer) 0 23 23
7472 0 my $start = $$self{PreviewImageStart};
7473 0 ▶ if ($start or $$options{ExtractEmbedded}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($start or $options->{"ExtractEmbedded"}) 0 0 0
Condition0%0/3
$start or $options->{"ExtractEmbedded"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$start or $options->{"ExtractEmbedded"}
$start $options->{"ExtractEmbedded"}
Truth table0%0/3
A or B
A= $startB= $options->{"ExtractEmbedded"}
ABresult
1X1
011
000
7474 0 my $buff;
7475 # most previews start right after the JPEG EOI, but the Olympus E-20
7476 # preview is 508 bytes into the trailer, the K-M Maxxum 7D preview is
7477 # 979 bytes in, and Sony previews can start up to 32 kB into the trailer.
7478 # (and Minolta and Sony previews can have a random first byte...)
7479 0 ▶ my $scanLen = $$self{Make} =~ /Sony/i ? 65536 : 1024;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'Make'} =~ /Sony/i ? : 0 0 0
7480 0 ▶ if ($raf->Read($buff, $scanLen)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($raf->Read($buff, $scanLen)) 0 0 0
7481 0 ▶ if ($buff =~ /^.{4}ftyp/s) {
Branch: 2 branches
BranchTrueFalseTotal
if ($buff =~ /^.{4}ftyp/s) { } 0 0 0
elsif ($buff =~ /\xff\xd8\xff./g or $self->{'Make'} =~ /(Minolta|Sony)/i and $buff =~ /.\xd8\xff\xdb/g) { } 0 0 0
7482 0 my $val;
7483 0 ▶ if ($raf->Seek(0,2)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($raf->Seek(0, 2)) { } 0 0 0
7484 0 my $len = $raf->Tell() - $pos;
7485 0 ▶ if ($$options{Binary}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($options->{'Binary'}) { } 0 0 0
7486 0 ▶ $val = \$buff if $raf->Seek($pos,0) and $raf->Read($buff,$len)==$len;
Branch: 1 branch
BranchTrueFalseTotal
if $raf->Seek($pos, 0) and $raf->Read($buff, $len) == $len 0 0 0
Condition0%0/3
$raf->Seek($pos, 0) and $raf->Read($buff, $len) == $len
!ll&&!rl&&r
000
MC/DC0%0/2
$raf->Seek($pos, 0) and $raf->Read($buff, $len) == $len
$raf->Seek($pos, 0) $raf->Read($buff, $len) == $len
Truth table0%0/3
A and B
A= $raf->Seek($pos, 0)B= $raf->Read($buff, $len) == $len
ABresult
0X0
100
111
7487 } else {
7488 0 $val = \ "Binary data $len bytes";
7489 }
7490 0 ▶ if ($val) {
Branch: 1 branch
BranchTrueFalseTotal
if ($val) { } 0 0 0
7491 0 $self->FoundTag('EmbeddedVideo', $val);
7492 } else {
7493 0 $self->Warn('Error reading trailer');
7494 }
7495 } else {
7496 0 $self->Warn('Error seeking to end of file');
7497 }
7498 ▶ } elsif ($buff =~ /\xff\xd8\xff./g or
Condition0%0/6
$buff =~ /\xff\xd8\xff./g or $self->{"Make"} =~ /(Minolta|Sony)/i and $buff =~ /.\xd8\xff\xdb/g
l!l&&r!l&&!r
000
$self->{"Make"} =~ /(Minolta|Sony)/i and $buff =~ /.\xd8\xff\xdb/g
!ll&&!rl&&r
000
MC/DC0%0/3
$buff =~ /\xff\xd8\xff./g or $self->{"Make"} =~ /(Minolta|Sony)/i and $buff =~ /.\xd8\xff\xdb/g
$buff =~ /\xff\xd8\xff./g $self->{"Make"} =~ /(Minolta|Sony)/i $buff =~ /.\xd8\xff\xdb/g
Truth table0%0/4
A or B and C
A= $buff =~ /\xff\xd8\xff./gB= $self->{"Make"} =~ /(Minolta|Sony)/iC= $buff =~ /.\xd8\xff\xdb/g
ABCresult
1XX1
0111
00X0
0100
7499 ($$self{Make} =~ /(Minolta|Sony)/i and $buff =~ /.\xd8\xff\xdb/g))
7500 {
7501 # adjust PreviewImageStart to this location
7502 0 my $actual = $pos + pos($buff) - 4;
7503 0 ▶ if ($start and $start ne $actual and $verbose > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($start and $start ne $actual and $verbose > 1) 0 0 0
Condition0%0/6
$start and $start ne $actual and $verbose > 1
!ll&&!rl&&r
000
$start and $start ne $actual
!ll&&!rl&&r
000
MC/DC0%0/3
$start and $start ne $actual and $verbose > 1
$start $start ne $actual $verbose > 1
Truth table0%0/4
A and B and C
A= $startB= $start ne $actualC= $verbose > 1
ABCresult
0XX0
10X0
1100
1111
7504 0 print $out "${indent}(Fixed PreviewImage location: $start -> $actual)\n";
7505 }
7506 # update preview image offsets
7507 0 ▶ if ($start) {
Branch: 1 branch
BranchTrueFalseTotal
if ($start) 0 0 0
7508 0 ▶ $$self{VALUE}{PreviewImageStart} = $actual if $$self{VALUE}{PreviewImageStart};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"VALUE"}{"PreviewImageStart"} 0 0 0
7509 0 $$self{PreviewImageStart} = $actual;
7510 }
7511 # load preview now if we tried and failed earlier
7512 0 ▶ if ($$self{PreviewError} and $$self{PreviewImageLength}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"PreviewError"} and $self->{"PreviewImageLength"}) 0 0 0
Condition0%0/3
$self->{"PreviewError"} and $self->{"PreviewImageLength"}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"PreviewError"} and $self->{"PreviewImageLength"}
$self->{"PreviewError"} $self->{"PreviewImageLength"}
Truth table0%0/3
A and B
A= $self->{"PreviewError"}B= $self->{"PreviewImageLength"}
ABresult
0X0
100
111
7513 0 ▶ if ($raf->Seek($actual, 0) and $raf->Read($buff, $$self{PreviewImageLength})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($raf->Seek($actual, 0) and $raf->Read($buff, $self->{"PreviewImageLength"})) 0 0 0
Condition0%0/3
$raf->Seek($actual, 0) and $raf->Read($buff, $self->{"PreviewImageLength"})
!ll&&!rl&&r
000
MC/DC0%0/2
$raf->Seek($actual, 0) and $raf->Read($buff, $self->{"PreviewImageLength"})
$raf->Seek($actual, 0) $raf->Read($buff, $self->{"PreviewImageLength"})
Truth table0%0/3
A and B
A= $raf->Seek($actual, 0)B= $raf->Read($buff, $self->{"PreviewImageLength"})
ABresult
0X0
100
111
7514 0 $self->FoundTag('PreviewImage', $buff);
7515 0 delete $$self{PreviewError};
7516 }
7517 }
7518 }
7519 }
7520 0 $raf->Seek($pos, 0);
7521 }
7522 }
7523 # process trailer now or finish processing trailers
7524 # and scan for AFCP if necessary
7525 23 my $fromEnd = 0;
7526 23 ▶ if ($trailInfo) {
Branch: 1 branch
BranchTrueFalseTotal
if ($trailInfo) 20 3 23
7527 20 $$trailInfo{ScanForTrailer} = 1; # scan now if necessary
7528 20 $self->ProcessTrailers($trailInfo);
7529 # save offset from end of file to start of first trailer
7530 20 $fromEnd = $$trailInfo{Offset};
7531 20 undef $trailInfo;
7532 }
7533 23 ▶ if ($$self{LeicaTrailer}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"LeicaTrailer"}) 0 23 23
7534 0 $raf->Seek(0, 2);
7535 0 $$self{LeicaTrailer}{TrailPos} = $pos;
7536 0 $$self{LeicaTrailer}{TrailLen} = $raf->Tell() - $pos - $fromEnd;
7537 0 Image::ExifTool::Panasonic::ProcessLeicaTrailer($self);
7538 }
7539 # finally, dump remaining information in JPEG trailer
7540 23 ▶ if ($verbose or $htmlDump) {
Branch: 1 branch
BranchTrueFalseTotal
if ($verbose or $htmlDump) 1 22 23
Condition66%2/3
$verbose or $htmlDump
l!l&&r!l&&!r
1022
MC/DC50%1/2
$verbose or $htmlDump
$verbose $htmlDump
Truth table66%2/3
A or B
A= $verboseB= $htmlDump
ABresult
1X1
011
000
7541 1 my $endPos = $$self{LeicaTrailerPos};
7542 1 ▶ unless ($endPos) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($endPos) 1 0 1
7543 1 $raf->Seek(0, 2);
7544 1 $endPos = $raf->Tell() - $fromEnd;
7545 }
7546 $self->DumpUnknownTrailer({
7547 1 ▶ RAF => $raf,
Branch: 1 branch
BranchTrueFalseTotal
if $endPos > $pos 0 1 1
7548 DataPos => $pos,
7549 DirLen => $endPos - $pos
7550 }) if $endPos > $pos;
7551 }
7552 23 ▶ $self->FoundTag('JPEGImageLength', $pos - $appBytes) if $calcImageLen;
Branch: 1 branch
BranchTrueFalseTotal
if $calcImageLen 0 23 23
7553 23 last; # all done parsing file
7554 } elsif ($marker == 0xda) { # SOS
7555 247 pop @$path;
7556 247 $foundSOS = 1;
7557 # all done with meta information unless we have a trailer
7558 247 ▶ $verbose and print $out "${indent}JPEG SOS\n";
Branch: 1 branch
BranchTrueFalseTotal
$verbose and print $out "${indent}JPEG SOS\n" 2 245 247
7559 # process extended XMP now if it existed
7560 # (must do this before trailers because XMP is required to process Google trailer)
7561 247 ▶ if (%extendedXMP) {
Branch: 1 branch
BranchTrueFalseTotal
if (%extendedXMP) 2 245 247
7562 2 my $guid;
7563 # GUID indicated by the last main XMP segment
7564 2 ▶ my $goodGuid = $$self{VALUE}{HasExtendedXMP} || '';
Condition50%1/2
$self->{'VALUE'}{'HasExtendedXMP'} || ''
l!l
20
MC/DC0%0/1
$self->{'VALUE'}{'HasExtendedXMP'} || ''
$self->{'VALUE'}{'HasExtendedXMP'}
Truth table50%1/2
A
A= $self->{'VALUE'}{'HasExtendedXMP'}
Aresult
11
00
7565 # GUID of the extended XMP that we will process ('2' for all)
7566 2 ▶ my $readGuid = $$options{ExtendedXMP} || 0;
Condition50%1/2
$options->{'ExtendedXMP'} || 0
l!l
20
MC/DC0%0/1
$options->{'ExtendedXMP'} || 0
$options->{'ExtendedXMP'}
Truth table50%1/2
A
A= $options->{'ExtendedXMP'}
Aresult
11
00
7567 2 ▶ $readGuid = $goodGuid if $readGuid eq '1';
Branch: 1 branch
BranchTrueFalseTotal
if $readGuid eq 1 2 0 2
7568 2 foreach $guid (sort keys %extendedXMP) {
7569 2 ▶ next unless length $guid == 32; # ignore other (internal) keys
Branch: 1 branch
BranchTrueFalseTotal
unless length $guid == 32 0 2 2
7570 2 my $extXMP = $extendedXMP{$guid};
7571 2 my ($off, @offsets, $warn);
7572 # make sure we have all chunks, and create a list of sorted offsets
7573 2 ▶ for ($off=0; $off<$$extXMP{Size}; ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($off < $extXMP->{"Size"}) 3 2 5
7574 3 ▶ last unless defined $$extXMP{$off};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $extXMP->{$off} 0 3 3
7575 3 push @offsets, $off;
7576 3 $off += length $$extXMP{$off};
7577 }
7578 2 ▶ unless ($off == $$extXMP{Size}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($off == $extXMP->{"Size"}) 0 2 2
7579 0 $self->Warn("Incomplete extended XMP (GUID $guid)");
7580 0 next;
7581 }
7582 2 ▶ if ($guid eq $readGuid or $readGuid eq '2') {
Branch: 1 branch
BranchTrueFalseTotal
if ($guid eq $readGuid or $readGuid eq '2') { } 2 0 2
Condition33%1/3
$guid eq $readGuid or $readGuid eq 2
l!l&&r!l&&!r
200
MC/DC0%0/2
$guid eq $readGuid or $readGuid eq 2
$guid eq $readGuid $readGuid eq 2
Truth table33%1/3
A or B
A= $guid eq $readGuidB= $readGuid eq 2
ABresult
1X1
011
000
7583 2 ▶ $warn = 'Reading non-' if $guid ne $goodGuid;
Branch: 1 branch
BranchTrueFalseTotal
if $guid ne $goodGuid 0 2 2
7584 2 my $buff = '';
7585 # assemble XMP all together
7586 2 $buff .= $$extXMP{$_} foreach @offsets;
7587 2 my $tagTablePtr = GetTagTable('Image::ExifTool::XMP::Main');
7588 2 my %dirInfo = (
7589 DataPt => \$buff,
7590 Parent => 'APP1',
7591 IsExtended => 1,
7592 );
7593 2 $$path[$pn] = 'APP1';
7594 2 $self->ProcessDirectory(\%dirInfo, $tagTablePtr);
7595 2 pop @$path;
7596 } else {
7597 0 $warn = 'Ignored ';
7598 0 ▶ $warn .= 'non-' if $guid ne $goodGuid;
Branch: 1 branch
BranchTrueFalseTotal
if $guid ne $goodGuid 0 0 0
7599 }
7600 2 ▶ $self->Warn("${warn}standard extended XMP (GUID $guid)") if $warn;
Branch: 1 branch
BranchTrueFalseTotal
if $warn 0 2 2
7601 2 delete $extendedXMP{$guid};
7602 }
7603 }
7604 247 ▶ unless ($fast) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($fast) 246 1 247
7605 246 $trailInfo = $self->IdentifyTrailer($raf);
7606 # process trailer now unless we are doing verbose dump
7607 246 ▶ if ($trailInfo and $verbose < 3 and not $htmlDump) {
Branch: 1 branch
BranchTrueFalseTotal
if ($trailInfo and $verbose < 3 and not $htmlDump) 29 217 246
Condition66%4/6
$trailInfo and $verbose < 3 and not $htmlDump
!ll&&!rl&&r
217029
$trailInfo and $verbose < 3
!ll&&!rl&&r
217029
MC/DC33%1/3
$trailInfo and $verbose < 3 and not $htmlDump
$trailInfo $verbose < 3 not $htmlDump
Truth table50%2/4
A and B and not(C)
A= $trailInfoB= $verbose < 3C= not $htmlDump
ABCresult
0XX0
10X0
1100
1111
7608 # process trailers (keep trailInfo to finish processing later
7609 # only if we can't finish without scanning from JPEG EOF)
7610 29 ▶ $self->ProcessTrailers($trailInfo) and undef $trailInfo;
Branch: 1 branch
BranchTrueFalseTotal
$self->ProcessTrailers($trailInfo) and undef $trailInfo 9 20 29
7611 }
7612 246 ▶ if ($wantTrailer and $$self{PreviewImageStart}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($wantTrailer and $self->{"PreviewImageStart"}) 0 246 246
Condition33%1/3
$wantTrailer and $self->{"PreviewImageStart"}
!ll&&!rl&&r
24600
MC/DC0%0/2
$wantTrailer and $self->{"PreviewImageStart"}
$wantTrailer $self->{"PreviewImageStart"}
Truth table33%1/3
A and B
A= $wantTrailerB= $self->{"PreviewImageStart"}
ABresult
0X0
100
111
7613 # seek ahead and validate preview image
7614 0 my $buff;
7615 0 my $curPos = $raf->Tell();
7616 0 ▶ if ($raf->Seek($$self{PreviewImageStart}, 0) and
Branch: 1 branch
BranchTrueFalseTotal
if ($raf->Seek($self->{"PreviewImageStart"}, 0) and $raf->Read($buff, 4) == 4 and $buff =~ /^.\xd8\xff[\xc4\xdb\xe0-\xef]/) 0 0 0
Condition0%0/6
$raf->Seek($self->{"PreviewImageStart"}, 0) and $raf->Read($buff, 4) == 4 and $buff =~ /^.\xd8\xff[\xc4\xdb\xe0-\xef]/
!ll&&!rl&&r
000
$raf->Seek($self->{"PreviewImageStart"}, 0) and $raf->Read($buff, 4) == 4
!ll&&!rl&&r
000
MC/DC0%0/3
$raf->Seek($self->{"PreviewImageStart"}, 0) and $raf->Read($buff, 4) == 4 and $buff =~ /^.\xd8\xff[\xc4\xdb\xe0-\xef]/
$raf->Seek($self->{"PreviewImageStart"}, 0) $raf->Read($buff, 4) == 4 $buff =~ /^.\xd8\xff[\xc4\xdb\xe0-\xef]/
Truth table0%0/4
A and B and C
A= $raf->Seek($self->{"PreviewImageStart"}, 0)B= $raf->Read($buff, 4) == 4C= $buff =~ /^.\xd8\xff[\xc4\xdb\xe0-\xef]/
ABCresult
0XX0
10X0
1100
1111
7617 $raf->Read($buff, 4) == 4 and
7618 $buff =~ /^.\xd8\xff[\xc4\xdb\xe0-\xef]/)
7619 {
7620 0 undef $wantTrailer;
7621 }
7622 0 ▶ $raf->Seek($curPos, 0) or last;
Branch: 1 branch
BranchTrueFalseTotal
$raf->Seek($curPos, 0) or last 0 0 0
7623 }
7624 # seek ahead and process Leica trailer
7625 246 ▶ if ($$self{LeicaTrailer}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'LeicaTrailer'}) { } 0 246 246
elsif ($options->{'ExtractEmbedded'} or $self->{'VALUE'}{'HiddenDataOffset'} and $self->{'VALUE'}{'HiddenDataLength'} and $options->{'Validate'} || $req->{'hiddendata'}) { } 0 492 492
7626 0 require Image::ExifTool::Panasonic;
7627 0 Image::ExifTool::Panasonic::ProcessLeicaTrailer($self);
7628 0 ▶ $wantTrailer = 1 if $$self{LeicaTrailer};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"LeicaTrailer"} 0 0 0
7629 ▶ } elsif ($$options{ExtractEmbedded} or ($$self{VALUE}{HiddenDataOffset} and
Condition25%3/12
$options->{"ExtractEmbedded"} or $self->{"VALUE"}{"HiddenDataOffset"} and $self->{"VALUE"}{"HiddenDataLength"} and $options->{"Validate"} || $req->{"hiddendata"}
l!l&&r!l&&!r
00246
$self->{"VALUE"}{"HiddenDataOffset"} and $self->{"VALUE"}{"HiddenDataLength"} and $options->{"Validate"} || $req->{"hiddendata"}
!ll&&!rl&&r
24600
$self->{"VALUE"}{"HiddenDataOffset"} and $self->{"VALUE"}{"HiddenDataLength"}
!ll&&!rl&&r
24600
$options->{"Validate"} or $req->{"hiddendata"}
l!l&&r!l&&!r
000
MC/DC0%0/5
$options->{"ExtractEmbedded"} or $self->{"VALUE"}{"HiddenDataOffset"} and $self->{"VALUE"}{"HiddenDataLength"} and $options->{"Validate"} || $req->{"hiddendata"}
$options->{"ExtractEmbedded"} $self->{"VALUE"}{"HiddenDataOffset"} $self->{"VALUE"}{"HiddenDataLength"} $options->{"Validate"} $req->{"hiddendata"}
Truth table16%1/6
A or B and C and D or E
A= $options->{"ExtractEmbedded"}B= $self->{"VALUE"}{"HiddenDataOffset"}C= $self->{"VALUE"}{"HiddenDataLength"}D= $options->{"Validate"}E= $req->{"hiddendata"}
ABCDEresult
1XXXX1
0111X1
011011
00XXX0
010XX0
011000
7630 $$self{VALUE}{HiddenDataLength} and ($$options{Validate} or $$req{hiddendata})))
7631 {
7632 0 $wantTrailer = 1;
7633 }
7634 246 ▶ next if $trailInfo or $wantTrailer or $verbose > 2 or $htmlDump;
Branch: 1 branch
BranchTrueFalseTotal
if $trailInfo or $wantTrailer or $verbose > 2 or $htmlDump 21 225 246
Condition77%7/9
$trailInfo or $wantTrailer or $verbose > 2 or $htmlDump
l!l&&r!l&&!r
210225
$trailInfo or $wantTrailer or $verbose > 2
l!l&&r!l&&!r
201225
$trailInfo or $wantTrailer
l!l&&r!l&&!r
200226
MC/DC50%2/4
$trailInfo or $wantTrailer or $verbose > 2 or $htmlDump
$trailInfo $wantTrailer $verbose > 2 $htmlDump
Truth table60%3/5
A or B or C or D
A= $trailInfoB= $wantTrailerC= $verbose > 2D= $htmlDump
ABCDresult
1XXX1
01XX1
001X1
00011
00000
7635 }
7636 # must scan to EOI if Validate or JpegCompressionFactor used
7637 226 ▶ next if $$options{Validate} or $calcImageLen or $$req{trailer} or $hash;
Branch: 1 branch
BranchTrueFalseTotal
if $options->{"Validate"} or $calcImageLen or $req->{"trailer"} or $hash 0 226 226
Condition33%3/9
$options->{"Validate"} or $calcImageLen or $req->{"trailer"} or $hash
l!l&&r!l&&!r
00226
$options->{"Validate"} or $calcImageLen or $req->{"trailer"}
l!l&&r!l&&!r
00226
$options->{"Validate"} or $calcImageLen
l!l&&r!l&&!r
00226
MC/DC0%0/4
$options->{"Validate"} or $calcImageLen or $req->{"trailer"} or $hash
$options->{"Validate"} $calcImageLen $req->{"trailer"} $hash
Truth table20%1/5
A or B or C or D
A= $options->{"Validate"}B= $calcImageLenC= $req->{"trailer"}D= $hash
ABCDresult
1XXX1
01XX1
001X1
00011
00000
7638 # nothing interesting to parse after start of scan (SOS)
7639 226 $success = 1;
7640 226 last; # all done parsing file
7641 } elsif ($marker == 0x93) {
7642 1 pop @$path;
7643 1 ▶ $verbose and print $out "${indent}JPEG SOD\n";
Branch: 1 branch
BranchTrueFalseTotal
$verbose and print $out "${indent}JPEG SOD\n" 0 1 1
7644 1 $success = 1;
7645 1 ▶ if ($hash and $$self{FILE_TYPE} eq 'JP2') {
Branch: 1 branch
BranchTrueFalseTotal
if ($hash and $self->{"FILE_TYPE"} eq "JP2") 0 1 1
Condition33%1/3
$hash and $self->{"FILE_TYPE"} eq "JP2"
!ll&&!rl&&r
100
MC/DC0%0/2
$hash and $self->{"FILE_TYPE"} eq "JP2"
$hash $self->{"FILE_TYPE"} eq "JP2"
Truth table33%1/3
A and B
A= $hashB= $self->{"FILE_TYPE"} eq "JP2"
ABresult
0X0
100
111
7646 0 my $pos = $raf->Tell();
7647 0 $self->ImageDataHash($raf, undef, 'SOD');
7648 0 $raf->Seek($pos, 0);
7649 }
7650 1 ▶ next if $verbose > 2 or $htmlDump;
Branch: 1 branch
BranchTrueFalseTotal
if $verbose > 2 or $htmlDump 0 1 1
Condition33%1/3
$verbose > 2 or $htmlDump
l!l&&r!l&&!r
001
MC/DC0%0/2
$verbose > 2 or $htmlDump
$verbose > 2 $htmlDump
Truth table33%1/3
A or B
A= $verbose > 2B= $htmlDump
ABresult
1X1
011
000
7651 1 last; # all done parsing file
7652 } elsif (defined $markerLenBytes{$marker}) {
7653 # handle other stand-alone markers and segments we skipped over
7654 0 ▶ if ($verbose and $marker) {
Branch: 1 branch
BranchTrueFalseTotal
if ($verbose and $marker) 0 0 0
Condition0%0/3
$verbose and $marker
!ll&&!rl&&r
000
MC/DC0%0/2
$verbose and $marker
$verbose $marker
Truth table0%0/3
A and B
A= $verboseB= $marker
ABresult
0X0
100
111
7655 0 ▶ next if $verbose < 4 and ($marker & 0xf8) == 0xd0;
Branch: 1 branch
BranchTrueFalseTotal
if $verbose < 4 and ($marker & 248) == 208 0 0 0
Condition0%0/3
$verbose < 4 and ($marker & 248) == 208
!ll&&!rl&&r
000
MC/DC0%0/2
$verbose < 4 and ($marker & 248) == 208
$verbose < 4 ($marker & 248) == 208
Truth table0%0/3
A and B
A= $verbose < 4B= ($marker & 248) == 208
ABresult
0X0
100
111
7656 0 print $out "${indent}JPEG $markerName\n";
7657 }
7658 0 next;
7659 ▶ } elsif ($marker == 0xdb and length($$segDataPt) and # DQT
Condition73%11/15
$marker == 219 and length $$segDataPt and $req->{"jpegdigest"} || $req->{"jpegqualityestimate"} || $options->{"RequestAll"} && $options->{"RequestAll"} > 2
!ll&&!rl&&r
11802471
$marker == 219 and length $$segDataPt
!ll&&!rl&&r
11800248
$req->{"jpegdigest"} or $req->{"jpegqualityestimate"} or $options->{"RequestAll"} and $options->{"RequestAll"} > 2
l!l&&r!l&&!r
10247
$req->{"jpegdigest"} or $req->{"jpegqualityestimate"}
l!l&&r!l&&!r
10247
$options->{"RequestAll"} and $options->{"RequestAll"} > 2
!ll&&!rl&&r
204430
MC/DC33%2/6
$marker == 219 and length $$segDataPt and $req->{"jpegdigest"} || $req->{"jpegqualityestimate"} || $options->{"RequestAll"} && $options->{"RequestAll"} > 2
$marker == 219 length $$segDataPt $req->{"jpegdigest"} $req->{"jpegqualityestimate"} $options->{"RequestAll"} $options->{"RequestAll"} > 2
Truth table57%4/7
A and B and C or D or E and F
A= $marker == 219B= length $$segDataPtC= $req->{"jpegdigest"}D= $req->{"jpegqualityestimate"}E= $options->{"RequestAll"}F= $options->{"RequestAll"} > 2
ABCDEFresult
0XXXXX0
10XXXX0
11000X0
1100100
111XXX1
1101XX1
1100111
7660 # save the DQT data only if JPEGDigest has been requested
7661 # (Note: since we aren't checking the API RequestAll option here, the application
7662 # must use the RequestTags option to generate these tags if they have not been
7663 # specifically requested. The reason is that there is too much overhead involved
7664 # in the calculation of this tag to make this worth the CPU time.)
7665 ($$req{jpegdigest} or $$req{jpegqualityestimate}
7666 or ($$options{RequestAll} and $$options{RequestAll} > 2)))
7667 {
7668 1 my $num = unpack('C',$$segDataPt) & 0x0f; # get table index
7669 1 ▶ $dqt[$num] = $$segDataPt if $num < 4; # save for hash calculation
Branch: 1 branch
BranchTrueFalseTotal
if $num < 4 1 0 1
7670 }
7671 # handle all other markers
7672 1428 my $dumpType = '';
7673 1428 my ($desc, $tip, $xtra, $useJpegMain);
7674 1428 $length = length $$segDataPt;
7675 1428 ▶ $appBytes += $length + 4 if ($marker & 0xf0) == 0xe0; # total size of APP segments
Branch: 1 branch
BranchTrueFalseTotal
if ($marker & 240) == 224 896 532 1428
7676 1428 ▶ if ($verbose) {
Branch: 1 branch
BranchTrueFalseTotal
if ($verbose) 6 1422 1428
7677 6 print $out "${indent}JPEG $markerName ($length bytes):\n";
7678 6 ▶ if ($verbose > 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($verbose > 2) 3 3 6
7679 3 my %extraParms = ( Addr => $segPos );
7680 3 ▶ $extraParms{MaxLen} = 128 if $verbose == 4;
Branch: 1 branch
BranchTrueFalseTotal
if $verbose == 4 0 3 3
7681 3 HexDump($segDataPt, undef, %dumpParms, %extraParms);
7682 }
7683 }
7684 # prepare dirInfo hash for processing this information
7685 1428 my %dirInfo = (
7686 Parent => $markerName,
7687 DataPt => $segDataPt,
7688 DataPos => $segPos,
7689 DataLen => $length,
7690 DirStart => 0,
7691 DirLen => $length,
7692 Base => 0,
7693 );
7694 1428 ▶ if ($marker == 0xe0) { # APP0 (JFIF, JFXX, CIFF, AVI1, Ocad)
Branch: 20 branches
BranchTrueFalseTotal
if ($marker == 224) { } 108 1320 1428
elsif ($marker == 225) { } 280 1040 1320
elsif ($marker == 226) { } 121 919 1040
elsif ($marker == 227) { } 21 898 919
elsif ($marker == 228) { } 1 897 898
elsif ($marker == 229) { } 21 876 897
elsif ($marker == 230) { } 38 838 876
elsif ($marker == 231) { } 20 818 838
elsif ($marker == 232) { } 20 798 818
elsif ($marker == 233) { } 20 778 798
elsif ($marker == 234) { } 19 759 778
elsif ($marker == 235) { } 38 721 759
elsif ($marker == 236) { } 40 681 721
elsif ($marker == 237) { } 85 596 681
elsif ($marker == 238) { } 45 551 596
elsif ($marker == 239) { } 19 532 551
elsif ($marker == 254) { } 27 505 532
elsif ($marker == 100) { } 2 503 505
elsif ($marker == 81) { } 1 502 503
elsif (($marker & 240) != 224) { } 502 0 502
7695 108 ▶ if ($$segDataPt =~ /^JFIF\0/) {
Branch: 4 branches
BranchTrueFalseTotal
if ($$segDataPt =~ /^JFIF\0/) { } 51 57 108
elsif ($$segDataPt =~ /^JFXX\0(\x10|\x11|\x13)/) { } 19 38 57
elsif ($$segDataPt =~ /^(II|MM).{4}HEAPJPGM/s) { } 19 19 38
elsif ($$segDataPt =~ /^(AVI1|Ocad)/) { } 19 0 19
7696 51 $dumpType = 'JFIF';
7697 51 DirStart(\%dirInfo, 5); # start at byte 5
7698 51 SetByteOrder('MM');
7699 51 my $tagTablePtr = GetTagTable('Image::ExifTool::JFIF::Main');
7700 51 $self->ProcessDirectory(\%dirInfo, $tagTablePtr);
7701 } elsif ($$segDataPt =~ /^JFXX\0(\x10|\x11|\x13)/) {
7702 19 my $tag = ord $1;
7703 19 $dumpType = 'JFXX';
7704 19 my $tagTablePtr = GetTagTable('Image::ExifTool::JFIF::Extension');
7705 19 my $tagInfo = $self->GetTagInfo($tagTablePtr, $tag);
7706 19 $self->FoundTag($tagInfo, substr($$segDataPt, 6));
7707 } elsif ($$segDataPt =~ /^(II|MM).{4}HEAPJPGM/s) {
7708 19 ▶ next if $fast > 1; # skip processing for very fast
Branch: 1 branch
BranchTrueFalseTotal
if $fast > 1 0 19 19
7709 19 $dumpType = 'CIFF';
7710 19 my %dirInfo = ( RAF => File::RandomAccess->new($segDataPt) );
7711 19 $$self{SET_GROUP1} = 'CIFF';
7712 19 push @{$$self{PATH}}, 'CIFF';
7713 19 require Image::ExifTool::CanonRaw;
7714 19 Image::ExifTool::CanonRaw::ProcessCRW($self, \%dirInfo);
7715 19 pop @{$$self{PATH}};
7716 19 delete $$self{SET_GROUP1};
7717 } elsif ($$segDataPt =~ /^(AVI1|Ocad)/) {
7718 19 $dumpType = $1;
7719 19 SetByteOrder('MM');
7720 19 my $tagTablePtr = GetTagTable("Image::ExifTool::JPEG::$dumpType");
7721 19 DirStart(\%dirInfo, 4);
7722 19 $self->ProcessDirectory(\%dirInfo, $tagTablePtr);
7723 }
7724 } elsif ($marker == 0xe1) { # APP1 (EXIF, XMP, QVCI, PARROT)
7725 # (some Kodak cameras don't put a second "\0", and I have seen an
7726 # example where there was a second 4-byte APP1 segment header)
7727 280 ▶ if ($$segDataPt =~ /^(.{0,4})Exif\0./is) {
Branch: 5 branches
BranchTrueFalseTotal
if ($$segDataPt =~ /^(.{0,4})Exif\0./is) { } 203 77 280
elsif ($$segDataPt =~ /^$Image::ExifTool::xmpExtAPP1hdr/) { } 3 74 77
elsif ($$segDataPt =~ /^QVCI\0/) { } 1 73 74
elsif ($$segDataPt =~ /^FLIR\0/ and $length >= 8) { } 1 72 73
elsif ($$segDataPt =~ /^PARROT\0(II\x2a\0|MM\0\x2a)/) { } 0 72 72
7728 203 undef $dumpType; # (will be dumped here)
7729 # this is EXIF data --
7730 # get the data block (into a common variable)
7731 203 my $hdrLen = length($exifAPP1hdr);
7732 203 ▶ if (length $1) {
Branch: 2 branches
BranchTrueFalseTotal
if (length $1) { } 0 203 203
elsif (not $$segDataPt =~ /^Exif\0/) { } 0 203 203
7733 0 $hdrLen += length $1;
7734 0 $self->Warn('Unknown garbage at start of EXIF segment',1);
7735 } elsif ($$segDataPt !~ /^Exif\0/) {
7736 0 $self->Warn('Incorrect EXIF segment identifier',1);
7737 }
7738 203 ▶ if ($htmlDump) {
Branch: 1 branch
BranchTrueFalseTotal
if ($htmlDump) 0 203 203
7739 0 $self->HDump($segPos-4, 4, 'APP1 header', "Data size: $length bytes");
7740 0 $self->HDump($segPos, $hdrLen, 'Exif header', 'APP1 data type: Exif');
7741 0 $dumpEnd = $segPos + $length;
7742 }
7743 203 my $dataPt = $segDataPt;
7744 203 ▶ if (defined $combinedSegData) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $combinedSegData) 0 203 203
7745 0 push @skipData, [ $segPos-4, $segPos+$hdrLen ];
7746 0 $combinedSegData .= substr($$segDataPt,$hdrLen);
7747 0 undef $$segDataPt;
7748 0 $dataPt = \$combinedSegData;
7749 0 $segPos = $firstSegPos;
7750 }
7751 # peek ahead to see if the next segment is extended EXIF
7752 203 ▶ if ($nextMarker == $marker and
Branch: 1 branch
BranchTrueFalseTotal
if ($nextMarker == $marker and $$nextSegDataPt =~ /^$Image::ExifTool::exifAPP1hdr(?!(MM\0\x2a|II\x2a\0))/) 0 203 203
Condition66%2/3
$nextMarker == $marker and $$nextSegDataPt =~ /^$Image::ExifTool::exifAPP1hdr(?!(MM\0\x2a|II\x2a\0))/
!ll&&!rl&&r
180230
MC/DC0%0/2
$nextMarker == $marker and $$nextSegDataPt =~ /^$Image::ExifTool::exifAPP1hdr(?!(MM\0\x2a|II\x2a\0))/
$nextMarker == $marker $$nextSegDataPt =~ /^$Image::ExifTool::exifAPP1hdr(?!(MM\0\x2a|II\x2a\0))/
Truth table66%2/3
A and B
A= $nextMarker == $markerB= $$nextSegDataPt =~ /^$Image::ExifTool::exifAPP1hdr(?!(MM\0\x2a|II\x2a\0))/
ABresult
0X0
100
111
7753 $$nextSegDataPt =~ /^$exifAPP1hdr(?!(MM\0\x2a|II\x2a\0))/)
7754 {
7755 # initialize combined data if necessary
7756 0 ▶ unless (defined $combinedSegData) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $combinedSegData) 0 0 0
7757 0 $combinedSegData = $$segDataPt;
7758 0 undef $$segDataPt;
7759 0 $firstSegPos = $segPos;
7760 0 $self->Warn('File contains multi-segment EXIF',1);
7761 0 $$self{ExtendedEXIF} = 1;
7762 }
7763 0 next;
7764 }
7765 203 $dirInfo{DataPt} = $dataPt;
7766 203 $dirInfo{DataPos} = $segPos;
7767 203 $dirInfo{DataLen} = $dirInfo{DirLen} = length $$dataPt;
7768 203 DirStart(\%dirInfo, $hdrLen, $hdrLen);
7769 203 ▶ $$self{SkipData} = \@skipData if @skipData;
Branch: 1 branch
BranchTrueFalseTotal
if @skipData 0 203 203
7770 # extract the EXIF information (it is in standard TIFF format)
7771 203 ▶ $self->ProcessTIFF(\%dirInfo) or $self->Warn('Malformed APP1 EXIF segment');
Branch: 1 branch
BranchTrueFalseTotal
$self->ProcessTIFF(\%dirInfo) or $self->Warn("Malformed APP1 EXIF segment") 203 0 203
7772 # scan for Vivo HiddenData if necessary
7773 203 ▶ if ($$self{Make} eq 'vivo' and
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"Make"} eq "vivo" and not $self->{"VALUE"}{"UserComment"} && $self->{"VALUE"}{"UserComment"} =~ /^filter:/ and $$dataPt =~ /(filter: .*?; \n)\0/gs) 0 203 203
Condition22%2/9
$self->{"Make"} eq "vivo" and not $self->{"VALUE"}{"UserComment"} && $self->{"VALUE"}{"UserComment"} =~ /^filter:/ and $$dataPt =~ /(filter: .*?; \n)\0/gs
!ll&&!rl&&r
20300
$self->{"Make"} eq "vivo" and not $self->{"VALUE"}{"UserComment"} && $self->{"VALUE"}{"UserComment"} =~ /^filter:/
!ll&&!rl&&r
20300
$self->{'VALUE'}{'UserComment'} && $self->{'VALUE'}{'UserComment'} =~ /^filter:/
!ll&&!rl&&r
000
MC/DC0%0/4
$self->{"Make"} eq "vivo" and not $self->{"VALUE"}{"UserComment"} && $self->{"VALUE"}{"UserComment"} =~ /^filter:/ and $$dataPt =~ /(filter: .*?; \n)\0/gs
$self->{"Make"} eq "vivo" $self->{'VALUE'}{'UserComment'} $self->{'VALUE'}{'UserComment'} =~ /^filter:/ $$dataPt =~ /(filter: .*?; \n)\0/gs
Truth table16%1/6
A and not(B && C) and D
A= $self->{"Make"} eq "vivo"B= $self->{'VALUE'}{'UserComment'}C= $self->{'VALUE'}{'UserComment'} =~ /^filter:/D= $$dataPt =~ /(filter: .*?; \n)\0/gs
ABCDresult
0XXX0
111X0
10X00
11000
10X11
11011
7774 # (stored as UserComment by some models)
7775 not ($$self{VALUE}{UserComment} and $$self{VALUE}{UserComment} =~ /^filter:/) and
7776 $$dataPt =~ /(filter: .*?; \n)\0/sg)
7777 {
7778 0 ▶ if ($htmlDump) {
Branch: 1 branch
BranchTrueFalseTotal
if ($htmlDump) 0 0 0
7779 0 my $n = length($1) + 1;
7780 0 $self->HDump($segPos+pos($$dataPt)-$n, $n, '[Vivo HiddenData]', undef, 0x08);
7781 }
7782 0 my $tbl = GetTagTable('Image::ExifTool::Trailer::Vivo');
7783 0 $self->HandleTag($tbl, HiddenData => $1);
7784 }
7785 # avoid looking for preview unless necessary because it really slows
7786 # us down -- only look for it if we found pointer, and preview is
7787 # outside EXIF, and PreviewImage is specifically requested
7788 203 my $start = $self->GetValue('PreviewImageStart', 'ValueConv');
7789 203 my $plen = $self->GetValue('PreviewImageLength', 'ValueConv');
7790 203 ▶ if (not $start or not $plen and $$self{PreviewError}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $start or not $plen and $self->{"PreviewError"}) 187 16 203
Condition66%4/6
not $start or not $plen and $self->{"PreviewError"}
l!l&&r!l&&!r
187016
not $plen and $self->{"PreviewError"}
!ll&&!rl&&r
1240
MC/DC33%1/3
not $start or not $plen and $self->{"PreviewError"}
not $start not $plen $self->{"PreviewError"}
Truth table75%3/4
not(A) or not(B) and C
A= not $startB= not $plenC= $self->{"PreviewError"}
ABCresult
1XX1
0111
00X0
0100
7791 187 $start = $$self{PreviewImageStart};
7792 187 $plen = $$self{PreviewImageLength};
7793 }
7794 203 ▶ if ($start and $plen and IsInt($start) and IsInt($plen) and
Branch: 1 branch
BranchTrueFalseTotal
if ($start and $plen and &IsInt($start) and &IsInt($plen) and $start + $plen > $self->{"EXIF_POS"} + length($self->{"EXIF_DATA"}) and $req->{"previewimage"} || $options->{"Binary"} && !$self->{"EXCL_TAG_LOOKUP"}{"previewimage"}) 0 203 203
Condition47%10/21
$start and $plen and &IsInt($start) and &IsInt($plen) and $start + $plen > $self->{"EXIF_POS"} + length($self->{"EXIF_DATA"}) and $req->{"previewimage"} || $options->{"Binary"} && !$self->{"EXCL_TAG_LOOKUP"}{"previewimage"}
!ll&&!rl&&r
20300
$start and $plen and &IsInt($start) and &IsInt($plen) and $start + $plen > $self->{"EXIF_POS"} + length($self->{"EXIF_DATA"})
!ll&&!rl&&r
191120
$start and $plen and &IsInt($start) and &IsInt($plen)
!ll&&!rl&&r
191012
$start and $plen and &IsInt($start)
!ll&&!rl&&r
191012
$start and $plen
!ll&&!rl&&r
187412
$req->{"previewimage"} or $options->{"Binary"} and not $self->{"EXCL_TAG_LOOKUP"}{"previewimage"}
l!l&&r!l&&!r
000
$options->{"Binary"} and not $self->{"EXCL_TAG_LOOKUP"}{"previewimage"}
!ll&&!rl&&r
000
MC/DC0%0/8
$start and $plen and &IsInt($start) and &IsInt($plen) and $start + $plen > $self->{"EXIF_POS"} + length($self->{"EXIF_DATA"}) and $req->{"previewimage"} || $options->{"Binary"} && !$self->{"EXCL_TAG_LOOKUP"}{"previewimage"}
$start $plen &IsInt($start) &IsInt($plen) $start + $plen > $self->{"EXIF_POS"} + length($self->{"EXIF_DATA"}) $req->{"previewimage"} $options->{"Binary"} not $self->{"EXCL_TAG_LOOKUP"}{"previewimage"}
Truth table33%3/9
A and B and C and D and E and F or G and not(H)
A= $startB= $plenC= &IsInt($start)D= &IsInt($plen)E= $start + $plen > $self->{"EXIF_POS"} + length($self->{"EXIF_DATA"})F= $req->{"previewimage"}G= $options->{"Binary"}H= not $self->{"EXCL_TAG_LOOKUP"}{"previewimage"}
ABCDEFGHresult
0XXXXXXX0
10XXXXXX0
110XXXXX0
1110XXXX0
11110XXX0
1111100X0
111110100
111111XX1
111110111
7795 $start + $plen > $$self{EXIF_POS} + length($$self{EXIF_DATA}) and
7796 ($$req{previewimage} or
7797 # (extracted normally, so check Binary option)
7798 ($$options{Binary} and not $$self{EXCL_TAG_LOOKUP}{previewimage})))
7799 {
7800 0 $$self{PreviewImageStart} = $start;
7801 0 $$self{PreviewImageLength} = $plen;
7802 0 $wantTrailer = 1;
7803 }
7804 203 ▶ if (@skipData) {
Branch: 1 branch
BranchTrueFalseTotal
if (@skipData) 0 203 203
7805 0 undef @skipData;
7806 0 delete $$self{SkipData};
7807 }
7808 203 undef $$dataPt;
7809 203 next;
7810 } elsif ($$segDataPt =~ /^$xmpExtAPP1hdr/) {
7811 # off len -- extended XMP header (75 bytes total):
7812 # 0 35 bytes - signature
7813 # 35 32 bytes - GUID (MD5 hash of full extended XMP data in ASCII)
7814 # 67 4 bytes - total size of extended XMP data
7815 # 71 4 bytes - offset for this XMP data portion
7816 3 $dumpType = 'Extended XMP';
7817 3 ▶ if ($length > 75) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length > 75) { } 3 0 3
7818 3 my ($size, $off) = unpack('x67N2', $$segDataPt);
7819 3 my $guid = substr($$segDataPt, 35, 32);
7820 3 ▶ if ($guid =~ /[^A-Za-z0-9]/) { # (technically, should be uppercase)
Branch: 1 branch
BranchTrueFalseTotal
if ($guid =~ /[^A-Za-z0-9]/) { } 0 3 3
7821 0 $self->Warn($tip = 'Invalid extended XMP GUID');
7822 } else {
7823 3 my $extXMP = $extendedXMP{$guid};
7824 3 ▶ if (not $extXMP) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $extXMP) { } 2 1 3
elsif ($size != $extXMP->{'Size'}) { } 0 1 1
7825 2 $extXMP = $extendedXMP{$guid} = { };
7826 } elsif ($size != $$extXMP{Size}) {
7827 0 $self->Warn('Inconsistent extended XMP size');
7828 }
7829 3 $$extXMP{Size} = $size;
7830 3 $$extXMP{$off} = substr($$segDataPt, 75);
7831 3 $tip = "Full length: $size\nChunk offset: $off\nChunk length: " .
7832 ($length - 75) . "\nGUID: $guid";
7833 # (delay processing extended XMP until after reading all segments)
7834 }
7835 } else {
7836 0 $self->Warn($tip = 'Invalid extended XMP segment');
7837 }
7838 } elsif ($$segDataPt =~ /^QVCI\0/) {
7839 1 $dumpType = 'QVCI';
7840 1 my $tagTablePtr = GetTagTable('Image::ExifTool::Casio::QVCI');
7841 1 $self->ProcessDirectory(\%dirInfo, $tagTablePtr);
7842 ▶ } elsif ($$segDataPt =~ /^FLIR\0/ and $length >= 8) {
Condition66%2/3
$$segDataPt =~ /^FLIR\0/ and $length >= 8
!ll&&!rl&&r
7201
MC/DC50%1/2
$$segDataPt =~ /^FLIR\0/ and $length >= 8
$$segDataPt =~ /^FLIR\0/ $length >= 8
Truth table66%2/3
A and B
A= $$segDataPt =~ /^FLIR\0/B= $length >= 8
ABresult
0X0
100
111
7843 1 $dumpType = 'FLIR';
7844 # must concatenate FLIR chunks (note: handle the case where
7845 # some software erroneously writes zeros for the chunk counts)
7846 1 my $chunkNum = Get8u($segDataPt, 6);
7847 1 my $chunksTot = Get8u($segDataPt, 7) + 1; # (note the "+ 1"!)
7848 1 ▶ $verbose and printf $out "${indent}FLIR chunk %d of %d\n",
Branch: 1 branch
BranchTrueFalseTotal
$verbose and printf $out "${indent}FLIR chunk %d of %d\n", $chunkNum + 1, $chunksTot 0 1 1
7849 $chunkNum + 1, $chunksTot;
7850 1 ▶ if (defined $flirTotal) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $flirTotal) { } 0 1 1
7851 # abort parsing FLIR if the total chunk count is inconsistent
7852 0 ▶ undef $flirCount if $chunksTot != $flirTotal;
Branch: 1 branch
BranchTrueFalseTotal
if $chunksTot != $flirTotal 0 0 0
7853 } else {
7854 1 $flirCount = 0;
7855 1 $flirTotal = $chunksTot;
7856 }
7857 1 ▶ if (defined $flirCount) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $flirCount) { } 1 0 1
7858 1 ▶ if (defined $flirChunk[$chunkNum]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $flirChunk[$chunkNum]) { } 0 1 1
7859 0 $self->Warn('Duplicate FLIR chunk number(s)');
7860 0 $flirChunk[$chunkNum] .= substr($$segDataPt, 8);
7861 } else {
7862 1 $flirChunk[$chunkNum] = substr($$segDataPt, 8);
7863 }
7864 # process the FLIR information if we have all of the chunks
7865 1 ▶ if (++$flirCount >= $flirTotal) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$flirCount >= $flirTotal) 1 0 1
7866 1 my $flir = '';
7867 1 ▶ defined $_ and $flir .= $_ foreach @flirChunk;
Branch: 1 branch
BranchTrueFalseTotal
defined $_ and $flir .= $_ 1 0 1
7868 1 undef @flirChunk; # free memory
7869 1 my $tagTablePtr = GetTagTable('Image::ExifTool::FLIR::FFF');
7870 1 my %dirInfo = (
7871 DataPt => \$flir,
7872 Parent => $markerName,
7873 DirName => 'FLIR',
7874 );
7875 1 $self->ProcessDirectory(\%dirInfo, $tagTablePtr);
7876 1 undef $flirCount; # prevent reprocessing
7877 }
7878 } else {
7879 0 $self->Warn('Invalid or extraneous FLIR chunk(s)');
7880 }
7881 } elsif ($$segDataPt =~ /^PARROT\0(II\x2a\0|MM\0\x2a)/) {
7882 # (don't know if this could span multiple segments)
7883 0 my $tagTablePtr = GetTagTable('Image::ExifTool::JPEG::Main');
7884 0 $self->HandleTag($tagTablePtr, 'APP1', $$segDataPt);
7885 0 $dumpType = 'Parrot';
7886 } else {
7887 # Hmmm. Could be XMP, let's see
7888 72 my $processed;
7889 72 ▶ if ($$segDataPt =~ /^(http|XMP\0)/ or $$segDataPt =~ /<(exif:|\?xpacket)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$segDataPt =~ /^(http|XMP\0)/ or $$segDataPt =~ /<(exif:|\?xpacket)/) 72 0 72
Condition33%1/3
$$segDataPt =~ /^(http|XMP\0)/ or $$segDataPt =~ /<(exif:|\?xpacket)/
l!l&&r!l&&!r
7200
MC/DC0%0/2
$$segDataPt =~ /^(http|XMP\0)/ or $$segDataPt =~ /<(exif:|\?xpacket)/
$$segDataPt =~ /^(http|XMP\0)/ $$segDataPt =~ /<(exif:|\?xpacket)/
Truth table33%1/3
A or B
A= $$segDataPt =~ /^(http|XMP\0)/B= $$segDataPt =~ /<(exif:|\?xpacket)/
ABresult
1X1
011
000
7890 72 $dumpType = 'XMP';
7891 # also try to parse XMP with a non-standard header
7892 # (note: this non-standard XMP is ignored when writing)
7893 72 ▶ my $start = ($$segDataPt =~ /^$xmpAPP1hdr/) ? length($xmpAPP1hdr) : 0;
Branch: 1 branch
BranchTrueFalseTotal
$$segDataPt =~ /^$Image::ExifTool::xmpAPP1hdr/ ? : 72 0 72
7894 72 my $tagTablePtr = GetTagTable('Image::ExifTool::XMP::Main');
7895 72 DirStart(\%dirInfo, $start);
7896 72 ▶ $dirInfo{DirName} = $start ? 'XMP' : 'XML',
Branch: 1 branch
BranchTrueFalseTotal
$start ? : 72 0 72
7897 $processed = $self->ProcessDirectory(\%dirInfo, $tagTablePtr);
7898 72 ▶ if ($processed and not $start) {
Branch: 1 branch
BranchTrueFalseTotal
if ($processed and not $start) 0 72 72
Condition33%1/3
$processed and not $start
!ll&&!rl&&r
0720
MC/DC0%0/2
$processed and not $start
$processed not $start
Truth table33%1/3
A and not(B)
A= $processedB= not $start
ABresult
0X0
100
111
7899 0 $self->Warn('Non-standard header for APP1 XMP segment');
7900 }
7901 }
7902 72 ▶ if ($verbose and not $processed) {
Branch: 1 branch
BranchTrueFalseTotal
if ($verbose and not $processed) 0 72 72
Condition33%1/3
$verbose and not $processed
!ll&&!rl&&r
7200
MC/DC0%0/2
$verbose and not $processed
$verbose not $processed
Truth table33%1/3
A and not(B)
A= $verboseB= not $processed
ABresult
0X0
100
111
7903 0 $self->Warn("Ignored APP1 segment length $length (unknown header)");
7904 }
7905 }
7906 } elsif ($marker == 0xe2) { # APP2 (ICC Profile, FPXR, MPF, InfiRay, URN, PreviewImage)
7907 121 ▶ if ($$segDataPt =~ /^ICC_PROFILE\0/ and $length >= 14) {
Branch: 7 branches
BranchTrueFalseTotal
if ($$segDataPt =~ /^ICC_PROFILE\0/ and $length >= 14) { } 34 87 121
elsif ($$segDataPt =~ /^FPXR\0/) { } 67 20 87
elsif ($$segDataPt =~ /^MPF\0/) { } 19 1 20
elsif ($$segDataPt =~ /^....IJPEG\0/s) { } 1 0 1
elsif ($$segDataPt =~ /^(|QVGA\0|BGTH)\xff\xd8\xff[\xdb\xe0\xe1]/) { } 0 0 0
elsif ($$segDataPt =~ /^urn:/) { } 0 0 0
elsif ($preview) { } 0 0 0
Condition66%2/3
$$segDataPt =~ /^ICC_PROFILE\0/ and $length >= 14
!ll&&!rl&&r
87034
MC/DC50%1/2
$$segDataPt =~ /^ICC_PROFILE\0/ and $length >= 14
$$segDataPt =~ /^ICC_PROFILE\0/ $length >= 14
Truth table66%2/3
A and B
A= $$segDataPt =~ /^ICC_PROFILE\0/B= $length >= 14
ABresult
0X0
100
111
7908 34 $dumpType = 'ICC_Profile';
7909 # must concatenate profile chunks (note: handle the case where
7910 # some software erroneously writes zeros for the chunk counts)
7911 34 my $chunkNum = Get8u($segDataPt, 12);
7912 34 my $chunksTot = Get8u($segDataPt, 13);
7913 34 ▶ $verbose and print $out "${indent}ICC_Profile chunk $chunkNum of $chunksTot\n";
Branch: 1 branch
BranchTrueFalseTotal
$verbose and print $out "${indent}ICC_Profile chunk $chunkNum of $chunksTot\n" 0 34 34
7914 34 ▶ if (defined $iccChunksTotal) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $iccChunksTotal) { } 0 34 34
7915 # abort parsing ICC_Profile if the total chunk count is inconsistent
7916 0 ▶ undef $iccChunkCount if $chunksTot != $iccChunksTotal;
Branch: 1 branch
BranchTrueFalseTotal
if $chunksTot != $iccChunksTotal 0 0 0
7917 } else {
7918 34 $iccChunkCount = 0;
7919 34 $iccChunksTotal = $chunksTot;
7920 34 ▶ $self->Warn('ICC_Profile chunk count is zero') if !$chunksTot;
Branch: 1 branch
BranchTrueFalseTotal
unless $chunksTot 0 34 34
7921 }
7922 34 ▶ if (defined $iccChunkCount) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $iccChunkCount) { } 34 0 34
7923 34 ▶ if (defined $iccChunk[$chunkNum]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $iccChunk[$chunkNum]) { } 0 34 34
7924 0 $self->Warn('Duplicate ICC_Profile chunk number(s)');
7925 0 $iccChunk[$chunkNum] .= substr($$segDataPt, 14);
7926 } else {
7927 34 $iccChunk[$chunkNum] = substr($$segDataPt, 14);
7928 }
7929 # process profile if we have all of the chunks
7930 34 ▶ if (++$iccChunkCount >= $iccChunksTotal) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$iccChunkCount >= $iccChunksTotal) 34 0 34
7931 34 my $icc_profile = '';
7932 34 ▶ defined $_ and $icc_profile .= $_ foreach @iccChunk;
Branch: 1 branch
BranchTrueFalseTotal
defined $_ and $icc_profile .= $_ 34 34 68
7933 34 undef @iccChunk; # free memory
7934 34 my $tagTablePtr = GetTagTable('Image::ExifTool::ICC_Profile::Main');
7935 34 my %dirInfo = (
7936 DataPt => \$icc_profile,
7937 DataPos => $segPos + 14,
7938 DataLen => length($icc_profile),
7939 DirStart => 0,
7940 DirLen => length($icc_profile),
7941 Parent => $markerName,
7942 );
7943 34 $self->ProcessDirectory(\%dirInfo, $tagTablePtr);
7944 34 undef $iccChunkCount; # prevent reprocessing
7945 }
7946 } else {
7947 0 $self->Warn('Invalid or extraneous ICC_Profile chunk(s)');
7948 }
7949 } elsif ($$segDataPt =~ /^FPXR\0/) {
7950 67 ▶ next if $fast > 1; # skip processing for very fast
Branch: 1 branch
BranchTrueFalseTotal
if $fast > 1 0 67 67
7951 67 $dumpType = 'FPXR';
7952 67 my $tagTablePtr = GetTagTable('Image::ExifTool::FlashPix::Main');
7953 # set flag if this is the last FPXR segment
7954 67 ▶ $dirInfo{LastFPXR} = not ($nextMarker==$marker and $$nextSegDataPt=~/^FPXR\0/),
Condition100%3/3
$nextMarker == $marker && $$nextSegDataPt =~ /^FPXR\0/
!ll&&!rl&&r
21946
MC/DC100%2/2
$nextMarker == $marker && $$nextSegDataPt =~ /^FPXR\0/
$nextMarker == $marker $$nextSegDataPt =~ /^FPXR\0/
Truth table100%3/3
A && B
A= $nextMarker == $markerB= $$nextSegDataPt =~ /^FPXR\0/
ABresult
0X0
100
111
7955 $self->ProcessDirectory(\%dirInfo, $tagTablePtr);
7956 } elsif ($$segDataPt =~ /^MPF\0/) {
7957 19 undef $dumpType; # (will be dumped here)
7958 19 DirStart(\%dirInfo, 4, 4);
7959 19 $dirInfo{Multi} = 1; # the MP Attribute IFD will be MPF1
7960 19 ▶ if ($htmlDump) {
Branch: 1 branch
BranchTrueFalseTotal
if ($htmlDump) 0 19 19
7961 0 $self->HDump($segPos-4, 4, 'APP2 header', "Data size: $length bytes");
7962 0 $self->HDump($segPos, 4, 'MPF header', 'APP2 data type: MPF');
7963 0 $dumpEnd = $segPos + $length;
7964 }
7965 # extract the MPF information (it is in standard TIFF format)
7966 19 my $tagTablePtr = GetTagTable('Image::ExifTool::MPF::Main');
7967 19 $self->ProcessTIFF(\%dirInfo, $tagTablePtr);
7968 } elsif ($$segDataPt =~ /^....IJPEG\0/s) {
7969 1 $dumpType = 'InfiRay Version';
7970 1 $$self{HasIJPEG} = 1;
7971 1 SetByteOrder('II');
7972 1 my $tagTablePtr = GetTagTable('Image::ExifTool::InfiRay::Version');
7973 1 $self->ProcessDirectory(\%dirInfo, $tagTablePtr);
7974 } elsif ($$segDataPt =~ /^(|QVGA\0|BGTH)\xff\xd8\xff[\xdb\xe0\xe1]/) {
7975 # Samsung/GE/GoPro="", BenQ DC C1220/Pentacon/Polaroid="QVGA\0",
7976 # Digilife DDC-690/Rollei="BGTH"
7977 0 $dumpType = 'Preview Image';
7978 0 $preview = substr($$segDataPt, length($1));
7979 } elsif ($$segDataPt =~ /^urn:/) { # (found in Apple HDR images)
7980 0 $dumpType = 'URN';
7981 0 $useJpegMain = 1;
7982 } elsif ($preview) {
7983 0 $dumpType = 'Preview Image';
7984 0 $preview .= $$segDataPt;
7985 }
7986 121 ▶ if ($preview and $nextMarker ne $marker) {
Branch: 1 branch
BranchTrueFalseTotal
if ($preview and $nextMarker ne $marker) 0 121 121
Condition33%1/3
$preview and $nextMarker ne $marker
!ll&&!rl&&r
12100
MC/DC0%0/2
$preview and $nextMarker ne $marker
$preview $nextMarker ne $marker
Truth table33%1/3
A and B
A= $previewB= $nextMarker ne $marker
ABresult
0X0
100
111
7987 0 $self->FoundTag('PreviewImage', $preview);
7988 0 undef $preview;
7989 }
7990 } elsif ($marker == 0xe3) { # APP3 (Kodak "Meta", Stim)
7991 21 ▶ if ($$segDataPt =~ /^(Meta|META|Exif)\0\0/) {
Branch: 5 branches
BranchTrueFalseTotal
if ($$segDataPt =~ /^(Meta|META|Exif)\0\0/) { } 19 2 21
elsif ($$segDataPt =~ /^Stim\0/) { } 0 2 2
elsif ($$segDataPt =~ /^_JPSJPS_/) { } 1 1 2
elsif ($self->{'HasIJPEG'} or $self->{'Make'} eq 'DJI') { } 1 0 1
elsif ($$segDataPt =~ /^\xff\xd8\xff\xdb/) { } 0 0 0
7992 19 undef $dumpType; # (will be dumped here)
7993 19 DirStart(\%dirInfo, 6, 6);
7994 19 ▶ if ($htmlDump) {
Branch: 1 branch
BranchTrueFalseTotal
if ($htmlDump) 0 19 19
7995 0 $self->HDump($segPos-4, 10, 'APP3 Meta header');
7996 0 $dumpEnd = $segPos + $length;
7997 }
7998 19 my $tagTablePtr = GetTagTable('Image::ExifTool::Kodak::Meta');
7999 19 $self->ProcessTIFF(\%dirInfo, $tagTablePtr);
8000 } elsif ($$segDataPt =~ /^Stim\0/) {
8001 0 undef $dumpType; # (will be dumped here)
8002 0 DirStart(\%dirInfo, 6, 6);
8003 0 ▶ if ($htmlDump) {
Branch: 1 branch
BranchTrueFalseTotal
if ($htmlDump) 0 0 0
8004 0 $self->HDump($segPos-4, 4, 'APP3 header', "Data size: $length bytes");
8005 0 $self->HDump($segPos, 5, 'Stim header', 'APP3 data type: Stim');
8006 0 $dumpEnd = $segPos + $length;
8007 }
8008 # extract the Stim information (it is in standard TIFF format)
8009 0 my $tagTablePtr = GetTagTable('Image::ExifTool::Stim::Main');
8010 0 $self->ProcessTIFF(\%dirInfo, $tagTablePtr);
8011 } elsif ($$segDataPt =~ /^_JPSJPS_/) {
8012 1 $dumpType = 'JPS';
8013 1 ▶ $self->OverrideFileType('JPS') if $$self{FILE_TYPE} eq 'JPEG';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"FILE_TYPE"} eq "JPEG" 1 0 1
8014 1 SetByteOrder('MM');
8015 1 my $tagTablePtr = GetTagTable('Image::ExifTool::JPEG::JPS');
8016 1 $self->ProcessDirectory(\%dirInfo, $tagTablePtr);
8017 ▶ } elsif ($$self{HasIJPEG} or $$self{Make} eq 'DJI') {
Condition33%1/3
$self->{"HasIJPEG"} or $self->{"Make"} eq "DJI"
l!l&&r!l&&!r
100
MC/DC0%0/2
$self->{"HasIJPEG"} or $self->{"Make"} eq "DJI"
$self->{"HasIJPEG"} $self->{"Make"} eq "DJI"
Truth table33%1/3
A or B
A= $self->{"HasIJPEG"}B= $self->{"Make"} eq "DJI"
ABresult
1X1
011
000
8018 1 ▶ $dumpType = $$self{HasIJPEG} ? 'InfiRay ImagingData' : 'DJI ThermalData';
Branch: 1 branch
BranchTrueFalseTotal
$self->{'HasIJPEG'} ? : 1 0 1
8019 # add this data to the combined data if it exists
8020 1 my $dataPt = $segDataPt;
8021 1 ▶ if (defined $combinedSegData) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $combinedSegData) 0 1 1
8022 0 $combinedSegData .= $$segDataPt;
8023 0 $dataPt = \$combinedSegData;
8024 }
8025 1 ▶ if ($nextMarker == $marker) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nextMarker == $marker) { } 0 1 1
8026 0 ▶ $combinedSegData = $$segDataPt unless defined $combinedSegData;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $combinedSegData 0 0 0
8027 } else {
8028 # process InfiRay/DJI thermal data
8029 1 my $tagTablePtr = GetTagTable('Image::ExifTool::JPEG::Main');
8030 1 $self->HandleTag($tagTablePtr, 'APP3', $$dataPt);
8031 1 undef $combinedSegData;
8032 }
8033 } elsif ($$segDataPt =~ /^\xff\xd8\xff\xdb/) {
8034 0 $dumpType = 'PreviewImage'; # (Samsung, HP, BenQ)
8035 0 $preview = $$segDataPt;
8036 }
8037 21 ▶ if ($preview and $nextMarker ne 0xe4) { # this preview continues in APP4
Branch: 1 branch
BranchTrueFalseTotal
if ($preview and $nextMarker ne 228) 0 21 21
Condition33%1/3
$preview and $nextMarker ne 228
!ll&&!rl&&r
2100
MC/DC0%0/2
$preview and $nextMarker ne 228
$preview $nextMarker ne 228
Truth table33%1/3
A and B
A= $previewB= $nextMarker ne 228
ABresult
0X0
100
111
8038 0 $self->FoundTag('PreviewImage', $preview);
8039 0 undef $preview;
8040 }
8041 } elsif ($marker == 0xe4) { # APP4 (InfiRay, "SCALADO", FPXR, DJI, PreviewImage)
8042 1 ▶ if ($$segDataPt =~ /^SCALADO\0/ and $length >= 16) {
Branch: 8 branches
BranchTrueFalseTotal
if ($$segDataPt =~ /^SCALADO\0/ and $length >= 16) { } 0 1 1
elsif ($$segDataPt =~ /^Qualcomm Dual Camera Attributes/) { } 0 1 1
elsif ($$segDataPt =~ /^FPXR\0/) { } 0 1 1
elsif ($self->{'Make'} eq 'DJI' and $$segDataPt =~ /^\xaa\x55\x12\x06/) { } 0 1 1
elsif ($self->{'Make'} eq 'DJI' and $$segDataPt =~ /^(.{32})?.{32}\x2c\x01\x20\0/s) { } 0 1 1
elsif ($self->{'Make'} eq 'DJI' and $$segDataPt =~ /^.{32}\xaa\x55\x38\0/s) { } 0 1 1
elsif ($self->{'HasIJPEG'} and $length >= 120) { } 1 0 1
elsif ($preview) { } 0 0 0
Condition33%1/3
$$segDataPt =~ /^SCALADO\0/ and $length >= 16
!ll&&!rl&&r
100
MC/DC0%0/2
$$segDataPt =~ /^SCALADO\0/ and $length >= 16
$$segDataPt =~ /^SCALADO\0/ $length >= 16
Truth table33%1/3
A and B
A= $$segDataPt =~ /^SCALADO\0/B= $length >= 16
ABresult
0X0
100
111
8043 0 $dumpType = 'SCALADO';
8044 0 my ($num, $idx, $len) = unpack('x8n2N', $$segDataPt);
8045 # assume that the segments are in order and just concatinate them
8046 0 ▶ $scalado = '' unless defined $scalado;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $scalado 0 0 0
8047 0 $scalado .= substr($$segDataPt, 16);
8048 0 ▶ if ($idx == $num - 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($idx == $num - 1) 0 0 0
8049 0 ▶ if ($len != length $scalado) {
Branch: 1 branch
BranchTrueFalseTotal
if ($len != length $scalado) 0 0 0
8050 0 $self->Warn('Possibly corrupted APP4 SCALADO data', 1);
8051 }
8052 0 my %dirInfo = (
8053 Parent => $markerName,
8054 DataPt => \$scalado,
8055 );
8056 0 my $tagTablePtr = GetTagTable('Image::ExifTool::Scalado::Main');
8057 0 $self->ProcessDirectory(\%dirInfo, $tagTablePtr);
8058 0 undef $scalado;
8059 }
8060 } elsif ($$segDataPt =~ /^Qualcomm Dual Camera Attributes/) {
8061 0 $dumpType = 'Qualcomm Dual Camera';
8062 0 my $tagTablePtr = GetTagTable('Image::ExifTool::Qualcomm::DualCamera');
8063 0 DirStart(\%dirInfo, 31);
8064 0 $dirInfo{DirName} = 'Qualcomm Dual Camera';
8065 0 $self->ProcessDirectory(\%dirInfo, $tagTablePtr);
8066 } elsif ($$segDataPt =~ /^FPXR\0/) {
8067 0 ▶ next if $fast > 1; # skip processing for very fast
Branch: 1 branch
BranchTrueFalseTotal
if $fast > 1 0 0 0
8068 0 $dumpType = 'FPXR';
8069 0 my $tagTablePtr = GetTagTable('Image::ExifTool::FlashPix::Main');
8070 # set flag if this is the last FPXR segment
8071 0 ▶ $dirInfo{LastFPXR} = not ($nextMarker==$marker and $$nextSegDataPt=~/^FPXR\0/),
Condition0%0/3
$nextMarker == $marker && $$nextSegDataPt =~ /^FPXR\0/
!ll&&!rl&&r
000
MC/DC0%0/2
$nextMarker == $marker && $$nextSegDataPt =~ /^FPXR\0/
$nextMarker == $marker $$nextSegDataPt =~ /^FPXR\0/
Truth table0%0/3
A && B
A= $nextMarker == $markerB= $$nextSegDataPt =~ /^FPXR\0/
ABresult
0X0
100
111
8072 $self->ProcessDirectory(\%dirInfo, $tagTablePtr);
8073 ▶ } elsif ($$self{Make} eq 'DJI' and $$segDataPt =~ /^\xaa\x55\x12\x06/) {
Condition33%1/3
$self->{"Make"} eq "DJI" and $$segDataPt =~ /^\xaa\x55\x12\x06/
!ll&&!rl&&r
100
MC/DC0%0/2
$self->{"Make"} eq "DJI" and $$segDataPt =~ /^\xaa\x55\x12\x06/
$self->{"Make"} eq "DJI" $$segDataPt =~ /^\xaa\x55\x12\x06/
Truth table33%1/3
A and B
A= $self->{"Make"} eq "DJI"B= $$segDataPt =~ /^\xaa\x55\x12\x06/
ABresult
0X0
100
111
8074 0 $dumpType = 'DJI ThermalParams';
8075 0 DirStart(\%dirInfo, 0, 0);
8076 0 my $tagTablePtr = GetTagTable('Image::ExifTool::DJI::ThermalParams');
8077 0 $self->ProcessDirectory(\%dirInfo, $tagTablePtr);
8078 ▶ } elsif ($$self{Make} eq 'DJI' and $$segDataPt =~ /^(.{32})?.{32}\x2c\x01\x20\0/s) {
Condition33%1/3
$self->{"Make"} eq "DJI" and $$segDataPt =~ /^(.{32})?.{32}\x2c\x01\x20\0/s
!ll&&!rl&&r
100
MC/DC0%0/2
$self->{"Make"} eq "DJI" and $$segDataPt =~ /^(.{32})?.{32}\x2c\x01\x20\0/s
$self->{"Make"} eq "DJI" $$segDataPt =~ /^(.{32})?.{32}\x2c\x01\x20\0/s
Truth table33%1/3
A and B
A= $self->{"Make"} eq "DJI"B= $$segDataPt =~ /^(.{32})?.{32}\x2c\x01\x20\0/s
ABresult
0X0
100
111
8079 0 $dumpType = 'DJI ThermalParams2';
8080 0 ▶ DirStart(\%dirInfo, $1 ? 32 : 0, 0);
Branch: 1 branch
BranchTrueFalseTotal
$1 ? : 0 0 0
8081 0 my $tagTablePtr = GetTagTable('Image::ExifTool::DJI::ThermalParams2');
8082 0 $self->ProcessDirectory(\%dirInfo, $tagTablePtr);
8083 ▶ } elsif ($$self{Make} eq 'DJI' and $$segDataPt =~ /^.{32}\xaa\x55\x38\0/s) {
Condition33%1/3
$self->{"Make"} eq "DJI" and $$segDataPt =~ /^.{32}\xaa\x55\x38\0/s
!ll&&!rl&&r
100
MC/DC0%0/2
$self->{"Make"} eq "DJI" and $$segDataPt =~ /^.{32}\xaa\x55\x38\0/s
$self->{"Make"} eq "DJI" $$segDataPt =~ /^.{32}\xaa\x55\x38\0/s
Truth table33%1/3
A and B
A= $self->{"Make"} eq "DJI"B= $$segDataPt =~ /^.{32}\xaa\x55\x38\0/s
ABresult
0X0
100
111
8084 0 $dumpType = 'DJI ThermalParams3';
8085 0 DirStart(\%dirInfo, 32, 0);
8086 0 my $tagTablePtr = GetTagTable('Image::ExifTool::DJI::ThermalParams3');
8087 0 $self->ProcessDirectory(\%dirInfo, $tagTablePtr);
8088 ▶ } elsif ($$self{HasIJPEG} and $length >= 120) {
Condition33%1/3
$self->{"HasIJPEG"} and $length >= 120
!ll&&!rl&&r
001
MC/DC0%0/2
$self->{"HasIJPEG"} and $length >= 120
$self->{"HasIJPEG"} $length >= 120
Truth table33%1/3
A and B
A= $self->{"HasIJPEG"}B= $length >= 120
ABresult
0X0
100
111
8089 1 $dumpType = 'InfiRay Factory';
8090 1 SetByteOrder('II');
8091 1 my $tagTablePtr = GetTagTable('Image::ExifTool::InfiRay::Factory');
8092 1 $self->ProcessDirectory(\%dirInfo, $tagTablePtr);
8093 } elsif ($preview) {
8094 # continued Samsung S1060 preview from APP3
8095 0 $dumpType = 'PreviewImage';
8096 0 $preview .= $$segDataPt;
8097 }
8098 # (also seen "QTI Debug Metadata\0" segment in some newer Samsung images)
8099 # BenQ DC E1050 continues preview in APP5
8100 1 ▶ if ($preview and $nextMarker ne 0xe5) {
Branch: 1 branch
BranchTrueFalseTotal
if ($preview and $nextMarker ne 229) 0 1 1
Condition33%1/3
$preview and $nextMarker ne 229
!ll&&!rl&&r
100
MC/DC0%0/2
$preview and $nextMarker ne 229
$preview $nextMarker ne 229
Truth table33%1/3
A and B
A= $previewB= $nextMarker ne 229
ABresult
0X0
100
111
8101 0 $self->FoundTag('PreviewImage', $preview);
8102 0 undef $preview;
8103 }
8104 } elsif ($marker == 0xe5) { # APP5 (InfiRay, Ricoh "RMETA")
8105 21 ▶ if ($$segDataPt =~ /^RMETA\0/) {
Branch: 5 branches
BranchTrueFalseTotal
if ($$segDataPt =~ /^RMETA\0/) { } 20 1 21
elsif ($$segDataPt =~ /^ssuniqueid\0/) { } 0 1 1
elsif ($self->{'Make'} eq 'DJI') { } 0 1 1
elsif ($self->{'HasIJPEG'} and $length >= 38) { } 1 0 1
elsif ($preview) { } 0 0 0
8106 # (NOTE: apparently these may span multiple segments, but I haven't seen
8107 # a sample like this, so multi-segment support hasn't yet been implemented)
8108 20 $dumpType = 'Ricoh RMETA';
8109 20 DirStart(\%dirInfo, 6, 6);
8110 20 my $tagTablePtr = GetTagTable('Image::ExifTool::Ricoh::RMETA');
8111 20 $self->ProcessDirectory(\%dirInfo, $tagTablePtr);
8112 } elsif ($$segDataPt =~ /^ssuniqueid\0/) {
8113 0 my $tagTablePtr = GetTagTable('Image::ExifTool::Samsung::APP5');
8114 0 $self->HandleTag($tagTablePtr, 'ssuniqueid', substr($$segDataPt, 11));
8115 } elsif ($$self{Make} eq 'DJI') {
8116 0 $dumpType = 'DJI ThermalCal';
8117 0 my $tagTablePtr = GetTagTable('Image::ExifTool::JPEG::Main');
8118 0 $self->HandleTag($tagTablePtr, 'APP5', $$segDataPt);
8119 ▶ } elsif ($$self{HasIJPEG} and $length >= 38) {
Condition33%1/3
$self->{"HasIJPEG"} and $length >= 38
!ll&&!rl&&r
001
MC/DC0%0/2
$self->{"HasIJPEG"} and $length >= 38
$self->{"HasIJPEG"} $length >= 38
Truth table33%1/3
A and B
A= $self->{"HasIJPEG"}B= $length >= 38
ABresult
0X0
100
111
8120 1 $dumpType = 'InfiRay Picture';
8121 1 SetByteOrder('II');
8122 1 my $tagTablePtr = GetTagTable('Image::ExifTool::InfiRay::Picture');
8123 1 $self->ProcessDirectory(\%dirInfo, $tagTablePtr);
8124 } elsif ($preview) {
8125 0 $dumpType = 'PreviewImage';
8126 0 $preview .= $$segDataPt;
8127 0 $self->FoundTag('PreviewImage', $preview);
8128 0 undef $preview;
8129 }
8130 } elsif ($marker == 0xe6) { # APP6 (InfiRay, Toshiba EPPIM, NITF, HP_TDHD)
8131 38 ▶ if ($$segDataPt =~ /^EPPIM\0/) {
Branch: 6 branches
BranchTrueFalseTotal
if ($$segDataPt =~ /^EPPIM\0/) { } 18 20 38
elsif ($$segDataPt =~ /^NITF\0/) { } 18 2 20
elsif ($$segDataPt =~ /^TDHD\x01\0\0\0/ and $length > 12) { } 0 2 2
elsif ($$segDataPt =~ /^GoPro\0/) { } 1 1 2
elsif ($$segDataPt =~ /^DTAT\0\0.\{/s) { } 0 1 1
elsif ($self->{'HasIJPEG'} and $length >= 129) { } 1 0 1
8132 18 undef $dumpType; # (will be dumped here)
8133 18 DirStart(\%dirInfo, 6, 6);
8134 18 ▶ if ($htmlDump) {
Branch: 1 branch
BranchTrueFalseTotal
if ($htmlDump) 0 18 18
8135 0 $self->HDump($segPos-4, 10, 'APP6 EPPIM header');
8136 0 $dumpEnd = $segPos + $length;
8137 }
8138 18 my $tagTablePtr = GetTagTable('Image::ExifTool::JPEG::EPPIM');
8139 18 $self->ProcessTIFF(\%dirInfo, $tagTablePtr);
8140 } elsif ($$segDataPt =~ /^NITF\0/) {
8141 18 $dumpType = 'NITF';
8142 18 SetByteOrder('MM');
8143 18 my $tagTablePtr = GetTagTable('Image::ExifTool::JPEG::NITF');
8144 18 DirStart(\%dirInfo, 5);
8145 18 $self->ProcessDirectory(\%dirInfo, $tagTablePtr);
8146 ▶ } elsif ($$segDataPt =~ /^TDHD\x01\0\0\0/ and $length > 12) {
Condition33%1/3
$$segDataPt =~ /^TDHD\x01\0\0\0/ and $length > 12
!ll&&!rl&&r
200
MC/DC0%0/2
$$segDataPt =~ /^TDHD\x01\0\0\0/ and $length > 12
$$segDataPt =~ /^TDHD\x01\0\0\0/ $length > 12
Truth table33%1/3
A and B
A= $$segDataPt =~ /^TDHD\x01\0\0\0/B= $length > 12
ABresult
0X0
100
111
8147 # HP Photosmart R837 APP6 "TDHD" segment
8148 0 $dumpType = 'TDHD';
8149 0 my $tagTablePtr = GetTagTable('Image::ExifTool::HP::TDHD');
8150 # (ignore first TDHD element because size includes 12-byte tag header)
8151 0 DirStart(\%dirInfo, 12);
8152 0 $self->ProcessDirectory(\%dirInfo, $tagTablePtr);
8153 } elsif ($$segDataPt =~ /^GoPro\0/) {
8154 # GoPro segment
8155 1 $dumpType = 'GoPro';
8156 1 my $tagTablePtr = GetTagTable('Image::ExifTool::GoPro::GPMF');
8157 1 DirStart(\%dirInfo, 6);
8158 1 $self->ProcessDirectory(\%dirInfo, $tagTablePtr);
8159 } elsif ($$segDataPt =~ /^DTAT\0\0.\{/s) {
8160 0 $dumpType = 'DJI_DTAT';
8161 0 my $tagTablePtr = GetTagTable('Image::ExifTool::JPEG::Main');
8162 0 $self->HandleTag($tagTablePtr, 'APP6', $$segDataPt);
8163 ▶ } elsif ($$self{HasIJPEG} and $length >= 129) {
Condition33%1/3
$self->{"HasIJPEG"} and $length >= 129
!ll&&!rl&&r
001
MC/DC0%0/2
$self->{"HasIJPEG"} and $length >= 129
$self->{"HasIJPEG"} $length >= 129
Truth table33%1/3
A and B
A= $self->{"HasIJPEG"}B= $length >= 129
ABresult
0X0
100
111
8164 1 $dumpType = 'InfiRay MixMode';
8165 1 SetByteOrder('II');
8166 1 my $tagTablePtr = GetTagTable('Image::ExifTool::InfiRay::MixMode');
8167 1 $self->ProcessDirectory(\%dirInfo, $tagTablePtr);
8168 }
8169 } elsif ($marker == 0xe7) { # APP7 (InfiRay, Pentax, Huawei, Qualcomm)
8170 20 ▶ if ($$segDataPt =~ /^(PENTAX |RICOH)\0(II|MM)/) {
Branch: 5 branches
BranchTrueFalseTotal
if ($$segDataPt =~ /^(PENTAX |RICOH)\0(II|MM)/) { } 0 20 20
elsif ($$segDataPt =~ /^HUAWEI\0\0(II|MM)/) { } 0 20 20
elsif ($$segDataPt =~ /^DJI-DBG\0/) { } 0 20 20
elsif ($$segDataPt =~ /^\x1aQualcomm Camera Attributes/) { } 19 1 20
elsif ($self->{'HasIJPEG'} and $length >= 32) { } 1 0 1
8171 # found in K-3 and Ricoh GR_IV images (is this multi-segment??)
8172 0 SetByteOrder($2);
8173 0 undef $dumpType; # (dump this ourself)
8174 0 my $hdrLen = length($1) + 3;
8175 0 my $tagTablePtr = GetTagTable('Image::ExifTool::Pentax::Main');
8176 0 DirStart(\%dirInfo, $hdrLen, 0);
8177 0 $dirInfo{DirName} = 'Pentax APP7';
8178 0 ▶ if ($htmlDump) {
Branch: 1 branch
BranchTrueFalseTotal
if ($htmlDump) 0 0 0
8179 0 $self->HDump($segPos-4, 4, 'APP7 header', "Data size: $length bytes");
8180 0 $self->HDump($segPos, $hdrLen, 'Pentax header', 'APP7 data type: Pentax');
8181 0 $dumpEnd = $segPos + $length;
8182 }
8183 0 $self->ProcessDirectory(\%dirInfo, $tagTablePtr);
8184 } elsif ($$segDataPt =~ /^HUAWEI\0\0(II|MM)/) {
8185 0 SetByteOrder($1);
8186 0 undef $dumpType; # (dump this ourself)
8187 0 my $hdrLen = 16;
8188 0 my $tagTablePtr = GetTagTable('Image::ExifTool::Unknown::Main');
8189 0 DirStart(\%dirInfo, $hdrLen, 8);
8190 0 $dirInfo{DirName} = 'Huawei APP7';
8191 0 ▶ if ($htmlDump) {
Branch: 1 branch
BranchTrueFalseTotal
if ($htmlDump) 0 0 0
8192 0 $self->HDump($segPos-4, 4, 'APP7 header', "Data size: $length bytes");
8193 0 $self->HDump($segPos, $hdrLen, 'Huawei header', 'APP7 data type: Huawei');
8194 0 $dumpEnd = $segPos + $length;
8195 }
8196 0 $$self{SET_GROUP0} = 'APP7';
8197 0 $$self{SET_GROUP1} = 'Huawei';
8198 0 $self->ProcessDirectory(\%dirInfo, $tagTablePtr);
8199 0 delete $$self{SET_GROUP0};
8200 0 delete $$self{SET_GROUP1};
8201 } elsif ($$segDataPt =~ /^DJI-DBG\0/) {
8202 0 $dumpType = 'DJI Info';
8203 0 my $tagTablePtr = GetTagTable('Image::ExifTool::DJI::Info');
8204 0 DirStart(\%dirInfo, 8, 0);
8205 0 $$self{SET_GROUP0} = 'APP7';
8206 0 $self->ProcessDirectory(\%dirInfo, $tagTablePtr);
8207 0 delete $$self{SET_GROUP0};
8208 } elsif ($$segDataPt =~ /^\x1aQualcomm Camera Attributes/) {
8209 # found in HP iPAQ_VoiceMessenger
8210 19 $dumpType = 'Qualcomm';
8211 19 my $tagTablePtr = GetTagTable('Image::ExifTool::Qualcomm::Main');
8212 19 DirStart(\%dirInfo, 27);
8213 19 $dirInfo{DirName} = 'Qualcomm';
8214 19 $self->ProcessDirectory(\%dirInfo, $tagTablePtr);
8215 ▶ } elsif ($$self{HasIJPEG} and $length >= 32) {
Condition33%1/3
$self->{"HasIJPEG"} and $length >= 32
!ll&&!rl&&r
001
MC/DC0%0/2
$self->{"HasIJPEG"} and $length >= 32
$self->{"HasIJPEG"} $length >= 32
Truth table33%1/3
A and B
A= $self->{"HasIJPEG"}B= $length >= 32
ABresult
0X0
100
111
8216 1 $dumpType = 'InfiRay OpMode';
8217 1 SetByteOrder('II');
8218 1 my $tagTablePtr = GetTagTable('Image::ExifTool::InfiRay::OpMode');
8219 1 $self->ProcessDirectory(\%dirInfo, $tagTablePtr);
8220 }
8221 } elsif ($marker == 0xe8) { # APP8 (InfiRay, SPIFF)
8222 # my sample SPIFF has 32 bytes of data, but spec states 30
8223 20 ▶ if ($$segDataPt =~ /^SPIFF\0/ and $length == 32) {
Branch: 3 branches
BranchTrueFalseTotal
if ($$segDataPt =~ /^SPIFF\0/ and $length == 32) { } 19 1 20
elsif ($self->{'HasIJPEG'} and $length >= 32) { } 1 0 1
elsif ($$segDataPt =~ /^SEAL\0/) { } 0 0 0
Condition66%2/3
$$segDataPt =~ /^SPIFF\0/ and $length == 32
!ll&&!rl&&r
1019
MC/DC50%1/2
$$segDataPt =~ /^SPIFF\0/ and $length == 32
$$segDataPt =~ /^SPIFF\0/ $length == 32
Truth table66%2/3
A and B
A= $$segDataPt =~ /^SPIFF\0/B= $length == 32
ABresult
0X0
100
111
8224 19 $dumpType = 'SPIFF';
8225 19 DirStart(\%dirInfo, 6);
8226 19 my $tagTablePtr = GetTagTable('Image::ExifTool::JPEG::SPIFF');
8227 19 $self->ProcessDirectory(\%dirInfo, $tagTablePtr);
8228 ▶ } elsif ($$self{HasIJPEG} and $length >= 32) {
Condition33%1/3
$self->{"HasIJPEG"} and $length >= 32
!ll&&!rl&&r
001
MC/DC0%0/2
$self->{"HasIJPEG"} and $length >= 32
$self->{"HasIJPEG"} $length >= 32
Truth table33%1/3
A and B
A= $self->{"HasIJPEG"}B= $length >= 32
ABresult
0X0
100
111
8229 1 $dumpType = 'InfiRay Isothermal';
8230 1 SetByteOrder('II');
8231 1 my $tagTablePtr = GetTagTable('Image::ExifTool::InfiRay::Isothermal');
8232 1 $self->ProcessDirectory(\%dirInfo, $tagTablePtr);
8233 } elsif ($$segDataPt =~ /^SEAL\0/) {
8234 0 $dumpType = 'SEAL';
8235 0 DirStart(\%dirInfo, 5);
8236 0 $self->ProcessDirectory(\%dirInfo, GetTagTable("Image::ExifTool::XMP::SEAL"));
8237 }
8238 } elsif ($marker == 0xe9) { # APP9 (InfiRay, Media Jukebox)
8239 20 ▶ if ($$segDataPt =~ /^Media Jukebox\0/ and $length > 22) {
Branch: 3 branches
BranchTrueFalseTotal
if ($$segDataPt =~ /^Media Jukebox\0/ and $length > 22) { } 19 1 20
elsif ($self->{'HasIJPEG'} and $length >= 768) { } 1 0 1
elsif ($$segDataPt =~ /^SEAL\0/) { } 0 0 0
Condition66%2/3
$$segDataPt =~ /^Media Jukebox\0/ and $length > 22
!ll&&!rl&&r
1019
MC/DC50%1/2
$$segDataPt =~ /^Media Jukebox\0/ and $length > 22
$$segDataPt =~ /^Media Jukebox\0/ $length > 22
Truth table66%2/3
A and B
A= $$segDataPt =~ /^Media Jukebox\0/B= $length > 22
ABresult
0X0
100
111
8240 19 $dumpType = 'MediaJukebox';
8241 # (start parsing after the "<MJMD>")
8242 19 DirStart(\%dirInfo, 22);
8243 19 $dirInfo{DirName} = 'MediaJukebox';
8244 19 require Image::ExifTool::XMP;
8245 19 my $tagTablePtr = GetTagTable('Image::ExifTool::JPEG::MediaJukebox');
8246 19 $self->ProcessDirectory(\%dirInfo, $tagTablePtr, \&Image::ExifTool::XMP::ProcessXMP);
8247 ▶ } elsif ($$self{HasIJPEG} and $length >= 768) {
Condition33%1/3
$self->{"HasIJPEG"} and $length >= 768
!ll&&!rl&&r
001
MC/DC0%0/2
$self->{"HasIJPEG"} and $length >= 768
$self->{"HasIJPEG"} $length >= 768
Truth table33%1/3
A and B
A= $self->{"HasIJPEG"}B= $length >= 768
ABresult
0X0
100
111
8248 1 $dumpType = 'InfiRay Sensor';
8249 1 SetByteOrder('II');
8250 1 my $tagTablePtr = GetTagTable('Image::ExifTool::InfiRay::Sensor');
8251 1 $self->ProcessDirectory(\%dirInfo, $tagTablePtr);
8252 } elsif ($$segDataPt =~ /^SEAL\0/) {
8253 0 $dumpType = 'SEAL';
8254 0 DirStart(\%dirInfo, 5);
8255 0 $self->ProcessDirectory(\%dirInfo, GetTagTable("Image::ExifTool::XMP::SEAL"));
8256 }
8257 } elsif ($marker == 0xea) { # APP10 (PhotoStudio Unicode comments, HDR gain curve)
8258 19 ▶ if ($$segDataPt =~ /^UNICODE\0/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($$segDataPt =~ /^UNICODE\0/) { } 19 0 19
elsif ($$segDataPt =~ /^AROT\0\0.{4}/s) { } 0 0 0
8259 19 $dumpType = 'PhotoStudio';
8260 19 my $comment = $self->Decode(substr($$segDataPt,8), 'UTF16', 'MM');
8261 19 $self->FoundTag('Comment', $comment);
8262 } elsif ($$segDataPt =~ /^AROT\0\0.{4}/s) {
8263 0 $dumpType = 'AROT', # (HDR gain curve? PH guess)
8264 $useJpegMain = 1;
8265 }
8266 } elsif ($marker == 0xeb) { # APP11 (JPEG-HDR, JUMBF)
8267 38 ▶ if ($$segDataPt =~ /^HDR_RI /) {
Branch: 2 branches
BranchTrueFalseTotal
if ($$segDataPt =~ /^HDR_RI /) { } 19 19 38
elsif ($$segDataPt =~ /^(JP..)/s and length $$segDataPt >= 16) { } 19 0 19
8268 19 $dumpType = 'JPEG-HDR';
8269 19 my $dataPt = $segDataPt;
8270 19 ▶ if (defined $combinedSegData) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $combinedSegData) 0 19 19
8271 0 ▶ if ($$segDataPt =~ /~\0/g) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$segDataPt =~ /~\0/g) { } 0 0 0
8272 0 $combinedSegData .= substr($$segDataPt,pos($$segDataPt));
8273 } else {
8274 0 $self->Warn('Invalid format for JPEG-HDR extended segment');
8275 }
8276 0 $dataPt = \$combinedSegData;
8277 }
8278 19 ▶ if ($nextMarker == $marker and $$nextSegDataPt =~ /^HDR_RI /) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nextMarker == $marker and $$nextSegDataPt =~ /^HDR_RI /) { } 0 19 19
Condition33%1/3
$nextMarker == $marker and $$nextSegDataPt =~ /^HDR_RI /
!ll&&!rl&&r
0190
MC/DC0%0/2
$nextMarker == $marker and $$nextSegDataPt =~ /^HDR_RI /
$nextMarker == $marker $$nextSegDataPt =~ /^HDR_RI /
Truth table33%1/3
A and B
A= $nextMarker == $markerB= $$nextSegDataPt =~ /^HDR_RI /
ABresult
0X0
100
111
8279 0 ▶ $combinedSegData = $$segDataPt unless defined $combinedSegData;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $combinedSegData 0 0 0
8280 } else {
8281 19 my $tagTablePtr = GetTagTable('Image::ExifTool::JPEG::HDR');
8282 19 my %dirInfo = ( DataPt => $dataPt );
8283 19 $self->ProcessDirectory(\%dirInfo, $tagTablePtr);
8284 19 undef $combinedSegData;
8285 }
8286 ▶ } elsif ($$segDataPt =~ /^(JP..)/s and length($$segDataPt) >= 16) {
Condition33%1/3
$$segDataPt =~ /^(JP..)/s and length $$segDataPt >= 16
!ll&&!rl&&r
0019
MC/DC0%0/2
$$segDataPt =~ /^(JP..)/s and length $$segDataPt >= 16
$$segDataPt =~ /^(JP..)/s length $$segDataPt >= 16
Truth table33%1/3
A and B
A= $$segDataPt =~ /^(JP..)/sB= length $$segDataPt >= 16
ABresult
0X0
100
111
8287 # JUMBF extension marker
8288 19 my $hdr = $1;
8289 19 $dumpType = 'JUMBF';
8290 19 SetByteOrder('MM');
8291 # (sequence should start from 1, but some software incorrectly writes 0)
8292 19 my $seq = Get32u($segDataPt, 4);
8293 19 my $len = Get32u($segDataPt, 8);
8294 19 my $type = substr($$segDataPt, 12, 4);
8295 # a Microsoft bug writes $len and $type incorrectly as little-endian
8296 19 ▶ if ($type eq 'bmuj') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "bmuj") 0 19 19
8297 0 $self->Warn('Wrong byte order in C2PA APP11 JUMBF header');
8298 0 $type = 'jumb';
8299 0 $len = unpack('x8V', $$segDataPt);
8300 # fix the header
8301 0 substr($$segDataPt, 8, 8) = Set32u($len) . $type;
8302 }
8303 19 my $hdrLen;
8304 19 ▶ if ($len == 1 and length($$segDataPt) >= 24) {
Branch: 1 branch
BranchTrueFalseTotal
if ($len == 1 and length $$segDataPt >= 24) { } 0 19 19
Condition33%1/3
$len == 1 and length $$segDataPt >= 24
!ll&&!rl&&r
1900
MC/DC0%0/2
$len == 1 and length $$segDataPt >= 24
$len == 1 length $$segDataPt >= 24
Truth table33%1/3
A and B
A= $len == 1B= length $$segDataPt >= 24
ABresult
0X0
100
111
8305 # (haven't seen this with the Microsoft bug)
8306 0 $len = Get64u($$segDataPt, 16);
8307 0 $hdrLen = 16;
8308 } else {
8309 19 $hdrLen = 8;
8310 }
8311 19 ▶ $jumbfChunk{$type} or $jumbfChunk{$type} = [ '' ];
Branch: 1 branch
BranchTrueFalseTotal
$jumbfChunk{$type} or $jumbfChunk{$type} = [""] 0 19 19
8312 19 ▶ if ($len < $hdrLen) {
Branch: 2 branches
BranchTrueFalseTotal
if ($len < $hdrLen) { } 0 19 19
elsif (defined $jumbfChunk{$type}[$seq] and length $jumbfChunk{$type}[$seq]) { } 0 19 19
8313 0 $self->Warn('Invalid JUMBF segment');
8314 ▶ } elsif (defined $jumbfChunk{$type}[$seq] and length $jumbfChunk{$type}[$seq]) {
Condition33%1/3
defined $jumbfChunk{$type}[$seq] and length $jumbfChunk{$type}[$seq]
!ll&&!rl&&r
1900
MC/DC0%0/2
defined $jumbfChunk{$type}[$seq] and length $jumbfChunk{$type}[$seq]
defined $jumbfChunk{$type}[$seq] length $jumbfChunk{$type}[$seq]
Truth table33%1/3
A and B
A= defined $jumbfChunk{$type}[$seq]B= length $jumbfChunk{$type}[$seq]
ABresult
0X0
100
111
8315 0 $self->Warn('Duplicate JUMBF sequence number');
8316 } else {
8317 19 ▶ $seq or $self->Warn('Incorrect JUMBF sequence numbering (should start from 0, not 1)');
Branch: 1 branch
BranchTrueFalseTotal
$seq or $self->Warn("Incorrect JUMBF sequence numbering (should start from 0, not 1)") 19 0 19
8318 # add to list of JUMBF chunks
8319 19 $jumbfChunk{$type}[$seq] = substr($$segDataPt, 8 + $hdrLen);
8320 # check to see if we have a complete JUMBF box
8321 19 my $size = $hdrLen;
8322 19 foreach (@{$jumbfChunk{$type}}) {
8323 38 ▶ defined $_ or $size = 0, last;
Branch: 1 branch
BranchTrueFalseTotal
defined $_ or $size = 0, last 38 0 38
8324 38 $size += length $_;
8325 }
8326 19 ▶ if ($size == $len) {
Branch: 1 branch
BranchTrueFalseTotal
if ($size == $len) 19 0 19
8327 19 my $buff = join '', substr($$segDataPt,8,$hdrLen), @{$jumbfChunk{$type}};
8328 19 $dirInfo{DataPt} = \$buff;
8329 19 $dirInfo{DataPos} = $segPos + 8; # (shows correct offsets for single-segment JUMBF)
8330 19 $dirInfo{DataLen} = $dirInfo{DirLen} = $size;
8331 19 $dirInfo{DirName} = 'JUMBF';
8332 19 my $tagTablePtr = GetTagTable('Image::ExifTool::Jpeg2000::Main');
8333 19 $self->ProcessDirectory(\%dirInfo, $tagTablePtr);
8334 19 delete $jumbfChunk{$type};
8335 }
8336 }
8337 }
8338 } elsif ($marker == 0xec) { # APP12 (Ducky, Picture Info)
8339 40 ▶ if ($$segDataPt =~ /^Ducky/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$segDataPt =~ /^Ducky/) { } 21 19 40
8340 21 $dumpType = 'Ducky';
8341 21 DirStart(\%dirInfo, 5);
8342 21 my $tagTablePtr = GetTagTable('Image::ExifTool::APP12::Ducky');
8343 21 $self->ProcessDirectory(\%dirInfo, $tagTablePtr);
8344 } else {
8345 19 my $tagTablePtr = GetTagTable('Image::ExifTool::APP12::PictureInfo');
8346 19 ▶ $self->ProcessDirectory(\%dirInfo, $tagTablePtr) and $dumpType = 'Picture Info';
Branch: 1 branch
BranchTrueFalseTotal
$self->ProcessDirectory(\%dirInfo, $tagTablePtr) and $dumpType = "Picture Info" 19 0 19
8347 }
8348 } elsif ($marker == 0xed) { # APP13 (Photoshop, Adobe_CM)
8349 85 my $isOld;
8350 85 ▶ if ($$segDataPt =~ /^$psAPP13hdr/ or ($$segDataPt =~ /^$psAPP13old/ and $isOld=1)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($$segDataPt =~ /^$Image::ExifTool::psAPP13hdr/ or $$segDataPt =~ /^$Image::ExifTool::psAPP13old/ and $isOld = 1) { } 66 19 85
elsif ($$segDataPt =~ /^Adobe_CM/) { } 19 0 19
Condition60%3/5
$$segDataPt =~ /^$Image::ExifTool::psAPP13hdr/ or $$segDataPt =~ /^$Image::ExifTool::psAPP13old/ and $isOld = 1
l!l&&r!l&&!r
66019
$$segDataPt =~ /^$Image::ExifTool::psAPP13old/ and $isOld = 1
!ll
190
MC/DC50%1/2
$$segDataPt =~ /^$Image::ExifTool::psAPP13hdr/ or $$segDataPt =~ /^$Image::ExifTool::psAPP13old/ and $isOld = 1
$$segDataPt =~ /^$Image::ExifTool::psAPP13hdr/ $$segDataPt =~ /^$Image::ExifTool::psAPP13old/
Truth table66%2/3
A or B
A= $$segDataPt =~ /^$Image::ExifTool::psAPP13hdr/B= $$segDataPt =~ /^$Image::ExifTool::psAPP13old/
ABresult
1X1
011
000
8351 66 $dumpType = 'Photoshop';
8352 # add this data to the combined data if it exists
8353 66 my $dataPt = $segDataPt;
8354 66 ▶ if (defined $combinedSegData) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $combinedSegData) 0 66 66
8355 0 $combinedSegData .= substr($$segDataPt,length($psAPP13hdr));
8356 0 $dataPt = \$combinedSegData;
8357 }
8358 # peek ahead to see if the next segment is photoshop data too
8359 66 ▶ if ($nextMarker == $marker and $$nextSegDataPt =~ /^$psAPP13hdr/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nextMarker == $marker and $$nextSegDataPt =~ /^$Image::ExifTool::psAPP13hdr/) { } 0 66 66
Condition66%2/3
$nextMarker == $marker and $$nextSegDataPt =~ /^$Image::ExifTool::psAPP13hdr/
!ll&&!rl&&r
47190
MC/DC0%0/2
$nextMarker == $marker and $$nextSegDataPt =~ /^$Image::ExifTool::psAPP13hdr/
$nextMarker == $marker $$nextSegDataPt =~ /^$Image::ExifTool::psAPP13hdr/
Truth table66%2/3
A and B
A= $nextMarker == $markerB= $$nextSegDataPt =~ /^$Image::ExifTool::psAPP13hdr/
ABresult
0X0
100
111
8360 # initialize combined data if necessary
8361 0 ▶ $combinedSegData = $$segDataPt unless defined $combinedSegData;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $combinedSegData 0 0 0
8362 # (will handle the Photoshop data the next time around)
8363 } else {
8364 66 ▶ my $hdrLen = $isOld ? 27 : 14;
Branch: 1 branch
BranchTrueFalseTotal
$isOld ? : 0 66 66
8365 # process APP13 Photoshop record
8366 66 my $tagTablePtr = GetTagTable('Image::ExifTool::Photoshop::Main');
8367 66 my %dirInfo = (
8368 DataPt => $dataPt,
8369 DataPos => $segPos,
8370 DataLen => length $$dataPt,
8371 DirStart => $hdrLen, # directory starts after identifier
8372 DirLen => length($$dataPt) - $hdrLen,
8373 Parent => $markerName,
8374 );
8375 66 $self->ProcessDirectory(\%dirInfo, $tagTablePtr);
8376 66 undef $combinedSegData;
8377 }
8378 } elsif ($$segDataPt =~ /^Adobe_CM/) {
8379 19 $dumpType = 'Adobe_CM';
8380 19 SetByteOrder('MM');
8381 19 my $tagTablePtr = GetTagTable('Image::ExifTool::JPEG::AdobeCM');
8382 19 DirStart(\%dirInfo, 8);
8383 19 $self->ProcessDirectory(\%dirInfo, $tagTablePtr);
8384 }
8385 } elsif ($marker == 0xee) { # APP14 (Adobe)
8386 45 ▶ if ($$segDataPt =~ /^Adobe/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$segDataPt =~ /^Adobe/) 45 0 45
8387 # extract as a block if requested, or if copying tags from file
8388 45 ▶ if ($$req{adobe} or
Branch: 1 branch
BranchTrueFalseTotal
if ($req->{"adobe"} or $self->{"TAGS_FROM_FILE"} and not $self->{"EXCL_TAG_LOOKUP"}{"adobe"}) 15 30 45
Condition83%5/6
$req->{"adobe"} or $self->{"TAGS_FROM_FILE"} and not $self->{"EXCL_TAG_LOOKUP"}{"adobe"}
l!l&&r!l&&!r
01530
$self->{"TAGS_FROM_FILE"} and not $self->{"EXCL_TAG_LOOKUP"}{"adobe"}
!ll&&!rl&&r
29115
MC/DC66%2/3
$req->{"adobe"} or $self->{"TAGS_FROM_FILE"} and not $self->{"EXCL_TAG_LOOKUP"}{"adobe"}
$req->{"adobe"} $self->{"TAGS_FROM_FILE"} not $self->{"EXCL_TAG_LOOKUP"}{"adobe"}
Truth table75%3/4
A or B and not(C)
A= $req->{"adobe"}B= $self->{"TAGS_FROM_FILE"}C= not $self->{"EXCL_TAG_LOOKUP"}{"adobe"}
ABCresult
1XX1
0111
00X0
0100
8389 # (not extracted normally, so check TAGS_FROM_FILE)
8390 ($$self{TAGS_FROM_FILE} and not $$self{EXCL_TAG_LOOKUP}{adobe}))
8391 {
8392 15 $self->FoundTag('Adobe', $$segDataPt);
8393 }
8394 45 $dumpType = 'Adobe';
8395 45 SetByteOrder('MM');
8396 45 my $tagTablePtr = GetTagTable('Image::ExifTool::JPEG::Adobe');
8397 45 DirStart(\%dirInfo, 5);
8398 45 $self->ProcessDirectory(\%dirInfo, $tagTablePtr);
8399 }
8400 } elsif ($marker == 0xef) { # APP15 (GraphicConverter)
8401 19 ▶ if ($$segDataPt =~ /^Q\s*(\d+)/ and $length == 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$segDataPt =~ /^Q\s*(\d+)/ and $length == 4) 19 0 19
Condition33%1/3
$$segDataPt =~ /^Q\s*(\d+)/ and $length == 4
!ll&&!rl&&r
0019
MC/DC0%0/2
$$segDataPt =~ /^Q\s*(\d+)/ and $length == 4
$$segDataPt =~ /^Q\s*(\d+)/ $length == 4
Truth table33%1/3
A and B
A= $$segDataPt =~ /^Q\s*(\d+)/B= $length == 4
ABresult
0X0
100
111
8402 19 $dumpType = 'GraphicConverter';
8403 19 my $tagTablePtr = GetTagTable('Image::ExifTool::JPEG::GraphConv');
8404 19 $self->HandleTag($tagTablePtr, 'Q', $1);
8405 }
8406 } elsif ($marker == 0xfe) { # COM (JPEG comment)
8407 27 $dumpType = 'Comment';
8408 27 $$segDataPt =~ s/\0+$//; # some dumb softwares add null terminators
8409 27 $self->FoundTag('Comment', $$segDataPt);
8410 } elsif ($marker == 0x64) { # CME (J2C comment and extension)
8411 2 $dumpType = 'Comment';
8412 2 ▶ if ($length > 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length > 2) 2 0 2
8413 2 my $reg = unpack('n', $$segDataPt); # get registration value
8414 2 my $val = substr($$segDataPt, 2);
8415 2 ▶ $val = $self->Decode($val, 'Latin') if $reg == 1;
Branch: 1 branch
BranchTrueFalseTotal
if $reg == 1 2 0 2
8416 # (actually an extension for $reg==65535, but store as binary comment)
8417 2 ▶ $self->FoundTag('Comment', ($reg==0 or $reg==65535) ? \$val : $val);
Branch: 1 branch
BranchTrueFalseTotal
$reg == 0 || $reg == 65535 ? : 0 2 2
Condition33%1/3
$reg == 0 or $reg == 65535
l!l&&r!l&&!r
002
MC/DC0%0/2
$reg == 0 or $reg == 65535
$reg == 0 $reg == 65535
Truth table33%1/3
A or B
A= $reg == 0B= $reg == 65535
ABresult
1X1
011
000
8418 }
8419 } elsif ($marker == 0x51) { # SIZ (J2C)
8420 1 my ($w, $h) = unpack('x2N2', $$segDataPt);
8421 1 ▶ unless ($gotSize) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($gotSize) 1 0 1
8422 1 $gotSize = 1;
8423 1 $self->FoundTag('ImageWidth', $w);
8424 1 $self->FoundTag('ImageHeight', $h);
8425 }
8426 } elsif (($marker & 0xf0) != 0xe0) {
8427 502 $dumpType = "$markerName segment";
8428 502 $desc = "[JPEG $markerName]"; # (other known JPEG segments)
8429 }
8430 1225 ▶ if (defined $dumpType) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $dumpType) 1169 56 1225
8431 1169 ▶ if ($useJpegMain) {
Branch: 1 branch
BranchTrueFalseTotal
if ($useJpegMain) 0 1169 1169
8432 0 my $tagTablePtr = GetTagTable('Image::ExifTool::JPEG::Main');
8433 0 $self->HandleTag($tagTablePtr, $markerName, $$segDataPt);
8434 }
8435 1169 ▶ if (not $dumpType and ($$options{Unknown} or $$options{Validate})) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $dumpType and $options->{"Unknown"} || $options->{"Validate"}) 0 1169 1169
Condition50%3/6
not $dumpType and $options->{"Unknown"} || $options->{"Validate"}
!ll&&!rl&&r
116810
$options->{"Unknown"} or $options->{"Validate"}
l!l&&r!l&&!r
001
MC/DC0%0/3
not $dumpType and $options->{"Unknown"} || $options->{"Validate"}
not $dumpType $options->{"Unknown"} $options->{"Validate"}
Truth table50%2/4
not(A) and B or C
A= not $dumpTypeB= $options->{"Unknown"}C= $options->{"Validate"}
ABCresult
0XX0
1000
11X1
1011
8436 0 ▶ my $str = ($$segDataPt =~ /^([\x20-\x7e]{1,20})\0/) ? " '${1}'" : '';
Branch: 1 branch
BranchTrueFalseTotal
$$segDataPt =~ /^([\x20-\x7e]{1,20})\0/ ? : 0 0 0
8437 0 ▶ $xtra = 'segment' unless $xtra;
Branch: 1 branch
BranchTrueFalseTotal
unless $xtra 0 0 0
8438 0 $self->Warn("Unknown $markerName$str $xtra", 1);
8439 }
8440 1169 ▶ if ($htmlDump) {
Branch: 1 branch
BranchTrueFalseTotal
if ($htmlDump) 0 1169 1169
8441 0 ▶ $desc or $desc = $markerName . ($dumpType ? " $dumpType" : '') . ' segment';
Branch: 2 branches
BranchTrueFalseTotal
$desc or $desc = $markerName . ($dumpType ? " $dumpType" : "") . ' segment' 0 0 0
$dumpType ? : 0 0 0
8442 0 $self->HDump($segPos-4, $length+4, $desc, $tip, 0x08);
8443 0 $dumpEnd = $segPos + $length;
8444 }
8445 }
8446 1225 undef $$segDataPt;
8447 }
8448 # print verbose hash message if necessary
8449 250 ▶ print $out "${indent}(ImageDataHash: $hashsize bytes of JPEG image data)\n" if $hashsize and $verbose;
Branch: 1 branch
BranchTrueFalseTotal
if $hashsize and $verbose 0 250 250
Condition33%1/3
$hashsize and $verbose
!ll&&!rl&&r
25000
MC/DC0%0/2
$hashsize and $verbose
$hashsize $verbose
Truth table33%1/3
A and B
A= $hashsizeB= $verbose
ABresult
0X0
100
111
8450 # calculate JPEGDigest if requested
8451 250 ▶ if (@dqt) {
Branch: 1 branch
BranchTrueFalseTotal
if (@dqt) 1 249 250
8452 1 require Image::ExifTool::JPEGDigest;
8453 1 Image::ExifTool::JPEGDigest::Calculate($self, \@dqt, $subSampling);
8454 }
8455 # issue necessary warnings
8456 250 ▶ $self->Warn('Invalid JUMBF size or missing JUMBF chunk') if %jumbfChunk;
Branch: 1 branch
BranchTrueFalseTotal
if %jumbfChunk 0 250 250
8457 250 ▶ $self->Warn('Incomplete ICC_Profile record', 1) if defined $iccChunkCount;
Branch: 1 branch
BranchTrueFalseTotal
if defined $iccChunkCount 0 250 250
8458 250 ▶ $self->Warn('Incomplete FLIR record', 1) if defined $flirCount;
Branch: 1 branch
BranchTrueFalseTotal
if defined $flirCount 0 250 250
8459 250 ▶ $self->Warn('Error reading PreviewImage', 1) if $$self{PreviewError};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"PreviewError"} 0 250 250
8460 250 ▶ $success or $self->Warn('JPEG format error');
Branch: 1 branch
BranchTrueFalseTotal
$success or $self->Warn("JPEG format error") 250 0 250
8461 250 ▶ pop @$path if @$path > $pn;
Branch: 1 branch
BranchTrueFalseTotal
if @$path > $pn 0 250 250
8462 250 return 1;
8463 }
8464  
8465 #------------------------------------------------------------------------------
8466 # Extract metadata from an Exiv2 EXV file
8467 # Inputs: 0) ExifTool object reference, 1) dirInfo ref with RAF set
8468 # Returns: 1 on success, 0 if this wasn't a valid JPEG file
8469 sub ProcessEXV($$)
8470 2 ▶{
Subroutine ProcessEXV: called CC=1 SCAR=0.0
Pod undocumented
8471 2 my ($self, $dirInfo) = @_;
8472 2 return $self->ProcessJPEG($dirInfo);
8473 }
8474  
8475 #------------------------------------------------------------------------------
8476 # Process EXIF file
8477 # Inputs/Returns: same as ProcessTIFF
8478 sub ProcessEXIF($$;$)
8479 2 ▶{
Subroutine ProcessEXIF: called CC=1 SCAR=0.0
Pod undocumented
8480 2 my ($self, $dirInfo, $tagTablePtr) = @_;
8481 2 return $self->ProcessTIFF($dirInfo, $tagTablePtr);
8482 }
8483  
8484 #------------------------------------------------------------------------------
8485 # Process TIFF data (wrapper for DoProcessTIFF to allow re-entry)
8486 # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) optional tag table ref
8487 # Returns: 1 if this looked like a valid EXIF block, 0 otherwise, or -1 on write error
8488 sub ProcessTIFF($$;$)
8489 502 ▶{
Subroutine ProcessTIFF: called CC=2 SCAR=6.9
Pod undocumented
8490 502 my ($self, $dirInfo, $tagTablePtr) = @_;
8491 502 my $exifData = $$self{EXIF_DATA};
8492 502 my $exifPos = $$self{EXIF_POS};
8493 502 my $rtnVal = $self->DoProcessTIFF($dirInfo, $tagTablePtr);
8494 # restore original EXIF information (in case ProcessTIFF is nested)
8495 502 ▶ if (defined $exifData) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $exifData) 108 394 502
8496 108 $$self{EXIF_DATA} = $exifData;
8497 108 $$self{EXIF_POS} = $exifPos;
8498 }
8499 502 return $rtnVal;
8500 }
8501  
8502 #------------------------------------------------------------------------------
8503 # Process TIFF as a sub-document
8504 # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) optional tag table ref
8505 # Returns: 1 if this looked like a valid EXIF block, 0 otherwise, or -1 on write error
8506 sub ProcessSubTIFF($$;$)
8507 0 ▶{
Subroutine ProcessSubTIFF: not called CC=1 SCAR=6.9
Pod undocumented
8508 0 my ($self, $dirInfo, $tagTablePtr) = @_;
8509 0 $$self{DOC_NUM} = ++$$self{DOC_COUNT};
8510 0 my $rtnVal = $self->ProcessTIFF($dirInfo, $tagTablePtr);
8511 0 delete $$self{DOC_NUM};
8512 0 return $rtnVal;
8513 }
8514  
8515 #------------------------------------------------------------------------------
8516 # Process TIFF data
8517 # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) optional tag table ref
8518 # Returns: 1 if this looked like a valid EXIF block, 0 otherwise, or -1 on write error
8519 sub DoProcessTIFF($$;$)
8520 502 ▶{
Subroutine DoProcessTIFF: called CC=156 SCAR=71.5
Pod undocumented
8521 502 my ($self, $dirInfo, $tagTablePtr) = @_;
8522 502 my $dataPt = $$dirInfo{DataPt};
8523 502 ▶ my $fileType = $$dirInfo{Parent} || '';
Condition100%2/2
$dirInfo->{'Parent'} || ''
l!l
44656
MC/DC100%1/1
$dirInfo->{'Parent'} || ''
$dirInfo->{'Parent'}
Truth table100%2/2
A
A= $dirInfo->{'Parent'}
Aresult
11
00
8524 502 my $raf = $$dirInfo{RAF};
8525 502 ▶ my $base = $$dirInfo{Base} || 0;
Condition100%2/2
$dirInfo->{'Base'} || 0
l!l
378124
MC/DC100%1/1
$dirInfo->{'Base'} || 0
$dirInfo->{'Base'}
Truth table100%2/2
A
A= $dirInfo->{'Base'}
Aresult
11
00
8526 502 my $outfile = $$dirInfo{OutFile};
8527 502 my ($err, $sig, $canonSig, $otherSig);
8528  
8529 # attempt to read TIFF header
8530 502 ▶ if ($raf) {
Branch: 3 branches
BranchTrueFalseTotal
if ($raf) { } 47 455 502
elsif ($dataPt and length $$dataPt) { } 411 44 455
elsif ($outfile) { } 44 0 44
8531 47 $$self{EXIF_DATA} = '';
8532 47 ▶ if ($outfile) {
Branch: 1 branch
BranchTrueFalseTotal
if ($outfile) { } 14 33 47
8533 14 ▶ $raf->Seek(0, 0) or return 0;
Branch: 1 branch
BranchTrueFalseTotal
$raf->Seek(0, 0) or return 0 14 0 14
8534 14 ▶ if ($base) {
Branch: 1 branch
BranchTrueFalseTotal
if ($base) 0 14 14
8535 0 ▶ $raf->Read($$dataPt, $base) == $base or return 0;
Branch: 1 branch
BranchTrueFalseTotal
$raf->Read($$dataPt, $base) == $base or return 0 0 0 0
8536 0 ▶ Write($outfile, $$dataPt) or $err = 1;
Branch: 1 branch
BranchTrueFalseTotal
&Write($outfile, $$dataPt) or $err = 1 0 0 0
8537 }
8538 } else {
8539 33 ▶ $raf->Seek($base, 0) or return 0;
Branch: 1 branch
BranchTrueFalseTotal
$raf->Seek($base, 0) or return 0 33 0 33
8540 }
8541 # extract full EXIF block (for block copy) from EXIF file
8542 47 ▶ my $amount = $fileType eq 'EXIF' ? 65536 * 8 : 8;
Branch: 1 branch
BranchTrueFalseTotal
$fileType eq 'EXIF' ? : 3 44 47
8543 47 my $n = $raf->Read($$self{EXIF_DATA}, $amount);
8544 47 ▶ if ($n < 8) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n < 8) 1 46 47
8545 1 ▶ return 0 if $n or not $outfile or $fileType ne 'EXIF';
Branch: 1 branch
BranchTrueFalseTotal
if $n or not $outfile or $fileType ne "EXIF" 0 1 1
Condition33%2/6
$n or not $outfile or $fileType ne "EXIF"
l!l&&r!l&&!r
001
$n or not $outfile
l!l&&r!l&&!r
001
MC/DC0%0/3
$n or not $outfile or $fileType ne "EXIF"
$n not $outfile $fileType ne "EXIF"
Truth table25%1/4
A or not(B) or C
A= $nB= not $outfileC= $fileType ne "EXIF"
ABCresult
1XX1
01X1
0011
0000
8546 # create EXIF file from scratch
8547 1 delete $$self{EXIF_DATA};
8548 1 undef $raf;
8549 }
8550 47 ▶ if ($n > 8) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n > 8) 2 45 47
8551 2 $raf->Seek(8, 0);
8552 2 ▶ if ($n == $amount) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n == $amount) 0 2 2
8553 0 $$self{EXIF_DATA} = substr($$self{EXIF_DATA}, 0, 8);
8554 0 $self->Warn('EXIF too large to extract as a block'); #(shouldn't happen)
8555 }
8556 }
8557 ▶ } elsif ($dataPt and length $$dataPt) {
Condition100%3/3
$dataPt and length $$dataPt
!ll&&!rl&&r
386411
MC/DC100%2/2
$dataPt and length $$dataPt
$dataPt length $$dataPt
Truth table100%3/3
A and B
A= $dataPtB= length $$dataPt
ABresult
0X0
100
111
8558 # save a copy of the EXIF data
8559 411 ▶ my $dirStart = $$dirInfo{DirStart} || 0;
Condition100%2/2
$dirInfo->{'DirStart'} || 0
l!l
37338
MC/DC100%1/1
$dirInfo->{'DirStart'} || 0
$dirInfo->{'DirStart'}
Truth table100%2/2
A
A= $dirInfo->{'DirStart'}
Aresult
11
00
8560 411 ▶ my $dirLen = $$dirInfo{DirLen} || (length($$dataPt) - $dirStart);
Condition66%2/3
$dirInfo->{'DirLen'} || length($$dataPt) - $dirStart
l!l&&r!l&&!r
357540
MC/DC0%0/2
$dirInfo->{'DirLen'} || length($$dataPt) - $dirStart
$dirInfo->{'DirLen'} length($$dataPt) - $dirStart
Truth table66%2/3
A || B
A= $dirInfo->{'DirLen'}B= length($$dataPt) - $dirStart
ABresult
1X1
011
000
8561 411 ▶ if ($dirLen > 0 or not $outfile) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dirLen > 0 or not $outfile) { } 411 0 411
Condition33%1/3
$dirLen > 0 or not $outfile
l!l&&r!l&&!r
41100
MC/DC0%0/2
$dirLen > 0 or not $outfile
$dirLen > 0 not $outfile
Truth table33%1/3
A or not(B)
A= $dirLen > 0B= not $outfile
ABresult
1X1
011
000
8562 411 $$self{EXIF_DATA} = substr($$dataPt, $dirStart, $dirLen);
8563 } else {
8564 0 delete $$self{EXIF_DATA}; # create from scratch;
8565 }
8566 411 ▶ $self->VerboseDir('TIFF') if $$self{OPTIONS}{Verbose} and length($$self{INDENT}) > 2;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"OPTIONS"}{"Verbose"} and length $self->{"INDENT"} > 2 0 411 411
Condition66%2/3
$self->{"OPTIONS"}{"Verbose"} and length $self->{"INDENT"} > 2
!ll&&!rl&&r
40920
MC/DC0%0/2
$self->{"OPTIONS"}{"Verbose"} and length $self->{"INDENT"} > 2
$self->{"OPTIONS"}{"Verbose"} length $self->{"INDENT"} > 2
Truth table66%2/3
A and B
A= $self->{"OPTIONS"}{"Verbose"}B= length $self->{"INDENT"} > 2
ABresult
0X0
100
111
8567 } elsif ($outfile) {
8568 44 delete $$self{EXIF_DATA}; # create from scratch
8569 } else {
8570 0 $$self{EXIF_DATA} = '';
8571 }
8572 502 ▶ unless (defined $$self{EXIF_DATA}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"EXIF_DATA"}) 45 457 502
8573 # set default byte order for creating new GPS in CR3 images
8574 45 my $defaultByteOrder;
8575 45 ▶ if ($$dirInfo{DirName} and $$dirInfo{DirName} eq 'GPS') {
Branch: 1 branch
BranchTrueFalseTotal
if ($dirInfo->{"DirName"} and $dirInfo->{"DirName"} eq "GPS") 0 45 45
Condition33%1/3
$dirInfo->{"DirName"} and $dirInfo->{"DirName"} eq "GPS"
!ll&&!rl&&r
0450
MC/DC0%0/2
$dirInfo->{"DirName"} and $dirInfo->{"DirName"} eq "GPS"
$dirInfo->{"DirName"} $dirInfo->{"DirName"} eq "GPS"
Truth table33%1/3
A and B
A= $dirInfo->{"DirName"}B= $dirInfo->{"DirName"} eq "GPS"
ABresult
0X0
100
111
8576 0 $defaultByteOrder = $$self{SaveExifByteOrder};
8577 }
8578 # create TIFF information from scratch
8579 45 ▶ if ($self->SetPreferredByteOrder($defaultByteOrder) eq 'MM') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->SetPreferredByteOrder($defaultByteOrder) eq 'MM') { } 36 9 45
8580 36 $$self{EXIF_DATA} = "MM\0\x2a\0\0\0\x08";
8581 } else {
8582 9 $$self{EXIF_DATA} = "II\x2a\0\x08\0\0\0";
8583 }
8584 }
8585 502 $$self{EXIF_POS} = $base + $$self{BASE};
8586 502 ▶ $$self{FIRST_EXIF_POS} = $$self{EXIF_POS} unless defined $$self{FIRST_EXIF_POS};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"FIRST_EXIF_POS"} 394 108 502
8587 502 $dataPt = \$$self{EXIF_DATA};
8588  
8589 # set byte ordering
8590 502 my $byteOrder = substr($$dataPt,0,2);
8591 502 ▶ SetByteOrder($byteOrder) or return 0;
Branch: 1 branch
BranchTrueFalseTotal
&SetByteOrder($byteOrder) or return 0 496 6 502
8592  
8593 # verify the byte ordering
8594 496 my $identifier = Get16u($dataPt, 2);
8595 # identifier is 0x2a for TIFF (but 0x4f52, 0x5352 or ?? for ORF)
8596 # no longer do this because various files use different values
8597 # (TIFF=0x2a, RW2/RWL=0x55, HDP=0xbc, BTF=0x2b, ORF=0x4f52/0x5352/0x????)
8598 # return 0 unless $identifier == 0x2a;
8599 496 ▶ $self->Warn('Invalid magic number in EXIF TIFF header') if $fileType eq 'APP1' and $identifier != 0x2a;
Branch: 1 branch
BranchTrueFalseTotal
if $fileType eq "APP1" and $identifier != 42 0 496 496
Condition66%2/3
$fileType eq "APP1" and $identifier != 42
!ll&&!rl&&r
2102860
MC/DC0%0/2
$fileType eq "APP1" and $identifier != 42
$fileType eq "APP1" $identifier != 42
Truth table66%2/3
A and B
A= $fileType eq "APP1"B= $identifier != 42
ABresult
0X0
100
111
8600  
8601 # get offset to IFD0
8602 496 ▶ return 0 if length $$dataPt < 8;
Branch: 1 branch
BranchTrueFalseTotal
if length $$dataPt < 8 0 496 496
8603 496 my $offset = Get32u($dataPt, 4);
8604 496 ▶ $offset >= 8 or return 0;
Branch: 1 branch
BranchTrueFalseTotal
$offset >= 8 or return 0 496 0 496
8605  
8606 496 ▶ if ($raf) {
Branch: 1 branch
BranchTrueFalseTotal
if ($raf) 40 456 496
8607 # check for canon or EXIF signature
8608 # (Canon CR2 images should have an offset of 16, but it may be
8609 # greater if edited by PhotoMechanic)
8610 40 ▶ if ($identifier == 0x2a and $offset >= 16) {
Branch: 4 branches
BranchTrueFalseTotal
if ($identifier == 42 and $offset >= 16) { } 17 23 40
elsif ($identifier == 85 and $fileType =~ /^(RAW|RW2|RWL|TIFF)$/) { } 3 20 23
elsif ($fileType eq 'TIFF') { } 13 7 20
elsif ($fileType eq 'ARW') { } 0 7 7
Condition100%3/3
$identifier == 42 and $offset >= 16
!ll&&!rl&&r
32017
MC/DC100%2/2
$identifier == 42 and $offset >= 16
$identifier == 42 $offset >= 16
Truth table100%3/3
A and B
A= $identifier == 42B= $offset >= 16
ABresult
0X0
100
111
8611 17 ▶ $raf->Read($sig, 8) == 8 or return 0;
Branch: 1 branch
BranchTrueFalseTotal
$raf->Read($sig, 8) == 8 or return 0 17 0 17
8612 17 $$dataPt .= $sig;
8613 17 ▶ if ($sig =~ /^(CR\x02\0|\xba\xb0\xac\xbb|ExifMeta)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sig =~ /^(CR\x02\0|\xba\xb0\xac\xbb|ExifMeta)/) 10 7 17
8614 10 ▶ if ($sig eq 'ExifMeta') {
Branch: 1 branch
BranchTrueFalseTotal
if ($sig eq 'ExifMeta') { } 1 9 10
8615 1 $self->SetFileType($fileType = 'EXIF');
8616 1 $otherSig = $sig;
8617 } else {
8618 9 ▶ $fileType = $sig =~ /^CR/ ? 'CR2' : 'Canon 1D RAW';
Branch: 1 branch
BranchTrueFalseTotal
$sig =~ /^CR/ ? : 9 0 9
8619 9 $canonSig = $sig;
8620 }
8621 10 ▶ $self->HDump($base+8, 8, "[$fileType header]") if $$self{HTML_DUMP};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"HTML_DUMP"} 0 10 10
8622 }
8623 ▶ } elsif ($identifier == 0x55 and $fileType =~ /^(RAW|RW2|RWL|TIFF)$/) {
Condition66%2/3
$identifier == 85 and $fileType =~ /^(RAW|RW2|RWL|TIFF)$/
!ll&&!rl&&r
2003
MC/DC50%1/2
$identifier == 85 and $fileType =~ /^(RAW|RW2|RWL|TIFF)$/
$identifier == 85 $fileType =~ /^(RAW|RW2|RWL|TIFF)$/
Truth table66%2/3
A and B
A= $identifier == 85B= $fileType =~ /^(RAW|RW2|RWL|TIFF)$/
ABresult
0X0
100
111
8624 # panasonic RAW, RW2 or RWL file
8625 3 my $magic;
8626 # test for RW2/RWL magic number
8627 3 ▶ if ($offset >= 0x18 and $raf->Read($magic, 16) and
Branch: 1 branch
BranchTrueFalseTotal
if ($offset >= 24 and $raf->Read($magic, 16) and $magic eq "\210\347t\330\370%\035M\224znw\202+]j") { } 3 0 3
Condition33%2/6
$offset >= 24 and $raf->Read($magic, 16) and $magic eq "\210\347t\330\370%\35M\224znw\202+]j"
!ll&&!rl&&r
003
$offset >= 24 and $raf->Read($magic, 16)
!ll&&!rl&&r
003
MC/DC0%0/3
$offset >= 24 and $raf->Read($magic, 16) and $magic eq "\210\347t\330\370%\35M\224znw\202+]j"
$offset >= 24 $raf->Read($magic, 16) $magic eq "\210\347t\330\370%\35M\224znw\202+]j"
Truth table25%1/4
A and B and C
A= $offset >= 24B= $raf->Read($magic, 16)C= $magic eq "\210\347t\330\370%\35M\224znw\202+]j"
ABCresult
0XX0
10X0
1100
1111
8628 $magic eq "\x88\xe7\x74\xd8\xf8\x25\x1d\x4d\x94\x7a\x6e\x77\x82\x2b\x5d\x6a")
8629 {
8630 3 ▶ $fileType = 'RW2' unless $fileType eq 'RWL';
Branch: 1 branch
BranchTrueFalseTotal
unless $fileType eq "RWL" 3 0 3
8631 3 ▶ $self->HDump($base + 8, 16, '[RW2/RWL header]') if $$self{HTML_DUMP};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"HTML_DUMP"} 0 3 3
8632 3 $otherSig = $magic; # save signature for writing
8633 } else {
8634 0 $fileType = 'RAW';
8635 }
8636 3 $tagTablePtr = GetTagTable('Image::ExifTool::PanasonicRaw::Main');
8637 } elsif ($fileType eq 'TIFF') {
8638 13 ▶ if ($identifier == 0x2b) {
Branch: 4 branches
BranchTrueFalseTotal
if ($identifier == 43) { } 0 13 13
elsif ($identifier == 20306 or $identifier == 21330) { } 0 13 13
elsif ($identifier == 17234) { } 0 13 13
elsif ($byteOrder eq 'II' and ($identifier & 255) == 188) { } 0 26 26
8639 # this looks like a BigTIFF image
8640 0 $raf->Seek(0);
8641 0 require Image::ExifTool::BigTIFF;
8642 0 my $result = Image::ExifTool::BigTIFF::ProcessBTF($self, $dirInfo);
8643 0 ▶ if ($result) {
Branch: 1 branch
BranchTrueFalseTotal
if ($result) 0 0 0
8644 0 ▶ $self->FoundTag(PageCount => $$self{PageCount}) if $$self{MultiPage};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"MultiPage"} 0 0 0
8645 0 return 1;
8646 }
8647 ▶ } elsif ($identifier == 0x4f52 or $identifier == 0x5352) {
Condition33%1/3
$identifier == 20306 or $identifier == 21330
l!l&&r!l&&!r
0013
MC/DC0%0/2
$identifier == 20306 or $identifier == 21330
$identifier == 20306 $identifier == 21330
Truth table33%1/3
A or B
A= $identifier == 20306B= $identifier == 21330
ABresult
1X1
011
000
8648 # Olympus ORF image (set FileType now because base type is 'ORF')
8649 0 $self->SetFileType($fileType = 'ORF');
8650 } elsif ($identifier == 0x4352) {
8651 0 $fileType = 'DCP';
8652 ▶ } elsif ($byteOrder eq 'II' and ($identifier & 0xff) == 0xbc) {
Condition33%1/3
$byteOrder eq "II" and ($identifier & 255) == 188
!ll&&!rl&&r
1300
MC/DC0%0/2
$byteOrder eq "II" and ($identifier & 255) == 188
$byteOrder eq "II" ($identifier & 255) == 188
Truth table33%1/3
A and B
A= $byteOrder eq "II"B= ($identifier & 255) == 188
ABresult
0X0
100
111
8653 0 $fileType = 'HDP'; # Windows HD Photo file
8654 # check version number
8655 0 my $ver = Get8u($dataPt, 3);
8656 0 ▶ if ($ver > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ver > 1) 0 0 0
8657 0 $self->Error("Windows HD Photo version $ver files not yet supported");
8658 0 return 1;
8659 }
8660 }
8661 } elsif ($fileType eq 'ARW') {
8662 0 $$self{LOW_PRIORITY_DIR}{IFD1} = 1; # lower priority of IFD1 tags in ARW files
8663 }
8664 # we have a valid TIFF (or whatever) file
8665 40 ▶ if ($fileType and not $$self{VALUE}{FileType}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fileType and not $self->{"VALUE"}{"FileType"}) 38 2 40
Condition66%2/3
$fileType and not $self->{"VALUE"}{"FileType"}
!ll&&!rl&&r
0238
MC/DC50%1/2
$fileType and not $self->{"VALUE"}{"FileType"}
$fileType not $self->{"VALUE"}{"FileType"}
Truth table66%2/3
A and not(B)
A= $fileTypeB= not $self->{"VALUE"}{"FileType"}
ABresult
0X0
100
111
8666 38 my $lookup = $fileTypeLookup{$fileType};
8667 38 ▶ $lookup = $fileTypeLookup{$lookup} unless ref $lookup or not $lookup;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $lookup or not $lookup 0 38 38
Condition33%1/3
ref $lookup or not $lookup
l!l&&r!l&&!r
3800
MC/DC0%0/2
ref $lookup or not $lookup
ref $lookup not $lookup
Truth table33%1/3
A or not(B)
A= ref $lookupB= not $lookup
ABresult
1X1
011
000
8668 # use file extension to pre-determine type if extension is TIFF-based or type is RAW
8669 38 ▶ my $baseType = $lookup ? (ref $$lookup[0] ? $$lookup[0][0] : $$lookup[0]) : '';
Branch: 2 branches
BranchTrueFalseTotal
$lookup ? : 38 0 38
ref $lookup->[0] ? : 0 38 38
8670 38 ▶ my $t = ($baseType eq 'TIFF' or $fileType =~ /RAW/) ? $fileType : undef;
Branch: 1 branch
BranchTrueFalseTotal
$baseType eq 'TIFF' || $fileType =~ /RAW/ ? : 37 1 38
Condition66%2/3
$baseType eq "TIFF" or $fileType =~ /RAW/
l!l&&r!l&&!r
3701
MC/DC50%1/2
$baseType eq "TIFF" or $fileType =~ /RAW/
$baseType eq "TIFF" $fileType =~ /RAW/
Truth table66%2/3
A or B
A= $baseType eq "TIFF"B= $fileType =~ /RAW/
ABresult
1X1
011
000
8671 38 $self->SetFileType($t);
8672 }
8673 # don't process file if FastScan > 2
8674 40 ▶ return 1 if not $outfile and $$self{OPTIONS}{FastScan} and $$self{OPTIONS}{FastScan} > 2;
Branch: 1 branch
BranchTrueFalseTotal
if not $outfile and $self->{"OPTIONS"}{"FastScan"} and $self->{"OPTIONS"}{"FastScan"} > 2 0 40 40
Condition50%3/6
not $outfile and $self->{"OPTIONS"}{"FastScan"} and $self->{"OPTIONS"}{"FastScan"} > 2
!ll&&!rl&&r
4000
not $outfile and $self->{"OPTIONS"}{"FastScan"}
!ll&&!rl&&r
13270
MC/DC0%0/3
not $outfile and $self->{"OPTIONS"}{"FastScan"} and $self->{"OPTIONS"}{"FastScan"} > 2
not $outfile $self->{"OPTIONS"}{"FastScan"} $self->{"OPTIONS"}{"FastScan"} > 2
Truth table50%2/4
not(A) and B and C
A= not $outfileB= $self->{"OPTIONS"}{"FastScan"}C= $self->{"OPTIONS"}{"FastScan"} > 2
ABCresult
0XX0
10X0
1100
1111
8675 }
8676 # (accommodate CR3 images which have a TIFF directory with ExifIFD at the top level)
8677 496 ▶ my $ifdName = ($$dirInfo{DirName} and $$dirInfo{DirName} =~ /^(ExifIFD|GPS)$/) ? $1 : 'IFD0';
Branch: 1 branch
BranchTrueFalseTotal
$dirInfo->{'DirName'} && $dirInfo->{'DirName'} =~ /^(ExifIFD|GPS)$/ ? : 18 478 496
Condition100%3/3
$dirInfo->{"DirName"} and $dirInfo->{"DirName"} =~ /^(ExifIFD|GPS)$/
!ll&&!rl&&r
30017818
MC/DC100%2/2
$dirInfo->{"DirName"} and $dirInfo->{"DirName"} =~ /^(ExifIFD|GPS)$/
$dirInfo->{"DirName"} $dirInfo->{"DirName"} =~ /^(ExifIFD|GPS)$/
Truth table100%3/3
A and B
A= $dirInfo->{"DirName"}B= $dirInfo->{"DirName"} =~ /^(ExifIFD|GPS)$/
ABresult
0X0
100
111
8678 496 ▶ if (not $tagTablePtr or $$tagTablePtr{GROUPS}{0} eq 'EXIF') {
Branch: 2 branches
BranchTrueFalseTotal
if (not $tagTablePtr or $tagTablePtr->{'GROUPS'}{'0'} eq 'EXIF') { } 420 76 496
elsif ($tagTablePtr->{'GROUPS'}{'0'} eq 'MakerNotes') { } 19 57 76
Condition100%3/3
not $tagTablePtr or $tagTablePtr->{"GROUPS"}{0} eq "EXIF"
l!l&&r!l&&!r
24317776
MC/DC100%2/2
not $tagTablePtr or $tagTablePtr->{"GROUPS"}{0} eq "EXIF"
not $tagTablePtr $tagTablePtr->{"GROUPS"}{0} eq "EXIF"
Truth table100%3/3
not(A) or B
A= not $tagTablePtrB= $tagTablePtr->{"GROUPS"}{0} eq "EXIF"
ABresult
1X1
011
000
8679 420 ▶ $self->FoundTag('ExifByteOrder', $byteOrder) unless $outfile;
Branch: 1 branch
BranchTrueFalseTotal
unless $outfile 298 122 420
8680 420 $$self{ExifByteOrder} = $byteOrder;
8681 } elsif ($$tagTablePtr{GROUPS}{0} eq 'MakerNotes') { # (for writing CR3 maker notes)
8682 19 $ifdName = $$tagTablePtr{GROUPS}{0};
8683 } else {
8684 57 $ifdName = $$tagTablePtr{GROUPS}{1};
8685 }
8686 496 ▶ if ($$self{HTML_DUMP}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"HTML_DUMP"}) 0 496 496
8687 0 ▶ my $tip = sprintf("Byte order: %s endian\nIdentifier: 0x%.4x\n$ifdName offset: 0x%.4x",
Branch: 1 branch
BranchTrueFalseTotal
$byteOrder eq 'II' ? : 0 0 0
8688 ($byteOrder eq 'II') ? 'Little' : 'Big', $identifier, $offset);
8689 0 $self->HDump($base, 8, 'TIFF header', $tip, 0);
8690 }
8691 # remember where we found the TIFF data (APP1, APP3, TIFF, NEF, etc...)
8692 496 $$self{TIFF_TYPE} = $fileType;
8693  
8694 # get reference to the main EXIF table
8695 496 ▶ $tagTablePtr or $tagTablePtr = GetTagTable('Image::ExifTool::Exif::Main');
Branch: 1 branch
BranchTrueFalseTotal
$tagTablePtr or $tagTablePtr = &GetTagTable("Image::ExifTool::Exif::Main") 253 243 496
8696  
8697 # build directory information hash
8698 my %dirInfo = (
8699 Base => $base,
8700 DataPt => $dataPt,
8701 DataLen => length $$dataPt,
8702 DataPos => 0,
8703 DirStart => $offset,
8704 DirLen => length($$dataPt) - $offset,
8705 RAF => $raf,
8706 DirName => $ifdName,
8707 Parent => $fileType,
8708 ImageData=> 'Main', # set flag to get information to copy main image data later
8709 Multi => $$dirInfo{Multi},
8710 496 );
8711  
8712 # extract information from the image
8713 496 ▶ unless ($outfile) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($outfile) 370 126 496
8714 # process the directory
8715 370 $self->ProcessDirectory(\%dirInfo, $tagTablePtr);
8716 # process GeoTiff information if available
8717 370 ▶ if ($$self{VALUE}{GeoTiffDirectory}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"VALUE"}{"GeoTiffDirectory"}) 7 363 370
8718 7 require Image::ExifTool::GeoTiff;
8719 7 Image::ExifTool::GeoTiff::ProcessGeoTiff($self);
8720 }
8721 # process information in recognized trailers
8722 370 ▶ if ($raf) {
Branch: 1 branch
BranchTrueFalseTotal
if ($raf) 27 343 370
8723 27 my $trailInfo = $self->IdentifyTrailer($raf);
8724 27 ▶ if ($trailInfo) {
Branch: 1 branch
BranchTrueFalseTotal
if ($trailInfo) 3 24 27
8725 # scan to find AFCP if necessary (Note: we are scanning
8726 # from a random file position in the TIFF)
8727 3 $$trailInfo{ScanForTrailer} = 1;
8728 3 $self->ProcessTrailers($trailInfo);
8729 }
8730 # dump any other known trailer (eg. A100 RAW Data)
8731 27 ▶ if ($$self{HTML_DUMP} and $$self{KnownTrailer}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"HTML_DUMP"} and $self->{"KnownTrailer"}) 0 27 27
Condition33%1/3
$self->{"HTML_DUMP"} and $self->{"KnownTrailer"}
!ll&&!rl&&r
2700
MC/DC0%0/2
$self->{"HTML_DUMP"} and $self->{"KnownTrailer"}
$self->{"HTML_DUMP"} $self->{"KnownTrailer"}
Truth table33%1/3
A and B
A= $self->{"HTML_DUMP"}B= $self->{"KnownTrailer"}
ABresult
0X0
100
111
8732 0 my $known = $$self{KnownTrailer};
8733 0 $raf->Seek(0, 2);
8734 0 my $len = $raf->Tell() - $$known{Start};
8735 0 ▶ $len -= $$trailInfo{Offset} if $trailInfo; # account for other trailers
Branch: 1 branch
BranchTrueFalseTotal
if $trailInfo 0 0 0
8736 0 ▶ $self->HDump($$known{Start}, $len, "[$$known{Name}]") if $len > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $len > 0 0 0 0
8737 }
8738 }
8739 # update FileType if necessary now that we know more about the file
8740 370 ▶ if ($$self{DNGVersion} and $$self{FILE_TYPE} eq 'TIFF' and $$self{FileType} !~ /^(DNG|GPR)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"DNGVersion"} and $self->{"FILE_TYPE"} eq "TIFF" and not $self->{"FileType"} =~ /^(DNG|GPR)$/) 0 370 370
Condition66%4/6
$self->{"DNGVersion"} and $self->{"FILE_TYPE"} eq "TIFF" and not $self->{"FileType"} =~ /^(DNG|GPR)$/
!ll&&!rl&&r
36820
$self->{"DNGVersion"} and $self->{"FILE_TYPE"} eq "TIFF"
!ll&&!rl&&r
36802
MC/DC0%0/3
$self->{"DNGVersion"} and $self->{"FILE_TYPE"} eq "TIFF" and not $self->{"FileType"} =~ /^(DNG|GPR)$/
$self->{"DNGVersion"} $self->{"FILE_TYPE"} eq "TIFF" not $self->{"FileType"} =~ /^(DNG|GPR)$/
Truth table50%2/4
A and B and not(C)
A= $self->{"DNGVersion"}B= $self->{"FILE_TYPE"} eq "TIFF"C= not $self->{"FileType"} =~ /^(DNG|GPR)$/
ABCresult
0XX0
10X0
1100
1111
8741 # override whatever FileType we set since we now know it is DNG
8742 0 $self->OverrideFileType($$self{TIFF_TYPE} = 'DNG');
8743 }
8744 370 ▶ if ($$self{TIFF_TYPE} eq 'TIFF') {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'TIFF_TYPE'} eq 'TIFF') { } 10 360 370
elsif ($self->{'TIFF_TYPE'} eq 'NRW' and $self->{'VALUE'}{'NEFLinearizationTable'}) { } 0 720 720
8745 10 ▶ $self->FoundTag(PageCount => $$self{PageCount}) if $$self{MultiPage};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"MultiPage"} 0 10 10
8746 ▶ } elsif ($$self{TIFF_TYPE} eq 'NRW' and $$self{VALUE}{NEFLinearizationTable}) {
Condition33%1/3
$self->{"TIFF_TYPE"} eq "NRW" and $self->{"VALUE"}{"NEFLinearizationTable"}
!ll&&!rl&&r
36000
MC/DC0%0/2
$self->{"TIFF_TYPE"} eq "NRW" and $self->{"VALUE"}{"NEFLinearizationTable"}
$self->{"TIFF_TYPE"} eq "NRW" $self->{"VALUE"}{"NEFLinearizationTable"}
Truth table33%1/3
A and B
A= $self->{"TIFF_TYPE"} eq "NRW"B= $self->{"VALUE"}{"NEFLinearizationTable"}
ABresult
0X0
100
111
8747 # fix NEF type if misidentified as NRW
8748 0 $self->OverrideFileType($$self{TIFF_TYPE} = 'NEF');
8749 }
8750 370 ▶ if ($$self{ImageDataHash} and $$self{A100DataOffset} and $raf->Seek($$self{A100DataOffset},0)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"ImageDataHash"} and $self->{"A100DataOffset"} and $raf->Seek($self->{"A100DataOffset"}, 0)) 0 370 370
Condition33%2/6
$self->{"ImageDataHash"} and $self->{"A100DataOffset"} and $raf->Seek($self->{"A100DataOffset"}, 0)
!ll&&!rl&&r
37000
$self->{"ImageDataHash"} and $self->{"A100DataOffset"}
!ll&&!rl&&r
37000
MC/DC0%0/3
$self->{"ImageDataHash"} and $self->{"A100DataOffset"} and $raf->Seek($self->{"A100DataOffset"}, 0)
$self->{"ImageDataHash"} $self->{"A100DataOffset"} $raf->Seek($self->{"A100DataOffset"}, 0)
Truth table25%1/4
A and B and C
A= $self->{"ImageDataHash"}B= $self->{"A100DataOffset"}C= $raf->Seek($self->{"A100DataOffset"}, 0)
ABCresult
0XX0
10X0
1100
1111
8751 0 $self->ImageDataHash($raf, undef, 'A100');
8752 }
8753 370 return 1;
8754 }
8755 #
8756 # rewrite the image
8757 #
8758 126 ▶ if ($$dirInfo{NoTiffEnd}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dirInfo->{'NoTiffEnd'}) { } 1 125 126
8759 1 delete $$self{TIFF_END};
8760 } else {
8761 # initialize TIFF_END so it will be updated by WriteExif()
8762 125 $$self{TIFF_END} = 0;
8763 }
8764 126 ▶ if ($canonSig) {
Branch: 1 branch
BranchTrueFalseTotal
if ($canonSig) { } 3 123 126
8765 # write Canon CR2 specially because it has a header we want to preserve,
8766 # and possibly trailers added by the Canon utilities and/or PhotoMechanic
8767 3 $dirInfo{OutFile} = $outfile;
8768 3 require Image::ExifTool::CanonRaw;
8769 3 ▶ Image::ExifTool::CanonRaw::WriteCR2($self, \%dirInfo, $tagTablePtr) or $err = 1;
Branch: 1 branch
BranchTrueFalseTotal
Image::ExifTool::CanonRaw::WriteCR2($self, \%dirInfo, $tagTablePtr) or $err = 1 3 0 3
8770 } else {
8771 # write TIFF header (8 bytes [plus optional signature] followed by IFD)
8772 123 ▶ if ($fileType eq 'EXIF') {
Branch: 2 branches
BranchTrueFalseTotal
if ($fileType eq 'EXIF') { } 3 120 123
elsif (not defined $otherSig) { } 119 1 120
8773 3 $otherSig = 'ExifMeta'; # force this signature for all EXIF files
8774 } elsif (not defined $otherSig) {
8775 119 $otherSig = '';
8776 }
8777 123 my $offset = 8 + length($otherSig);
8778 # construct tiff header
8779 123 my $header = substr($$dataPt, 0, 4) . Set32u($offset) . $otherSig;
8780 123 $dirInfo{NewDataPos} = $offset;
8781 123 $dirInfo{HeaderPtr} = \$header;
8782 # preserve padding between image data blocks in ORF images
8783 # (otherwise dcraw has problems because it assumes fixed block spacing)
8784 123 ▶ $dirInfo{PreserveImagePadding} = 1 if $fileType eq 'ORF' or $identifier != 0x2a;
Branch: 1 branch
BranchTrueFalseTotal
if $fileType eq "ORF" or $identifier != 42 1 122 123
Condition66%2/3
$fileType eq "ORF" or $identifier != 42
l!l&&r!l&&!r
01122
MC/DC50%1/2
$fileType eq "ORF" or $identifier != 42
$fileType eq "ORF" $identifier != 42
Truth table66%2/3
A or B
A= $fileType eq "ORF"B= $identifier != 42
ABresult
1X1
011
000
8785 123 my $newData = $self->WriteDirectory(\%dirInfo, $tagTablePtr);
8786 123 ▶ if (not defined $newData) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $newData) { } 0 123 123
elsif (length $newData) { } 117 6 123
8787 0 $err = 1;
8788 } elsif (length($newData)) {
8789 # update header length in case more was added
8790 117 my $hdrLen = length $header;
8791 117 ▶ if ($hdrLen != 8) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hdrLen != 8) 5 112 117
8792 5 Set32u($hdrLen, \$header, 4);
8793 # also update preview fixup if necessary
8794 5 my $pi = $$self{PREVIEW_INFO};
8795 5 ▶ $$pi{Fixup}{Start} += $hdrLen - 8 if $pi and $$pi{Fixup};
Branch: 1 branch
BranchTrueFalseTotal
if $pi and $pi->{"Fixup"} 0 5 5
Condition33%1/3
$pi and $pi->{"Fixup"}
!ll&&!rl&&r
500
MC/DC0%0/2
$pi and $pi->{"Fixup"}
$pi $pi->{"Fixup"}
Truth table33%1/3
A and B
A= $piB= $pi->{"Fixup"}
ABresult
0X0
100
111
8796 }
8797 117 ▶ if ($$self{TIFF_TYPE} eq 'ARW' and not $err) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'TIFF_TYPE'} eq 'ARW' and not $err) { } 0 117 117
Condition33%1/3
$self->{"TIFF_TYPE"} eq "ARW" and not $err
!ll&&!rl&&r
11700
MC/DC0%0/2
$self->{"TIFF_TYPE"} eq "ARW" and not $err
$self->{"TIFF_TYPE"} eq "ARW" not $err
Truth table33%1/3
A and not(B)
A= $self->{"TIFF_TYPE"} eq "ARW"B= not $err
ABresult
0X0
100
111
8798 # write any required ARW trailer and patch other ARW quirks
8799 0 require Image::ExifTool::Sony;
8800 my $errStr = Image::ExifTool::Sony::FinishARW($self, $dirInfo, \$newData,
8801 0 $dirInfo{ImageData});
8802 0 ▶ $errStr and $self->Error($errStr);
Branch: 1 branch
BranchTrueFalseTotal
$errStr and $self->Error($errStr) 0 0 0
8803 0 delete $dirInfo{ImageData}; # (was copied by FinishARW)
8804 } else {
8805 117 ▶ Write($outfile, $header, $newData) or $err = 1;
Branch: 1 branch
BranchTrueFalseTotal
&Write($outfile, $header, $newData) or $err = 1 117 0 117
8806 }
8807 117 undef $newData; # free memory
8808 }
8809 # copy over image data now if necessary
8810 123 ▶ if (ref $dirInfo{ImageData} and not $err) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $dirInfo{"ImageData"} and not $err) 10 113 123
Condition66%2/3
ref $dirInfo{"ImageData"} and not $err
!ll&&!rl&&r
113010
MC/DC50%1/2
ref $dirInfo{"ImageData"} and not $err
ref $dirInfo{"ImageData"} not $err
Truth table66%2/3
A and not(B)
A= ref $dirInfo{"ImageData"}B= not $err
ABresult
0X0
100
111
8811 10 ▶ $self->CopyImageData($dirInfo{ImageData}, $outfile) or $err = 1;
Branch: 1 branch
BranchTrueFalseTotal
$self->CopyImageData($dirInfo{"ImageData"}, $outfile) or $err = 1 10 0 10
8812 10 delete $dirInfo{ImageData};
8813 }
8814 }
8815 # make local copy of TIFF_END now (it may be reset when processing trailers)
8816 126 my $tiffEnd = $$self{TIFF_END};
8817 126 delete $$self{TIFF_END};
8818  
8819 # rewrite trailers if they exist
8820 126 ▶ if ($raf and $tiffEnd and not $err) {
Branch: 1 branch
BranchTrueFalseTotal
if ($raf and $tiffEnd and not $err) 12 114 126
Condition83%5/6
$raf and $tiffEnd and not $err
!ll&&!rl&&r
114012
$raf and $tiffEnd
!ll&&!rl&&r
113112
MC/DC66%2/3
$raf and $tiffEnd and not $err
$raf $tiffEnd not $err
Truth table75%3/4
A and B and not(C)
A= $rafB= $tiffEndC= not $err
ABCresult
0XX0
10X0
1100
1111
8821 12 my ($buf, $trailInfo);
8822 12 ▶ $raf->Seek(0, 2) or $err = 1;
Branch: 1 branch
BranchTrueFalseTotal
$raf->Seek(0, 2) or $err = 1 12 0 12
8823 12 my $extra = $raf->Tell() - $tiffEnd;
8824 # check for trailer and process if possible
8825 12 for (;;) {
8826 12 ▶ last unless $extra > 12;
Branch: 1 branch
BranchTrueFalseTotal
unless $extra > 12 9 3 12
8827 3 $raf->Seek($tiffEnd); # seek back to end of image
8828 3 $trailInfo = $self->IdentifyTrailer($raf);
8829 3 ▶ last unless $trailInfo;
Branch: 1 branch
BranchTrueFalseTotal
unless $trailInfo 3 0 3
8830 0 my $tbuf = '';
8831 0 $$trailInfo{OutFile} = \$tbuf; # rewrite trailer(s)
8832 0 $$trailInfo{ScanForTrailer} = 1; # scan for AFCP if necessary
8833 0 $$self{TrailerStart} = $tiffEnd;
8834 # rewrite all trailers to buffer
8835 0 ▶ unless ($self->ProcessTrailers($trailInfo)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->ProcessTrailers($trailInfo)) 0 0 0
8836 0 undef $trailInfo;
8837 0 $err = 1;
8838 0 last;
8839 }
8840 # calculate unused bytes before trailer
8841 0 $extra = $$trailInfo{DataPos} - $tiffEnd;
8842 0 last; # yes, the 'for' loop was just a cheap 'goto'
8843 }
8844 # ignore a single zero byte if used for padding
8845 12 ▶ if ($extra > 0 and $tiffEnd & 0x01) {
Branch: 1 branch
BranchTrueFalseTotal
if ($extra > 0 and $tiffEnd & 1) 1 11 12
Condition100%3/3
$extra > 0 and $tiffEnd & 1
!ll&&!rl&&r
831
MC/DC100%2/2
$extra > 0 and $tiffEnd & 1
$extra > 0 $tiffEnd & 1
Truth table100%3/3
A and B
A= $extra > 0B= $tiffEnd & 1
ABresult
0X0
100
111
8846 1 ▶ $raf->Seek($tiffEnd, 0) or $err = 1;
Branch: 1 branch
BranchTrueFalseTotal
$raf->Seek($tiffEnd, 0) or $err = 1 1 0 1
8847 1 ▶ $raf->Read($buf, 1) or $err = 1;
Branch: 1 branch
BranchTrueFalseTotal
$raf->Read($buf, 1) or $err = 1 1 0 1
8848 1 ▶ defined $buf and $buf eq "\0" and --$extra, ++$tiffEnd;
Branch: 1 branch
BranchTrueFalseTotal
defined $buf and $buf eq "\0" and --$extra, ++$tiffEnd 1 0 1
Condition33%1/3
defined $buf and $buf eq "\0"
!ll&&!rl&&r
001
MC/DC0%0/2
defined $buf and $buf eq "\0"
defined $buf $buf eq "\0"
Truth table33%1/3
A and B
A= defined $bufB= $buf eq "\0"
ABresult
0X0
100
111
8849 }
8850 12 ▶ if ($extra > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($extra > 0) 3 9 12
8851 3 my $known = $$self{KnownTrailer};
8852 3 ▶ if ($$self{DEL_GROUP}{Trailer} and not $known) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'DEL_GROUP'}{'Trailer'} and not $known) { } 0 3 3
elsif ($known) { } 0 3 3
Condition33%1/3
$self->{"DEL_GROUP"}{"Trailer"} and not $known
!ll&&!rl&&r
300
MC/DC0%0/2
$self->{"DEL_GROUP"}{"Trailer"} and not $known
$self->{"DEL_GROUP"}{"Trailer"} not $known
Truth table33%1/3
A and not(B)
A= $self->{"DEL_GROUP"}{"Trailer"}B= not $known
ABresult
0X0
100
111
8853 0 $self->VPrint(0, " Deleting unknown trailer ($extra bytes)\n");
8854 0 ++$$self{CHANGED};
8855 } elsif ($known) {
8856 0 $self->VPrint(0, " Copying $$known{Name} ($extra bytes)\n");
8857 0 ▶ $raf->Seek($tiffEnd, 0) or $err = 1;
Branch: 1 branch
BranchTrueFalseTotal
$raf->Seek($tiffEnd, 0) or $err = 1 0 0 0
8858 0 ▶ CopyBlock($raf, $outfile, $extra) or $err = 1;
Branch: 1 branch
BranchTrueFalseTotal
&CopyBlock($raf, $outfile, $extra) or $err = 1 0 0 0
8859 } else {
8860 3 ▶ $raf->Seek($tiffEnd, 0) or $err = 1;
Branch: 1 branch
BranchTrueFalseTotal
$raf->Seek($tiffEnd, 0) or $err = 1 3 0 3
8861 # preserve unknown trailer only if it contains non-null data
8862 # (Photoshop CS adds a trailer with 2 null bytes)
8863 3 my $size = $extra;
8864 3 for (;;) {
8865 3 ▶ my $n = $size > 65536 ? 65536 : $size;
Branch: 1 branch
BranchTrueFalseTotal
$size > 65536 ? : 0 3 3
8866 3 ▶ $raf->Read($buf, $n) == $n or $err = 1, last;
Branch: 1 branch
BranchTrueFalseTotal
$raf->Read($buf, $n) == $n or $err = 1, last 3 0 3
8867 3 ▶ if ($buf =~ /[^\0]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($buf =~ /[^\0]/) 3 0 3
8868 3 $self->VPrint(0, " Preserving unknown trailer ($extra bytes)\n");
8869 # copy the trailer since it contains non-null data
8870 3 ▶ Write($outfile, "\0"x($extra-$size)) or $err = 1, last if $size != $extra;
Branch: 1 branch
BranchTrueFalseTotal
if $size != $extra 0 3 3
Condition16%1/6
$size != $extra && (&Write($outfile, scalar "\000" x ($extra - $size)) || ($err = 1, last))
!ll&&!rl&&r
300
&Write($outfile, scalar "\0" x ($extra - $size)) or $err = 1, last
l!l&&r!l&&!r
000
MC/DC0%0/3
$size != $extra && (&Write($outfile, scalar "\000" x ($extra - $size)) || ($err = 1, last))
$size != $extra &Write($outfile, scalar "\0" x ($extra - $size)) $err = 1, last
Truth table0%0/4
A && B or C
A= $size != $extraB= &Write($outfile, scalar "\0" x ($extra - $size))C= $err = 1, last
ABCresult
0XX0
1000
11X1
1011
8871 3 ▶ Write($outfile, $buf) or $err = 1, last;
Branch: 1 branch
BranchTrueFalseTotal
&Write($outfile, $buf) or $err = 1, last 3 0 3
8872 3 ▶ CopyBlock($raf, $outfile, $size-$n) or $err = 1 if $size > $n;
Branch: 1 branch
BranchTrueFalseTotal
if $size > $n 0 3 3
Condition16%1/6
$size > $n && (&CopyBlock($raf, $outfile, $size - $n) || ($err = 1))
!ll&&!rl&&r
300
&CopyBlock($raf, $outfile, $size - $n) or $err = 1
l!l&&r!l&&!r
000
MC/DC0%0/3
$size > $n && (&CopyBlock($raf, $outfile, $size - $n) || ($err = 1))
$size > $n &CopyBlock($raf, $outfile, $size - $n) $err = 1
Truth table0%0/4
A && B or C
A= $size > $nB= &CopyBlock($raf, $outfile, $size - $n)C= $err = 1
ABCresult
0XX0
1000
11X1
1011
8873 3 last;
8874 }
8875 0 $size -= $n;
8876 0 ▶ next if $size > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $size > 0 0 0 0
8877 0 $self->VPrint(0, " Deleting blank trailer ($extra bytes)\n");
8878 0 last;
8879 }
8880 }
8881 }
8882 # write trailer buffer if necessary
8883 12 ▶ $self->WriteTrailerBuffer($trailInfo, $outfile) or $err = 1 if $trailInfo;
Branch: 1 branch
BranchTrueFalseTotal
if $trailInfo 0 12 12
Condition16%1/6
$trailInfo && ($self->WriteTrailerBuffer($trailInfo, $outfile) || ($err = 1))
!ll&&!rl&&r
1200
$self->WriteTrailerBuffer($trailInfo, $outfile) or $err = 1
l!l&&r!l&&!r
000
MC/DC0%0/3
$trailInfo && ($self->WriteTrailerBuffer($trailInfo, $outfile) || ($err = 1))
$trailInfo $self->WriteTrailerBuffer($trailInfo, $outfile) $err = 1
Truth table0%0/4
A && B or C
A= $trailInfoB= $self->WriteTrailerBuffer($trailInfo, $outfile)C= $err = 1
ABCresult
0XX0
1000
11X1
1011
8884 # add any new trailers we are creating
8885 12 my $trailPt = $self->AddNewTrailers();
8886 12 ▶ Write($outfile, $$trailPt) or $err = 1 if $trailPt;
Branch: 1 branch
BranchTrueFalseTotal
if $trailPt 2 10 12
Condition50%3/6
$trailPt && (&Write($outfile, $$trailPt) || ($err = 1))
!ll&&!rl&&r
1020
&Write($outfile, $$trailPt) or $err = 1
l!l&&r!l&&!r
200
MC/DC0%0/3
$trailPt && (&Write($outfile, $$trailPt) || ($err = 1))
$trailPt &Write($outfile, $$trailPt) $err = 1
Truth table0%0/4
A && B or C
A= $trailPtB= &Write($outfile, $$trailPt)C= $err = 1
ABCresult
0XX0
1000
11X1
1011
8887 }
8888 # check DNG version
8889 126 ▶ if ($$self{DNGVersion}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"DNGVersion"}) 1 125 126
8890 1 my $ver = $$self{DNGVersion};
8891 # currently support up to DNG version 1.7
8892 1 ▶ unless ($ver =~ /^(\d+) (\d+)/ and "$1.$2" <= 1.7) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ver =~ /^(\d+) (\d+)/ and "$1.$2" <= "1.7") 0 1 1
Condition33%1/3
$ver =~ /^(\d+) (\d+)/ and "$1.$2" <= "1.7"
!ll&&!rl&&r
001
MC/DC0%0/2
$ver =~ /^(\d+) (\d+)/ and "$1.$2" <= "1.7"
$ver =~ /^(\d+) (\d+)/ "$1.$2" <= "1.7"
Truth table33%1/3
A and B
A= $ver =~ /^(\d+) (\d+)/B= "$1.$2" <= "1.7"
ABresult
0X0
100
111
8893 0 $ver =~ tr/ /./;
8894 0 $self->Error("DNG Version $ver not yet tested", 1);
8895 }
8896 }
8897 126 ▶ return $err ? -1 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$err ? : 0 126 126
8898 }
8899  
8900 #------------------------------------------------------------------------------
8901 # Return list of tag table keys (ignoring special keys)
8902 # Inputs: 0) reference to tag table
8903 # Returns: List of table keys (unsorted)
8904 sub TagTableKeys($)
8905 8162 ▶{
Subroutine TagTableKeys: called CC=3 SCAR=11.0
Pod undocumented
8906 8162 local $_;
8907 8162 my $tagTablePtr = shift;
8908 8162 my @keyList;
8909 8162 foreach (keys %$tagTablePtr) {
8910 521672 ▶ push(@keyList, $_) unless $specialTags{$_};
Branch: 1 branch
BranchTrueFalseTotal
unless $Image::ExifTool::specialTags{$_} 453454 68218 521672
8911 }
8912 8162 return @keyList;
8913 }
8914  
8915 #------------------------------------------------------------------------------
8916 # GetTagTable
8917 # Inputs: 0) table name
8918 # Returns: tag table reference, or undefined if not found
8919 # Notes: Always use this function instead of requiring module and using table
8920 # directly since this function also does the following the first time the table
8921 # is loaded:
8922 # - requires new module if necessary
8923 # - generates default GROUPS hash and Group 0 name from module name
8924 # - registers Composite tags if Composite table found
8925 # - saves descriptions for tags in specified table
8926 # - generates default TAG_PREFIX to be used for unknown tags
8927 sub GetTagTable($)
8928 97544 ▶{
Subroutine GetTagTable: called CC=38 SCAR=39.4
Pod undocumented
8929 97544 ▶ my $tableName = shift or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $tableName = shift() or return undef 97540 4 97544
8930 97540 my $table = $allTables{$tableName};
8931  
8932 97540 ▶ unless ($table) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($table) 4825 92715 97540
8933 113 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
8934 4825 ▶ unless (%$tableName) {
Branch: 1 branch
BranchTrueFalseTotal
unless (%$tableName) 920 3905 4825
8935 # try to load module for this table
8936 920 ▶ if ($tableName =~ /(.*)::/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tableName =~ /(.*)::/) 920 0 920
8937 920 my $module = $1;
8938 920 ▶ if (not eval "require $module") {
Branch: 2 branches
BranchTrueFalseTotal
if (not eval "require $module") { } 0 920 920
elsif (not %$tableName) { } 28 892 920
8939 0 ▶ $@ and warn $@;
Branch: 1 branch
BranchTrueFalseTotal
$@ and warn $@ 0 0 0
8940 } elsif (not %$tableName) {
8941 # load additional modules if required
8942 28 ▶ if ($module eq 'Image::ExifTool::XMP') {
Branch: 2 branches
BranchTrueFalseTotal
if ($module eq 'Image::ExifTool::XMP') { } 28 0 28
elsif ($tableName eq 'Image::ExifTool::QuickTime::Stream') { } 0 0 0
8943 28 require 'Image/ExifTool/XMP2.pl';
8944 } elsif ($tableName eq 'Image::ExifTool::QuickTime::Stream') {
8945 0 require 'Image/ExifTool/QuickTimeStream.pl';
8946 }
8947 }
8948 }
8949 920 ▶ %$tableName or warn("Can't find table $tableName\n"), return undef;
Branch: 1 branch
BranchTrueFalseTotal
%$tableName or warn("Can't find table $tableName\n"), (return undef) 920 0 920
8950 }
8951 113 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
8952 4825 $table = \%$tableName;
8953 113 ▶ use strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
8954 4825 ▶ &{$$table{INIT_TABLE}}($table) if $$table{INIT_TABLE};
Branch: 1 branch
BranchTrueFalseTotal
if $table->{"INIT_TABLE"} 13 4812 4825
8955 4825 $$table{TABLE_NAME} = $tableName; # set table name
8956 4825 ($$table{SHORT_NAME} = $tableName) =~ s/^Image::ExifTool:://;
8957 # set default group 0 and 1 from module name unless already specified
8958 4825 my $defaultGroups = $$table{GROUPS};
8959 4825 ▶ $defaultGroups or $defaultGroups = $$table{GROUPS} = { };
Branch: 1 branch
BranchTrueFalseTotal
$defaultGroups or $defaultGroups = ($table->{"GROUPS"} = {}) 4696 129 4825
8960 4825 ▶ unless ($$defaultGroups{0} and $$defaultGroups{1}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($defaultGroups->{0} and $defaultGroups->{1}) 3829 996 4825
Condition100%3/3
$defaultGroups->{0} and $defaultGroups->{1}
!ll&&!rl&&r
14242405996
MC/DC100%2/2
$defaultGroups->{0} and $defaultGroups->{1}
$defaultGroups->{0} $defaultGroups->{1}
Truth table100%3/3
A and B
A= $defaultGroups->{0}B= $defaultGroups->{1}
ABresult
0X0
100
111
8961 3829 ▶ if ($tableName =~ /Image::.*?::([^:]*)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tableName =~ /Image::.*?::([^:]*)/) { } 3829 0 3829
8962 3829 ▶ $$defaultGroups{0} = $1 unless $$defaultGroups{0};
Branch: 1 branch
BranchTrueFalseTotal
unless $defaultGroups->{0} 1424 2405 3829
8963 3829 ▶ $$defaultGroups{1} = $1 unless $$defaultGroups{1};
Branch: 1 branch
BranchTrueFalseTotal
unless $defaultGroups->{1} 3143 686 3829
8964 } else {
8965 0 ▶ $$defaultGroups{0} = $tableName unless $$defaultGroups{0};
Branch: 1 branch
BranchTrueFalseTotal
unless $defaultGroups->{0} 0 0 0
8966 0 ▶ $$defaultGroups{1} = $tableName unless $$defaultGroups{1};
Branch: 1 branch
BranchTrueFalseTotal
unless $defaultGroups->{1} 0 0 0
8967 }
8968 }
8969 4825 ▶ $$defaultGroups{2} = 'Other' unless $$defaultGroups{2};
Branch: 1 branch
BranchTrueFalseTotal
unless $defaultGroups->{2} 288 4537 4825
8970 4825 ▶ if ($$defaultGroups{0} eq 'XMP' or $$table{NAMESPACE}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($defaultGroups->{0} eq "XMP" or $table->{"NAMESPACE"}) 549 4276 4825
Condition100%3/3
$defaultGroups->{0} eq "XMP" or $table->{"NAMESPACE"}
l!l&&r!l&&!r
54814276
MC/DC100%2/2
$defaultGroups->{0} eq "XMP" or $table->{"NAMESPACE"}
$defaultGroups->{0} eq "XMP" $table->{"NAMESPACE"}
Truth table100%3/3
A or B
A= $defaultGroups->{0} eq "XMP"B= $table->{"NAMESPACE"}
ABresult
1X1
011
000
8971 # initialize some XMP table defaults
8972 549 require Image::ExifTool::XMP;
8973 549 Image::ExifTool::XMP::RegisterNamespace($table); # register all table namespaces
8974 # set default write/check procs
8975 549 ▶ $$table{WRITE_PROC} = \&Image::ExifTool::XMP::WriteXMP unless $$table{WRITE_PROC};
Branch: 1 branch
BranchTrueFalseTotal
unless $table->{"WRITE_PROC"} 24 525 549
8976 549 ▶ $$table{CHECK_PROC} = \&Image::ExifTool::XMP::CheckXMP unless $$table{CHECK_PROC};
Branch: 1 branch
BranchTrueFalseTotal
unless $table->{"CHECK_PROC"} 68 481 549
8977 549 ▶ $$table{LANG_INFO} = \&Image::ExifTool::XMP::GetLangInfo unless $$table{LANG_INFO};
Branch: 1 branch
BranchTrueFalseTotal
unless $table->{"LANG_INFO"} 65 484 549
8978 }
8979 # generate a tag prefix for unknown tags if necessary
8980 4825 ▶ unless (defined $$table{TAG_PREFIX}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $table->{"TAG_PREFIX"}) 4691 134 4825
8981 4691 my $tagPrefix;
8982 4691 ▶ if ($tableName =~ /Image::.*?::(.*)::Main/ || $tableName =~ /Image::.*?::(.*)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tableName =~ /Image::.*?::(.*)::Main/ or $tableName =~ /Image::.*?::(.*)/) { } 4691 0 4691
Condition66%2/3
$tableName =~ /Image::.*?::(.*)::Main/ or $tableName =~ /Image::.*?::(.*)/
l!l&&r!l&&!r
78439070
MC/DC0%0/2
$tableName =~ /Image::.*?::(.*)::Main/ or $tableName =~ /Image::.*?::(.*)/
$tableName =~ /Image::.*?::(.*)::Main/ $tableName =~ /Image::.*?::(.*)/
Truth table66%2/3
A or B
A= $tableName =~ /Image::.*?::(.*)::Main/B= $tableName =~ /Image::.*?::(.*)/
ABresult
1X1
011
000
8983 4691 ($tagPrefix = $1) =~ s/::/_/g;
8984 } else {
8985 0 $tagPrefix = $tableName;
8986 }
8987 4691 $$table{TAG_PREFIX} = $tagPrefix;
8988 }
8989 # set up the new table
8990 4825 SetupTagTable($table);
8991 # add any user-defined tags (except Composite tags, which are handled specially)
8992 4825 ▶ if (%UserDefined and $UserDefined{$tableName} and $table ne \%Image::ExifTool::Composite) {
Branch: 1 branch
BranchTrueFalseTotal
if (%Image::ExifTool::UserDefined and $Image::ExifTool::UserDefined{$tableName} and $table ne \%Image::ExifTool::Composite) 2 4823 4825
Condition83%5/6
%Image::ExifTool::UserDefined and $Image::ExifTool::UserDefined{$tableName} and $table ne \%Image::ExifTool::Composite
!ll&&!rl&&r
482302
%Image::ExifTool::UserDefined and $Image::ExifTool::UserDefined{$tableName}
!ll&&!rl&&r
41926312
MC/DC66%2/3
%Image::ExifTool::UserDefined and $Image::ExifTool::UserDefined{$tableName} and $table ne \%Image::ExifTool::Composite
%Image::ExifTool::UserDefined $Image::ExifTool::UserDefined{$tableName} $table ne \%Image::ExifTool::Composite
Truth table75%3/4
A and B and C
A= %Image::ExifTool::UserDefinedB= $Image::ExifTool::UserDefined{$tableName}C= $table ne \%Image::ExifTool::Composite
ABCresult
0XX0
10X0
1100
1111
8993 2 my $tagID;
8994 2 foreach $tagID (TagTableKeys($UserDefined{$tableName})) {
8995 3 ▶ next if $specialTags{$tagID};
Branch: 1 branch
BranchTrueFalseTotal
if $Image::ExifTool::specialTags{$tagID} 0 3 3
8996 3 delete $$table{$tagID}; # replace any existing entry
8997 3 AddTagToTable($table, $tagID, $UserDefined{$tableName}{$tagID}, 1);
8998 }
8999 }
9000 # remember order we loaded the tables in
9001 4825 push @tableOrder, $tableName;
9002 # insert newly loaded table into list
9003 4825 $allTables{$tableName} = $table;
9004 }
9005 # must check each time to add UserDefined Composite tags because the Composite table
9006 # may be loaded before the UserDefined tags are available
9007 97540 ▶ if ($table eq \%Image::ExifTool::Composite and not $$table{VARS}{LOADED_USERDEFINED} and
Branch: 1 branch
BranchTrueFalseTotal
if ($table eq \%Image::ExifTool::Composite and not $table->{"VARS"}{"LOADED_USERDEFINED"} and %Image::ExifTool::UserDefined and $Image::ExifTool::UserDefined{$tableName}) 0 97540 97540
Condition77%7/9
$table eq \%Image::ExifTool::Composite and not $table->{"VARS"}{"LOADED_USERDEFINED"} and %Image::ExifTool::UserDefined and $Image::ExifTool::UserDefined{$tableName}
!ll&&!rl&&r
973981420
$table eq \%Image::ExifTool::Composite and not $table->{"VARS"}{"LOADED_USERDEFINED"} and %Image::ExifTool::UserDefined
!ll&&!rl&&r
961251273142
$table eq \%Image::ExifTool::Composite and not $table->{"VARS"}{"LOADED_USERDEFINED"}
!ll&&!rl&&r
9612501415
MC/DC0%0/4
$table eq \%Image::ExifTool::Composite and not $table->{"VARS"}{"LOADED_USERDEFINED"} and %Image::ExifTool::UserDefined and $Image::ExifTool::UserDefined{$tableName}
$table eq \%Image::ExifTool::Composite not $table->{"VARS"}{"LOADED_USERDEFINED"} %Image::ExifTool::UserDefined $Image::ExifTool::UserDefined{$tableName}
Truth table60%3/5
A and not(B) and C and D
A= $table eq \%Image::ExifTool::CompositeB= not $table->{"VARS"}{"LOADED_USERDEFINED"}C= %Image::ExifTool::UserDefinedD= $Image::ExifTool::UserDefined{$tableName}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
9008 %UserDefined and $UserDefined{$tableName})
9009 {
9010 0 my $userComp = $UserDefined{$tableName};
9011 0 delete $UserDefined{$tableName}; # (must delete first to avoid infinite recursion)
9012 0 AddCompositeTags($userComp, 1);
9013 0 $UserDefined{$tableName} = $userComp; # (add back again for adding writable tags later)
9014 0 $$table{VARS}{LOADED_USERDEFINED} = 1; # set flag to avoid doing this again
9015 }
9016 97540 return $table;
9017 }
9018  
9019 #------------------------------------------------------------------------------
9020 # Process an image directory
9021 # Inputs: 0) ExifTool object reference, 1) directory information reference
9022 # 2) tag table reference, 3) optional reference to processing procedure
9023 # Returns: Result from processing (1=success)
9024 sub ProcessDirectory($$$;$)
9025 5230 ▶{
Subroutine ProcessDirectory: called CC=18 SCAR=30.2
Pod undocumented
9026 5230 my ($self, $dirInfo, $tagTablePtr, $proc) = @_;
9027  
9028 5230 ▶ return 0 unless $tagTablePtr and $dirInfo;
Branch: 1 branch
BranchTrueFalseTotal
unless $tagTablePtr and $dirInfo 0 5230 5230
Condition33%1/3
$tagTablePtr and $dirInfo
!ll&&!rl&&r
005230
MC/DC0%0/2
$tagTablePtr and $dirInfo
$tagTablePtr $dirInfo
Truth table33%1/3
A and B
A= $tagTablePtrB= $dirInfo
ABresult
0X0
100
111
9029 # use default proc from tag table or EXIF proc as fallback if no proc specified
9030 5230 ▶ $proc or $proc = $$tagTablePtr{PROCESS_PROC} || \&Image::ExifTool::Exif::ProcessExif;
Branch: 1 branch
BranchTrueFalseTotal
$proc or $proc = $tagTablePtr->{"PROCESS_PROC"} || \&Image::ExifTool::Exif::ProcessExif 429 4801 5230
Condition100%2/2
$tagTablePtr->{'PROCESS_PROC'} || \&Image::ExifTool::Exif::ProcessExif
l!l
37471054
MC/DC100%1/1
$tagTablePtr->{'PROCESS_PROC'} || \&Image::ExifTool::Exif::ProcessExif
$tagTablePtr->{'PROCESS_PROC'}
Truth table100%2/2
A
A= $tagTablePtr->{'PROCESS_PROC'}
Aresult
11
00
9031 # set directory name from default group0 name if not done already
9032 5230 my $dirName = $$dirInfo{DirName};
9033 5230 ▶ unless ($dirName) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dirName) 704 4526 5230
9034 704 $dirName = $$tagTablePtr{GROUPS}{0};
9035 704 ▶ $dirName = $$tagTablePtr{GROUPS}{1} if $dirName =~ /^APP\d+$/; # (use specific APP name)
Branch: 1 branch
BranchTrueFalseTotal
if $dirName =~ /^APP\d+$/ 186 518 704
9036 704 $$dirInfo{DirName} = $dirName;
9037 }
9038  
9039 # guard against cyclical recursion into the same directory
9040 5230 ▶ if (defined $$dirInfo{DirStart} and defined $$dirInfo{DataPos} and
Branch: 1 branch
BranchTrueFalseTotal
if (defined $dirInfo->{"DirStart"} and defined $dirInfo->{"DataPos"} and $dirInfo->{"DirLen"} || !defined($dirInfo->{"DirLen"})) 4420 810 5230
Condition100%9/9
defined $dirInfo->{"DirStart"} and defined $dirInfo->{"DataPos"} and $dirInfo->{"DirLen"} || !defined($dirInfo->{"DirLen"})
!ll&&!rl&&r
761494420
defined $dirInfo->{"DirStart"} and defined $dirInfo->{"DataPos"}
!ll&&!rl&&r
2005614469
$dirInfo->{"DirLen"} or not defined $dirInfo->{"DirLen"}
l!l&&r!l&&!r
4419149
MC/DC100%4/4
defined $dirInfo->{"DirStart"} and defined $dirInfo->{"DataPos"} and $dirInfo->{"DirLen"} || !defined($dirInfo->{"DirLen"})
defined $dirInfo->{"DirStart"} defined $dirInfo->{"DataPos"} $dirInfo->{"DirLen"} not defined $dirInfo->{"DirLen"}
Truth table100%5/5
A and B and C or not(D)
A= defined $dirInfo->{"DirStart"}B= defined $dirInfo->{"DataPos"}C= $dirInfo->{"DirLen"}D= not defined $dirInfo->{"DirLen"}
ABCDresult
0XXX0
10XX0
11000
111X1
11011
9041 # directories don't overlap if the length is zero
9042 ($$dirInfo{DirLen} or not defined $$dirInfo{DirLen}))
9043 {
9044 4420 ▶ my $addr = $$dirInfo{DirStart} + $$dirInfo{DataPos} + ($$dirInfo{Base}||0) + $$self{BASE};
Condition100%2/2
$dirInfo->{'Base'} || 0
l!l
29051515
MC/DC100%1/1
$dirInfo->{'Base'} || 0
$dirInfo->{'Base'}
Truth table100%2/2
A
A= $dirInfo->{'Base'}
Aresult
11
00
9045 4420 ▶ if ($$self{PROCESSED}{$addr} and not $$dirInfo{NotDup}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"PROCESSED"}{$addr} and not $dirInfo->{"NotDup"}) 0 4420 4420
Condition33%1/3
$self->{"PROCESSED"}{$addr} and not $dirInfo->{"NotDup"}
!ll&&!rl&&r
442000
MC/DC0%0/2
$self->{"PROCESSED"}{$addr} and not $dirInfo->{"NotDup"}
$self->{"PROCESSED"}{$addr} not $dirInfo->{"NotDup"}
Truth table33%1/3
A and not(B)
A= $self->{"PROCESSED"}{$addr}B= not $dirInfo->{"NotDup"}
ABresult
0X0
100
111
9046 0 $self->Warn("$dirName pointer references previous $$self{PROCESSED}{$addr} directory");
9047 # patch for bug in Windows phone 7.5 O/S that writes incorrect InteropIFD pointer
9048 0 ▶ return 0 unless $dirName eq 'GPS' and $$self{PROCESSED}{$addr} eq 'InteropIFD';
Branch: 1 branch
BranchTrueFalseTotal
unless $dirName eq "GPS" and $self->{"PROCESSED"}{$addr} eq "InteropIFD" 0 0 0
Condition0%0/3
$dirName eq "GPS" and $self->{"PROCESSED"}{$addr} eq "InteropIFD"
!ll&&!rl&&r
000
MC/DC0%0/2
$dirName eq "GPS" and $self->{"PROCESSED"}{$addr} eq "InteropIFD"
$dirName eq "GPS" $self->{"PROCESSED"}{$addr} eq "InteropIFD"
Truth table0%0/3
A and B
A= $dirName eq "GPS"B= $self->{"PROCESSED"}{$addr} eq "InteropIFD"
ABresult
0X0
100
111
9049 }
9050 4420 ▶ $$self{PROCESSED}{$addr} = $dirName unless $$tagTablePtr{VARS} and $$tagTablePtr{VARS}{ALLOW_REPROCESS};
Branch: 1 branch
BranchTrueFalseTotal
unless $tagTablePtr->{"VARS"} and $tagTablePtr->{"VARS"}{"ALLOW_REPROCESS"} 4420 0 4420
Condition66%2/3
$tagTablePtr->{"VARS"} and $tagTablePtr->{"VARS"}{"ALLOW_REPROCESS"}
!ll&&!rl&&r
40543660
MC/DC0%0/2
$tagTablePtr->{"VARS"} and $tagTablePtr->{"VARS"}{"ALLOW_REPROCESS"}
$tagTablePtr->{"VARS"} $tagTablePtr->{"VARS"}{"ALLOW_REPROCESS"}
Truth table66%2/3
A and B
A= $tagTablePtr->{"VARS"}B= $tagTablePtr->{"VARS"}{"ALLOW_REPROCESS"}
ABresult
0X0
100
111
9051 }
9052 5230 my $oldOrder = GetByteOrder();
9053 5230 my @save = @$self{'INDENT','DIR_NAME','Compression','SubfileType'};
9054 5230 $$self{LIST_TAGS} = { }; # don't build lists across different directories
9055 5230 $$self{INDENT} .= '| ';
9056 5230 $$self{DIR_NAME} = $dirName;
9057 5230 push @{$$self{PATH}}, $dirName;
9058 5230 $$self{FOUND_DIR}{$dirName} = 1;
9059  
9060 # process the directory
9061 113 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
9062 5230 my $rtnVal = &$proc($self, $dirInfo, $tagTablePtr);
9063 113 ▶ use strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
9064  
9065 5230 pop @{$$self{PATH}};
9066 5230 @$self{'INDENT','DIR_NAME','Compression','SubfileType'} = @save;
9067 5230 SetByteOrder($oldOrder);
9068 5230 return $rtnVal;
9069 }
9070  
9071 #------------------------------------------------------------------------------
9072 # Get Metadata path
9073 # Inputs: 0) ExifTool object ref
9074 # Return: Metadata path string
9075 sub MetadataPath($)
9076 742 ▶{
Subroutine MetadataPath: called CC=1 SCAR=0.0
Pod undocumented
9077 742 my $self = shift;
9078 742 return join '-', @{$$self{PATH}}
9079 }
9080  
9081 #------------------------------------------------------------------------------
9082 # Get standardized file extension
9083 # Inputs: 0) file name
9084 # Returns: standardized extension (all uppercase), or undefined if no extension
9085 sub GetFileExtension($)
9086 2039 ▶{
Subroutine GetFileExtension: called CC=4 SCAR=13.9
Pod undocumented
9087 2039 my $filename = shift;
9088 2039 my $fileExt;
9089 2039 ▶ if ($filename and $filename =~ /^.*\.([^.]+)$/s) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename and $filename =~ /^.*\.([^.]+)$/s) 1897 142 2039
Condition100%3/3
$filename and $filename =~ /^.*\.([^.]+)$/s
!ll&&!rl&&r
93491897
MC/DC100%2/2
$filename and $filename =~ /^.*\.([^.]+)$/s
$filename $filename =~ /^.*\.([^.]+)$/s
Truth table100%3/3
A and B
A= $filenameB= $filename =~ /^.*\.([^.]+)$/s
ABresult
0X0
100
111
9090 1897 $fileExt = uc($1); # change extension to upper case
9091 # convert TIF extension to TIFF because we use the
9092 # extension for the file type tag of TIFF images
9093 1897 ▶ $fileExt eq 'TIF' and $fileExt = 'TIFF';
Branch: 1 branch
BranchTrueFalseTotal
$fileExt eq "TIF" and $fileExt = "TIFF" 34 1863 1897
9094 }
9095 2039 return $fileExt;
9096 }
9097  
9098 #------------------------------------------------------------------------------
9099 # Get list of tag information hashes for given tag ID
9100 # Inputs: 0) Tag table reference, 1) tag ID
9101 # Returns: Array of tag information references
9102 # Notes: Generates tagInfo hash if necessary
9103 sub GetTagInfoList($$)
9104 610528 ▶{
Subroutine GetTagInfoList: called CC=5 SCAR=16.2
Pod undocumented
9105 610528 my ($tagTablePtr, $tagID) = @_;
9106 610528 my $tagInfo = $$tagTablePtr{$tagID};
9107  
9108 610528 ▶ if ($specialTags{$tagID}) {
Branch: 4 branches
BranchTrueFalseTotal
if ($Image::ExifTool::specialTags{$tagID}) { } 0 610528 610528
elsif (ref $tagInfo eq 'HASH') { } 556576 53952 610528
elsif (ref $tagInfo eq 'ARRAY') { } 11784 42168 53952
elsif ($tagInfo) { } 37641 4527 42168
9109 # (hopefully this won't happen)
9110 0 warn "Tag $tagID conflicts with internal ExifTool variable in $$tagTablePtr{TABLE_NAME}\n";
9111 } elsif (ref $tagInfo eq 'HASH') {
9112 556576 return ($tagInfo);
9113 } elsif (ref $tagInfo eq 'ARRAY') {
9114 11784 return @$tagInfo;
9115 } elsif ($tagInfo) {
9116 # create hash with name
9117 37641 $tagInfo = $$tagTablePtr{$tagID} = { Name => $tagInfo };
9118 37641 return ($tagInfo);
9119 }
9120 4527 return ();
9121 }
9122  
9123 #------------------------------------------------------------------------------
9124 # Find tag information, processing conditional tags
9125 # Inputs: 0) ExifTool object reference, 1) tagTable pointer, 2) tag ID
9126 # 3) optional value reference (usually reference to binary data value, but
9127 # depends on information type), 4) optional format type, 5) optional value count
9128 # Returns: pointer to tagInfo hash, undefined if none found, or '' if $valPt needed
9129 # Notes: You should always call this routine to find a tag in a table because
9130 # this routine will evaluate conditional tags.
9131 # Arguments 3-5 are only required if the information type allows $valPt, $format and/or
9132 # $count in a Condition, and if not given when needed this routine returns ''.
9133 sub GetTagInfo($$$;$$$)
9134 114742 ▶{
Subroutine GetTagInfo: called CC=24 SCAR=31.9
Pod undocumented
9135 114742 my ($self, $tagTablePtr, $tagID) = @_;
9136 114742 my ($valPt, $format, $count);
9137  
9138 114742 my @infoArray = GetTagInfoList($tagTablePtr, $tagID);
9139 114742 my $options = $$self{OPTIONS};
9140 # evaluate condition
9141 114742 my $tagInfo;
9142 114742 foreach $tagInfo (@infoArray) {
9143 120419 my $condition = $$tagInfo{Condition};
9144 120419 ▶ if ($condition) {
Branch: 1 branch
BranchTrueFalseTotal
if ($condition) 14283 106136 120419
9145 14283 ▶ ($valPt, $format, $count) = splice(@_, 3) if @_ > 3;
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 3 879 13404 14283
9146 14283 ▶ return '' if $condition =~ /\$(valPt|format|count)\b/ and not defined $valPt;
Branch: 1 branch
BranchTrueFalseTotal
if $condition =~ /\$(valPt|format|count)\b/ and not defined $valPt 695 13588 14283
Condition100%3/3
$condition =~ /\$(valPt|format|count)\b/ and not defined $valPt
!ll&&!rl&&r
76635925695
MC/DC100%2/2
$condition =~ /\$(valPt|format|count)\b/ and not defined $valPt
$condition =~ /\$(valPt|format|count)\b/ not defined $valPt
Truth table100%3/3
A and not(B)
A= $condition =~ /\$(valPt|format|count)\b/B= not defined $valPt
ABresult
0X0
100
111
9147 # set old value for use in condition if needed
9148 13588 local $SIG{'__WARN__'} = \&SetWarning;
9149 13588 undef $evalWarning;
9150 #### eval Condition ($self, [$valPt, $format, $count])
9151 13588 ▶ unless (eval $condition) {
Branch: 1 branch
BranchTrueFalseTotal
unless (eval $condition) 11043 2545 13588
9152 11043 ▶ $@ and $evalWarning = $@;
Branch: 1 branch
BranchTrueFalseTotal
$@ and $Image::ExifTool::evalWarning = $@ 0 11043 11043
9153 11043 ▶ $self->Warn("Condition $$tagInfo{Name}: " . CleanWarning()) if $evalWarning;
Branch: 1 branch
BranchTrueFalseTotal
if $Image::ExifTool::evalWarning 0 11043 11043
9154 11043 next;
9155 }
9156 }
9157 # don't return Unknown tags unless that option is set or we are writing (also see forum13716)
9158 108681 ▶ if ($$tagInfo{Unknown} and not $$options{Unknown} and
Branch: 1 branch
BranchTrueFalseTotal
if ($tagInfo->{"Unknown"} and not $options->{"Unknown"} and !$self->{"IsWriting"} || $tagInfo->{"AddedUnknown"} and not $options->{"Verbose"} || $self->{"HTML_DUMP"} || $options->{"Validate"} && !$tagInfo->{"AddedUnknown"}) 1957 106724 108681
Condition90%19/21
$tagInfo->{"Unknown"} and not $options->{"Unknown"} and !$self->{"IsWriting"} || $tagInfo->{"AddedUnknown"} and not $options->{"Verbose"} || $self->{"HTML_DUMP"} || $options->{"Validate"} && !$tagInfo->{"AddedUnknown"}
!ll&&!rl&&r
106639851957
$tagInfo->{"Unknown"} and not $options->{"Unknown"} and !$self->{"IsWriting"} || $tagInfo->{"AddedUnknown"}
!ll&&!rl&&r
1064401992042
$tagInfo->{"Unknown"} and not $options->{"Unknown"}
!ll&&!rl&&r
1054539872241
not $self->{"IsWriting"} or $tagInfo->{"AddedUnknown"}
l!l&&r!l&&!r
199844199
$options->{'Verbose'} || $self->{'HTML_DUMP'} || $options->{'Validate'} && !$tagInfo->{'AddedUnknown'}
l!l&&r!l&&!r
8141957
$options->{"Verbose"} or $self->{"HTML_DUMP"}
l!l&&r!l&&!r
8101961
$options->{"Validate"} and not $tagInfo->{"AddedUnknown"}
!ll&&!rl&&r
195704
MC/DC75%6/8
$tagInfo->{"Unknown"} and not $options->{"Unknown"} and !$self->{"IsWriting"} || $tagInfo->{"AddedUnknown"} and not $options->{"Verbose"} || $self->{"HTML_DUMP"} || $options->{"Validate"} && !$tagInfo->{"AddedUnknown"}
$tagInfo->{"Unknown"} not $options->{"Unknown"} not $self->{"IsWriting"} $tagInfo->{"AddedUnknown"} $options->{"Verbose"} $self->{"HTML_DUMP"} $options->{"Validate"} not $tagInfo->{"AddedUnknown"}
Truth table53%7/13
A and not(B) and not(C) or D and not(E or F || G and not(H))
A= $tagInfo->{"Unknown"}B= not $options->{"Unknown"}C= not $self->{"IsWriting"}D= $tagInfo->{"AddedUnknown"}E= $options->{"Verbose"}F= $self->{"HTML_DUMP"}G= $options->{"Validate"}H= not $tagInfo->{"AddedUnknown"}
ABCDEFGHresult
0XXXXXXX0
10XXXXXX0
1100XXXX0
111X1XXX0
111X01XX0
111X00110
11011XXX0
110101XX0
110100110
111X000X1
111X00101
1101000X1
110100101
9159 (not $$self{IsWriting} or $$tagInfo{AddedUnknown}) and not
9160 ($$options{Verbose} or $$self{HTML_DUMP} or
9161 ($$options{Validate} and not $$tagInfo{AddedUnknown})))
9162 {
9163 1957 return undef;
9164 }
9165 # return the tag information we found
9166 106724 return $tagInfo;
9167 }
9168 # generate information for unknown tags (numerical only) if required
9169 5366 ▶ if (not $tagInfo and ($$options{Unknown} or $$options{Verbose} or $$self{HTML_DUMP}) and
Branch: 1 branch
BranchTrueFalseTotal
if (not $tagInfo and $options->{'Unknown'} || $options->{'Verbose'} || $self->{'HTML_DUMP'} and $tagID =~ /^\d+$/ and not $self->{'NO_UNKNOWN'}) { } 589 4777 5366
Condition86%13/15
not $tagInfo and $options->{"Unknown"} || $options->{"Verbose"} || $self->{"HTML_DUMP"} and $tagID =~ /^\d+$/ and not $self->{"NO_UNKNOWN"}
!ll&&!rl&&r
4637140589
not $tagInfo and $options->{"Unknown"} || $options->{"Verbose"} || $self->{"HTML_DUMP"} and $tagID =~ /^\d+$/
!ll&&!rl&&r
4500137729
not $tagInfo and $options->{"Unknown"} || $options->{"Verbose"} || $self->{"HTML_DUMP"}
!ll&&!rl&&r
04500866
$options->{"Unknown"} or $options->{"Verbose"} or $self->{"HTML_DUMP"}
l!l&&r!l&&!r
86604500
$options->{"Unknown"} or $options->{"Verbose"}
l!l&&r!l&&!r
828384500
MC/DC66%4/6
not $tagInfo and $options->{"Unknown"} || $options->{"Verbose"} || $self->{"HTML_DUMP"} and $tagID =~ /^\d+$/ and not $self->{"NO_UNKNOWN"}
not $tagInfo $options->{"Unknown"} $options->{"Verbose"} $self->{"HTML_DUMP"} $tagID =~ /^\d+$/ not $self->{"NO_UNKNOWN"}
Truth table63%7/11
not(A) and B or C or D and E and not(F)
A= not $tagInfoB= $options->{"Unknown"}C= $options->{"Verbose"}D= $self->{"HTML_DUMP"}E= $tagID =~ /^\d+$/F= not $self->{"NO_UNKNOWN"}
ABCDEFresult
0XXXXX0
1000XX0
11XX0X0
101X0X0
10010X0
11XX100
101X100
1001100
11XX111
101X111
1001111
9170 $tagID =~ /^\d+$/ and not $$self{NO_UNKNOWN})
9171 {
9172 589 my $printConv;
9173 589 ▶ if (defined $$tagTablePtr{PRINT_CONV}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $tagTablePtr->{'PRINT_CONV'}) { } 155 434 589
9174 155 $printConv = $$tagTablePtr{PRINT_CONV};
9175 } else {
9176 # limit length of printout (can be very long)
9177 434 $printConv = \&LimitLongValues;
9178 }
9179 589 my $hex = sprintf("0x%.4x", $tagID);
9180 589 my $prefix = $$tagTablePtr{TAG_PREFIX};
9181 589 $tagInfo = {
9182 Name => "${prefix}_$hex",
9183 Description => MakeDescription($prefix, $hex),
9184 Unknown => 1,
9185 Writable => 0, # can't write unknown tags
9186 PrintConv => $printConv,
9187 AddedUnknown => 1,
9188 };
9189 # add tag information to table
9190 589 AddTagToTable($tagTablePtr, $tagID, $tagInfo);
9191 } else {
9192 4777 undef $tagInfo;
9193 }
9194 5366 return $tagInfo;
9195 }
9196  
9197 #------------------------------------------------------------------------------
9198 # Add new tag to table (must use this routine to add new tags to a table)
9199 # Inputs: 0) reference to tag table, 1) tag ID
9200 # 2) [optional] tag name or reference to tag information hash
9201 # 3) [optional] flag to avoid adding prefix when generating tag name
9202 # Returns: tagInfo ref
9203 # Notes: - will not override existing entry in table
9204 # - info need contain no entries when this routine is called
9205 # - tag name is cleaned if necessary
9206 sub AddTagToTable($$;$$)
9207 7230 ▶{
Subroutine AddTagToTable: called CC=22 SCAR=31.7
Pod undocumented
9208 7230 my ($tagTablePtr, $tagID, $tagInfo, $noPrefix) = @_;
9209  
9210 # generate tag info hash if necessary
9211 7230 ▶ $tagInfo = $tagInfo ? { Name => $tagInfo } : { } unless ref $tagInfo eq 'HASH';
Branch: 2 branches
BranchTrueFalseTotal
unless ref $tagInfo eq "HASH" 0 7230 7230
$tagInfo ? : 0 0 0
9212  
9213 # define necessary entries in information hash
9214 7230 ▶ if ($$tagInfo{Groups}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tagInfo->{'Groups'}) { } 496 6734 7230
9215 # fill in default groups from table GROUPS
9216 496 foreach (keys %{$$tagTablePtr{GROUPS}}) {
9217 1488 ▶ next if $$tagInfo{Groups}{$_};
Branch: 1 branch
BranchTrueFalseTotal
if $tagInfo->{"Groups"}{$_} 954 534 1488
9218 534 $$tagInfo{Groups}{$_} = $$tagTablePtr{GROUPS}{$_};
9219 }
9220 } else {
9221 6734 $$tagInfo{Groups} = { %{$$tagTablePtr{GROUPS}} };
9222 }
9223 7230 ▶ $$tagInfo{Flags} and ExpandFlags($tagInfo);
Branch: 1 branch
BranchTrueFalseTotal
$tagInfo->{"Flags"} and &ExpandFlags($tagInfo) 60 7170 7230
9224 $$tagInfo{GotGroups} = 1,
9225 7230 $$tagInfo{Table} = $tagTablePtr;
9226 7230 $$tagInfo{TagID} = $tagID;
9227 7230 ▶ $$tagInfo{Hidden} = 1 unless defined $$tagInfo{Hidden};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $tagInfo->{"Hidden"} 1854 5376 7230
9228 7230 ▶ if (defined $$tagTablePtr{AVOID} and not defined $$tagInfo{Avoid}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $tagTablePtr->{"AVOID"} and not defined $tagInfo->{"Avoid"}) 1744 5486 7230
Condition100%3/3
defined $tagTablePtr->{"AVOID"} and not defined $tagInfo->{"Avoid"}
!ll&&!rl&&r
548511744
MC/DC100%2/2
defined $tagTablePtr->{"AVOID"} and not defined $tagInfo->{"Avoid"}
defined $tagTablePtr->{"AVOID"} not defined $tagInfo->{"Avoid"}
Truth table100%3/3
A and not(B)
A= defined $tagTablePtr->{"AVOID"}B= not defined $tagInfo->{"Avoid"}
ABresult
0X0
100
111
9229 1744 $$tagInfo{Avoid} = $$tagTablePtr{AVOID};
9230 }
9231  
9232 7230 my $name = $$tagInfo{Name};
9233 7230 ▶ $name = $tagID unless defined $name;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $name 516 6714 7230
9234 7230 $name =~ tr/-_a-zA-Z0-9//dc; # remove illegal characters
9235 7230 $name = ucfirst $name; # capitalize first letter
9236 # add tag-name prefix if specified and tag name not provided
9237 7230 ▶ unless (defined $$tagInfo{Name} or $noPrefix or not $$tagTablePtr{TAG_PREFIX}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $tagInfo->{"Name"} or $noPrefix or not $tagTablePtr->{"TAG_PREFIX"}) 514 6716 7230
Condition83%5/6
defined $tagInfo->{"Name"} or $noPrefix or not $tagTablePtr->{"TAG_PREFIX"}
l!l&&r!l&&!r
67160514
defined $tagInfo->{"Name"} or $noPrefix
l!l&&r!l&&!r
67142514
MC/DC66%2/3
defined $tagInfo->{"Name"} or $noPrefix or not $tagTablePtr->{"TAG_PREFIX"}
defined $tagInfo->{"Name"} $noPrefix not $tagTablePtr->{"TAG_PREFIX"}
Truth table75%3/4
A or B or not(C)
A= defined $tagInfo->{"Name"}B= $noPrefixC= not $tagTablePtr->{"TAG_PREFIX"}
ABCresult
1XX1
01X1
0011
0000
9238 # make description to prevent tagID from getting mangled by MakeDescription()
9239 514 $$tagInfo{Description} = MakeDescription($$tagTablePtr{TAG_PREFIX}, $name);
9240 514 $name = "$$tagTablePtr{TAG_PREFIX}_$name";
9241 }
9242 # tag names must be at least 2 characters long and prefer them to start with a letter
9243 7230 ▶ $name = "Tag$name" if length($name) < 2 or $name !~ /^[A-Z]/i;
Branch: 1 branch
BranchTrueFalseTotal
if length $name < 2 or not $name =~ /^[A-Z]/i 13 7217 7230
Condition66%2/3
length $name < 2 or not $name =~ /^[A-Z]/i
l!l&&r!l&&!r
1307217
MC/DC50%1/2
length $name < 2 or not $name =~ /^[A-Z]/i
length $name < 2 not $name =~ /^[A-Z]/i
Truth table66%2/3
A or not(B)
A= length $name < 2B= not $name =~ /^[A-Z]/i
ABresult
1X1
011
000
9244 7230 $$tagInfo{Name} = $name;
9245 # add tag to table, but never override existing entries (could potentially happen
9246 # if someone thinks there isn't any tagInfo because a condition wasn't satisfied)
9247 7230 ▶ unless (defined $$tagTablePtr{$tagID} or $specialTags{$tagID}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $tagTablePtr->{$tagID} or $Image::ExifTool::specialTags{$tagID}) 7163 67 7230
Condition66%2/3
defined $tagTablePtr->{$tagID} or $Image::ExifTool::specialTags{$tagID}
l!l&&r!l&&!r
6707163
MC/DC50%1/2
defined $tagTablePtr->{$tagID} or $Image::ExifTool::specialTags{$tagID}
defined $tagTablePtr->{$tagID} $Image::ExifTool::specialTags{$tagID}
Truth table66%2/3
A or B
A= defined $tagTablePtr->{$tagID}B= $Image::ExifTool::specialTags{$tagID}
ABresult
1X1
011
000
9248 7163 $$tagTablePtr{$tagID} = $tagInfo;
9249 7163 ▶ if ($purgeFlag and $$tagInfo{Unknown} and not $$tagInfo{SubDirectory}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($purgeFlag and $tagInfo->{"Unknown"} and not $tagInfo->{"SubDirectory"}) 0 7163 7163
Condition33%2/6
$purgeFlag and $tagInfo->{"Unknown"} and not $tagInfo->{"SubDirectory"}
!ll&&!rl&&r
716300
$purgeFlag and $tagInfo->{"Unknown"}
!ll&&!rl&&r
716300
MC/DC0%0/3
$purgeFlag and $tagInfo->{"Unknown"} and not $tagInfo->{"SubDirectory"}
$purgeFlag $tagInfo->{"Unknown"} not $tagInfo->{"SubDirectory"}
Truth table25%1/4
A and B and not(C)
A= $purgeFlagB= $tagInfo->{"Unknown"}C= not $tagInfo->{"SubDirectory"}
ABCresult
0XX0
10X0
1100
1111
9250 0 push @purgeTags, $tagInfo;
9251 }
9252 }
9253 7230 ▶ $$tagInfo{AddedUnknown} = 1 if $$tagInfo{Unknown};
Branch: 1 branch
BranchTrueFalseTotal
if $tagInfo->{"Unknown"} 1125 6105 7230
9254 7230 return $tagInfo;
9255 }
9256  
9257 #------------------------------------------------------------------------------
9258 # Handle simple extraction of new tag information
9259 # Inputs: 0) ExifTool object ref, 1) tag table reference, 2) tagID, 3) raw value,
9260 # 4-N) parameters hash: Index, DataPt, DataPos, Base, Start, Size, Parent,
9261 # TagInfo, ProcessProc, RAF, Format, Count, MakeTagInfo
9262 # Returns: tag key or undef if tag not found
9263 # Notes: if value is not defined, it is extracted from DataPt using TagInfo
9264 # Format and Count if provided
9265 # - set MakeTagInfo to add tag info for unknown tags with name made from tag ID
9266 sub HandleTag($$$$;%)
9267 9771 ▶{
Subroutine HandleTag: called CC=66 SCAR=55.0
Pod undocumented
9268 9771 my ($self, $tagTablePtr, $tag, $val, %parms) = @_;
9269 9771 my $verbose = $$self{OPTIONS}{Verbose};
9270 9771 my $pfmt = $parms{Format};
9271 9771 ▶ my $valPt = defined $val ? \$val : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $val ? : 7589 2182 9771
9272 9771 ▶ my $tagInfo = $parms{TagInfo} || $self->GetTagInfo($tagTablePtr, $tag, $valPt, $pfmt, $parms{Count});
Condition100%3/3
$parms{'TagInfo'} || $self->GetTagInfo($tagTablePtr, $tag, $valPt, $pfmt, $parms{'Count'})
l!l&&r!l&&!r
161159652195
MC/DC100%2/2
$parms{'TagInfo'} || $self->GetTagInfo($tagTablePtr, $tag, $valPt, $pfmt, $parms{'Count'})
$parms{'TagInfo'} $self->GetTagInfo($tagTablePtr, $tag, $valPt, $pfmt, $parms{'Count'})
Truth table100%3/3
A || B
A= $parms{'TagInfo'}B= $self->GetTagInfo($tagTablePtr, $tag, $valPt, $pfmt, $parms{'Count'})
ABresult
1X1
011
000
9273 9771 my $dataPt = $parms{DataPt};
9274 9771 my ($subdir, $format, $noTagInfo, $rational, $binVal);
9275  
9276 # get binary data for Condition if necessary
9277 9771 ▶ if (not $tagInfo and defined $tagInfo and $dataPt) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $tagInfo and defined $tagInfo and $dataPt) 0 9771 9771
Condition50%3/6
not $tagInfo and defined $tagInfo and $dataPt
!ll&&!rl&&r
977100
not $tagInfo and defined $tagInfo
!ll&&!rl&&r
757621950
MC/DC0%0/3
not $tagInfo and defined $tagInfo and $dataPt
not $tagInfo defined $tagInfo $dataPt
Truth table50%2/4
not(A) and B and C
A= not $tagInfoB= defined $tagInfoC= $dataPt
ABCresult
0XX0
10X0
1100
1111
9278 0 ▶ my $start = $parms{Start} || 0;
Condition0%0/2
$parms{'Start'} || 0
l!l
00
MC/DC0%0/1
$parms{'Start'} || 0
$parms{'Start'}
Truth table0%0/2
A
A= $parms{'Start'}
Aresult
11
00
9279 0 my $size = $parms{Size};
9280 0 ▶ $size = length($$dataPt) - $start unless defined $size;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $size 0 0 0
9281 0 ▶ return undef if $start + $size > length($$dataPt);
Branch: 1 branch
BranchTrueFalseTotal
if $start + $size > length $$dataPt 0 0 0
9282 0 ▶ $size = 1024 if $size > 1024; # max 1024 bytes available for the Condition
Branch: 1 branch
BranchTrueFalseTotal
if $size > 1024 0 0 0
9283 0 my $dat = substr($$dataPt, $start, $size);
9284 0 $tagInfo = $self->GetTagInfo($tagTablePtr, $tag, \$dat, $pfmt, $parms{Count});
9285 }
9286 9771 ▶ if ($tagInfo) {
Branch: 2 branches
BranchTrueFalseTotal
if ($tagInfo) { } 7576 2195 9771
elsif ($parms{'MakeTagInfo'}) { } 0 2195 2195
9287 7576 $subdir = $$tagInfo{SubDirectory};
9288 } elsif ($parms{MakeTagInfo}) {
9289 0 ▶ $self->VPrint(0, $$self{INDENT}, "[adding $tag]\n") if $verbose;
Branch: 1 branch
BranchTrueFalseTotal
if $verbose 0 0 0
9290 0 my $name = $tag;
9291 0 $name =~ s/([A-Z]) ([A-Z][ A-Z])/${1}_$2/g; # underline between acronyms
9292 0 $name =~ s/([^A-Za-z])([a-z])/$1\u$2/g; # capitalize words
9293 0 $name =~ tr/-_a-zA-Z0-9//dc; # remove illegal characters
9294 0 ▶ $name = "Tag$name" if length($name) < 2 or $name =~ /^[-0-9]/;
Branch: 1 branch
BranchTrueFalseTotal
if length $name < 2 or $name =~ /^[-0-9]/ 0 0 0
Condition0%0/3
length $name < 2 or $name =~ /^[-0-9]/
l!l&&r!l&&!r
000
MC/DC0%0/2
length $name < 2 or $name =~ /^[-0-9]/
length $name < 2 $name =~ /^[-0-9]/
Truth table0%0/3
A or B
A= length $name < 2B= $name =~ /^[-0-9]/
ABresult
1X1
011
000
9295 0 $tagInfo = { Name => ucfirst($name) };
9296 0 AddTagToTable($tagTablePtr, $tag, $tagInfo);
9297 } else {
9298 2195 ▶ return undef unless $verbose;
Branch: 1 branch
BranchTrueFalseTotal
unless $verbose 2195 0 2195
9299 0 $tagInfo = { Name => "tag $tag" }; # create temporary tagInfo hash
9300 0 $noTagInfo = 1;
9301 }
9302 # read value if not done already (not necessary for subdir)
9303 7576 ▶ unless (defined $val or ($subdir and not $$tagInfo{Writable} and not $$tagInfo{RawConv})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $val or $subdir and not $tagInfo->{"Writable"} and not $tagInfo->{"RawConv"}) 890 6686 7576
Condition77%7/9
defined $val or $subdir and not $tagInfo->{"Writable"} and not $tagInfo->{"RawConv"}
l!l&&r!l&&!r
6108578890
$subdir and not $tagInfo->{"Writable"} and not $tagInfo->{"RawConv"}
!ll&&!rl&&r
8900578
$subdir and not $tagInfo->{"Writable"}
!ll&&!rl&&r
8900578
MC/DC50%2/4
defined $val or $subdir and not $tagInfo->{"Writable"} and not $tagInfo->{"RawConv"}
defined $val $subdir not $tagInfo->{"Writable"} not $tagInfo->{"RawConv"}
Truth table60%3/5
A or B and not(C) and not(D)
A= defined $valB= $subdirC= not $tagInfo->{"Writable"}D= not $tagInfo->{"RawConv"}
ABCDresult
1XXX1
01111
00XX0
010X0
01100
9304 890 ▶ my $start = $parms{Start} || 0;
Condition100%2/2
$parms{'Start'} || 0
l!l
87317
MC/DC100%1/1
$parms{'Start'} || 0
$parms{'Start'}
Truth table100%2/2
A
A= $parms{'Start'}
Aresult
11
00
9305 890 ▶ my $dLen = $dataPt ? length($$dataPt) : -1;
Branch: 1 branch
BranchTrueFalseTotal
$dataPt ? : 890 0 890
9306 890 my $size = $parms{Size};
9307 890 ▶ defined $size or $size = ($dLen > 0 ? $dLen : 0);
Branch: 2 branches
BranchTrueFalseTotal
defined $size or $size = $dLen > 0 ? $dLen : 0 883 7 890
$dLen > 0 ? : 7 0 7
9308 # read from data in memory if possible
9309 890 ▶ if ($start >= 0 and $start + $size <= $dLen) {
Branch: 1 branch
BranchTrueFalseTotal
if ($start >= 0 and $start + $size <= $dLen) { } 890 0 890
Condition33%1/3
$start >= 0 and $start + $size <= $dLen
!ll&&!rl&&r
00890
MC/DC0%0/2
$start >= 0 and $start + $size <= $dLen
$start >= 0 $start + $size <= $dLen
Truth table33%1/3
A and B
A= $start >= 0B= $start + $size <= $dLen
ABresult
0X0
100
111
9310 890 ▶ $format = $$tagInfo{Format} || $$tagTablePtr{FORMAT};
Condition100%3/3
$tagInfo->{'Format'} || $tagTablePtr->{'FORMAT'}
l!l&&r!l&&!r
8225783
MC/DC100%2/2
$tagInfo->{'Format'} || $tagTablePtr->{'FORMAT'}
$tagInfo->{'Format'} $tagTablePtr->{'FORMAT'}
Truth table100%3/3
A || B
A= $tagInfo->{'Format'}B= $tagTablePtr->{'FORMAT'}
ABresult
1X1
011
000
9311 890 ▶ $format = $pfmt if not $format and $pfmt and $formatSize{$pfmt};
Branch: 1 branch
BranchTrueFalseTotal
if not $format and $pfmt and $formatSize{$pfmt} 331 559 890
Condition83%5/6
not $format and $pfmt and $formatSize{$pfmt}
!ll&&!rl&&r
5590331
not $format and $pfmt
!ll&&!rl&&r
107452331
MC/DC66%2/3
not $format and $pfmt and $formatSize{$pfmt}
not $format $pfmt $formatSize{$pfmt}
Truth table75%3/4
not(A) and B and C
A= not $formatB= $pfmtC= $formatSize{$pfmt}
ABCresult
0XX0
10X0
1100
1111
9312 890 ▶ if (not $format) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $format) { } 452 438 890
elsif (not $tagInfo->{'ByteOrder'}) { } 438 0 438
9313 452 $val = substr($$dataPt, $start, $size);
9314 } elsif (not $$tagInfo{ByteOrder}) {
9315 438 $val = ReadValue($dataPt, $start, $format, $$tagInfo{Count}, $size, \$rational);
9316 } else {
9317 0 my $oldOrder = GetByteOrder(), SetByteOrder($$tagInfo{ByteOrder});
9318 0 $val = ReadValue($dataPt, $start, $format, $$tagInfo{Count}, $size, \$rational);
9319 0 SetByteOrder($oldOrder);
9320 }
9321 890 ▶ $binVal = substr($$dataPt, $start, $size) if $$self{OPTIONS}{SaveBin};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"OPTIONS"}{"SaveBin"} 0 890 890
9322 } else {
9323 0 $self->Warn("Error extracting value for $$tagInfo{Name}");
9324 0 return undef;
9325 }
9326 }
9327 # do verbose print if necessary
9328 7576 ▶ if ($verbose) {
Branch: 1 branch
BranchTrueFalseTotal
if ($verbose) 51 7525 7576
9329 51 ▶ undef $tagInfo if $noTagInfo;
Branch: 1 branch
BranchTrueFalseTotal
if $noTagInfo 0 51 51
9330 51 $parms{Value} = $val;
9331 51 ▶ $parms{Value} .= " ($rational)" if defined $rational;
Branch: 1 branch
BranchTrueFalseTotal
if defined $rational 0 51 51
9332 51 $parms{Table} = $tagTablePtr;
9333 51 ▶ if ($format) {
Branch: 1 branch
BranchTrueFalseTotal
if ($format) 0 51 51
9334 0 ▶ my $count = int(($parms{Size} || 0) / ($formatSize{$format} || 1));
Condition0%0/4
$parms{'Size'} || 0
l!l
00
$formatSize{$format} || 1
l!l
00
MC/DC0%0/1
$parms{'Size'} || 0
$parms{'Size'}
MC/DC0%0/1
$formatSize{$format} || 1
$formatSize{$format}
Truth table0%0/2
A
A= $parms{'Size'}
Aresult
11
00
Truth table0%0/2
A
A= $formatSize{$format}
Aresult
11
00
9335 0 $parms{Format} = $format . "[$count]";
9336 }
9337 51 $self->VerboseInfo($tag, $tagInfo, %parms);
9338 }
9339 7576 ▶ if ($tagInfo) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tagInfo) 7576 0 7576
9340 7576 ▶ if ($subdir) {
Branch: 1 branch
BranchTrueFalseTotal
if ($subdir) 753 6823 7576
9341 753 ▶ if ($$tagInfo{MakerNotes} and $$self{OPTIONS}{FastScan} and $$self{OPTIONS}{FastScan} > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tagInfo->{"MakerNotes"} and $self->{"OPTIONS"}{"FastScan"} and $self->{"OPTIONS"}{"FastScan"} > 1) 0 753 753
Condition50%3/6
$tagInfo->{"MakerNotes"} and $self->{"OPTIONS"}{"FastScan"} and $self->{"OPTIONS"}{"FastScan"} > 1
!ll&&!rl&&r
75300
$tagInfo->{"MakerNotes"} and $self->{"OPTIONS"}{"FastScan"}
!ll&&!rl&&r
741120
MC/DC0%0/3
$tagInfo->{"MakerNotes"} and $self->{"OPTIONS"}{"FastScan"} and $self->{"OPTIONS"}{"FastScan"} > 1
$tagInfo->{"MakerNotes"} $self->{"OPTIONS"}{"FastScan"} $self->{"OPTIONS"}{"FastScan"} > 1
Truth table50%2/4
A and B and C
A= $tagInfo->{"MakerNotes"}B= $self->{"OPTIONS"}{"FastScan"}C= $self->{"OPTIONS"}{"FastScan"} > 1
ABCresult
0XX0
10X0
1100
1111
9342 0 return undef; # don't process maker note directories when FastScan > 1
9343 }
9344 753 my $subdirStart = $parms{Start};
9345 753 my $subdirLen = $parms{Size};
9346 753 ▶ if ($$tagInfo{RawConv} and not $$tagInfo{Writable}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($tagInfo->{'RawConv'} and not $tagInfo->{'Writable'}) { } 1 752 753
elsif (not $dataPt) { } 13 739 752
Condition66%2/3
$tagInfo->{"RawConv"} and not $tagInfo->{"Writable"}
!ll&&!rl&&r
75201
MC/DC50%1/2
$tagInfo->{"RawConv"} and not $tagInfo->{"Writable"}
$tagInfo->{"RawConv"} not $tagInfo->{"Writable"}
Truth table66%2/3
A and not(B)
A= $tagInfo->{"RawConv"}B= not $tagInfo->{"Writable"}
ABresult
0X0
100
111
9347 1 my $conv = $$tagInfo{RawConv};
9348 1 local $SIG{'__WARN__'} = \&SetWarning;
9349 1 undef $evalWarning;
9350 1 ▶ if (ref $conv eq 'CODE') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $conv eq 'CODE') { } 0 1 1
9351 0 $val = &$conv($val, $self);
9352 } else {
9353 1 my ($priority, @grps);
9354 # NOTE: RawConv is evaluated in Writer.pl and twice in ExifTool.pm
9355 #### eval RawConv ($self, $val, $tag, $tagInfo, $priority, @grps)
9356 1 $val = eval $conv;
9357 1 ▶ $@ and $evalWarning = $@;
Branch: 1 branch
BranchTrueFalseTotal
$@ and $Image::ExifTool::evalWarning = $@ 0 1 1
9358 }
9359 1 ▶ $self->Warn("RawConv $tag: " . CleanWarning()) if $evalWarning;
Branch: 1 branch
BranchTrueFalseTotal
if $Image::ExifTool::evalWarning 0 1 1
9360 1 ▶ return undef unless defined $val;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $val 0 1 1
9361 1 ▶ $dataPt = ref $val eq 'SCALAR' ? $val : \$val;
Branch: 1 branch
BranchTrueFalseTotal
ref $val eq 'SCALAR' ? : 1 0 1
9362 1 $subdirStart = 0;
9363 1 $subdirLen = length $$dataPt;
9364 } elsif (not $dataPt) {
9365 13 ▶ $dataPt = ref $val eq 'SCALAR' ? $val : \$val;
Branch: 1 branch
BranchTrueFalseTotal
ref $val eq 'SCALAR' ? : 1 12 13
9366 }
9367 753 ▶ if ($$subdir{Start}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($subdir->{"Start"}) 8 745 753
9368 8 my $valuePtr = 0;
9369 #### eval Start ($valuePtr)
9370 8 my $off = eval $$subdir{Start};
9371 8 $subdirStart += $off;
9372 8 $subdirLen -= $off;
9373 }
9374 # process subdirectory information
9375 my %dirInfo = (
9376 DirName => $$subdir{DirName} || $$tagInfo{Name},
9377 DataPt => $dataPt,
9378 DataLen => length $$dataPt,
9379 DataPos => $parms{DataPos},
9380 DirStart => $subdirStart,
9381 DirLen => $subdirLen,
9382 DirID => $tag,
9383 Parent => $parms{Parent},
9384 Base => $parms{Base},
9385 Multi => $$subdir{Multi},
9386 TagInfo => $tagInfo,
9387 IgnoreProp => $$subdir{IgnoreProp},
9388 RAF => $parms{RAF},
9389 753 ▶ );
Condition66%2/3
$subdir->{'DirName'} || $tagInfo->{'Name'}
l!l&&r!l&&!r
1655880
MC/DC0%0/2
$subdir->{'DirName'} || $tagInfo->{'Name'}
$subdir->{'DirName'} $tagInfo->{'Name'}
Truth table66%2/3
A || B
A= $subdir->{'DirName'}B= $tagInfo->{'Name'}
ABresult
1X1
011
000
9390 753 my $oldOrder = GetByteOrder();
9391 753 ▶ if ($$subdir{ByteOrder}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($subdir->{"ByteOrder"}) 3 750 753
9392 3 ▶ if ($$subdir{ByteOrder} eq 'Unknown') {
Branch: 1 branch
BranchTrueFalseTotal
if ($subdir->{'ByteOrder'} eq 'Unknown') { } 1 2 3
9393 1 ▶ if ($subdirStart + 2 <= $subdirLen) {
Branch: 1 branch
BranchTrueFalseTotal
if ($subdirStart + 2 <= $subdirLen) 1 0 1
9394 # attempt to determine the byte ordering of an IFD-style subdirectory
9395 1 my $num = Get16u($dataPt, $subdirStart);
9396 1 ▶ ToggleByteOrder if $num & 0xff00 and ($num>>8) > ($num&0xff);
Branch: 1 branch
BranchTrueFalseTotal
if $num & 65280 and $num >> 8 > ($num & 255) 1 0 1
Condition33%1/3
$num & 65280 and $num >> 8 > ($num & 255)
!ll&&!rl&&r
001
MC/DC0%0/2
$num & 65280 and $num >> 8 > ($num & 255)
$num & 65280 $num >> 8 > ($num & 255)
Truth table33%1/3
A and B
A= $num & 65280B= $num >> 8 > ($num & 255)
ABresult
0X0
100
111
9397 }
9398 } else {
9399 2 SetByteOrder($$subdir{ByteOrder});
9400 }
9401 }
9402 753 ▶ my $subTablePtr = GetTagTable($$subdir{TagTable}) || $tagTablePtr;
Condition33%1/3
&GetTagTable($subdir->{'TagTable'}) || $tagTablePtr
l!l&&r!l&&!r
75300
MC/DC0%0/2
&GetTagTable($subdir->{'TagTable'}) || $tagTablePtr
&GetTagTable($subdir->{'TagTable'}) $tagTablePtr
Truth table33%1/3
A || B
A= &GetTagTable($subdir->{'TagTable'})B= $tagTablePtr
ABresult
1X1
011
000
9403 753 ▶ $self->ProcessDirectory(\%dirInfo, $subTablePtr, $$subdir{ProcessProc} || $parms{ProcessProc});
Condition100%3/3
$subdir->{'ProcessProc'} || $parms{'ProcessProc'}
l!l&&r!l&&!r
5935659
MC/DC100%2/2
$subdir->{'ProcessProc'} || $parms{'ProcessProc'}
$subdir->{'ProcessProc'} $parms{'ProcessProc'}
Truth table100%3/3
A || B
A= $subdir->{'ProcessProc'}B= $parms{'ProcessProc'}
ABresult
1X1
011
000
9404 753 SetByteOrder($oldOrder);
9405 # return now unless directory is writable as a block
9406 753 ▶ return undef unless $$tagInfo{Writable};
Branch: 1 branch
BranchTrueFalseTotal
unless $tagInfo->{"Writable"} 753 0 753
9407 }
9408 6823 my $key = $self->FoundTag($tagInfo, $val);
9409 6823 ▶ if (defined $key) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $key) 6814 9 6823
9410 # save original components of rational numbers and original binary value
9411 6814 ▶ $$self{TAG_EXTRA}{$key}{Rational} = $rational if defined $rational;
Branch: 1 branch
BranchTrueFalseTotal
if defined $rational 12 6802 6814
9412 6814 ▶ $$self{TAG_EXTRA}{$key}{BinVal} = $binVal if defined $binVal;
Branch: 1 branch
BranchTrueFalseTotal
if defined $binVal 0 6814 6814
9413 }
9414 6823 return $key;
9415 }
9416 0 return undef;
9417 }
9418  
9419 #------------------------------------------------------------------------------
9420 # Add tag to hash of extracted information
9421 # Inputs: 0) ExifTool object reference
9422 # 1) reference to tagInfo hash or tag name
9423 # 2) data value (or reference to require hash if Composite)
9424 # 3) optional family 0 group, 4) optional family 1 group
9425 # Returns: tag key or undef if no value
9426 sub FoundTag($$$;@)
9427 61467 ▶{
Subroutine FoundTag: called CC=68 SCAR=43.6
Pod undocumented
9428 61467 local $_;
9429 61467 my ($self, $tagInfo, $value, @grps) = @_;
9430 61467 my ($tag, $noListDel, $tbl);
9431 61467 my $options = $$self{OPTIONS};
9432  
9433 61467 ▶ if (ref $tagInfo eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $tagInfo eq 'HASH') { } 53662 7805 61467
9434 53662 ▶ $tag = $$tagInfo{Name} or warn("No tag name\n"), return undef;
Branch: 1 branch
BranchTrueFalseTotal
$tag = $tagInfo->{"Name"} or warn("No tag name\n"), (return undef) 53662 0 53662
9435 53662 $tbl = $$tagInfo{Table};
9436 } else {
9437 7805 $tag = $tagInfo;
9438 # look for tag in Extra
9439 7805 $tbl = GetTagTable('Image::ExifTool::Extra');
9440 7805 $tagInfo = $self->GetTagInfo($tbl, $tag);
9441 # make temporary hash if tag doesn't exist in Extra
9442 # (not advised to do this since the tag won't show in list)
9443 7805 ▶ $tagInfo or $tagInfo = { Name => $tag, Groups => \%allGroupsExifTool };
Branch: 1 branch
BranchTrueFalseTotal
$tagInfo or $tagInfo = {"Name", $tag, "Groups", \%allGroupsExifTool} 7803 2 7805
9444 7805 ▶ $$options{Verbose} and $self->VerboseInfo(undef, $tagInfo, Value => $value);
Branch: 1 branch
BranchTrueFalseTotal
$options->{"Verbose"} and $self->VerboseInfo(undef, $tagInfo, "Value", $value) 39 7766 7805
9445 }
9446 # get tag priority
9447 61467 my $priority = $$tagInfo{Priority};
9448 61467 ▶ unless (defined $priority) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $priority) 55161 6306 61467
9449 55161 $priority = $$tbl{PRIORITY};
9450 55161 ▶ $priority = 0 if not defined $priority and $$tagInfo{Avoid};
Branch: 1 branch
BranchTrueFalseTotal
if not defined $priority and $tagInfo->{"Avoid"} 55 55106 55161
Condition100%3/3
not defined $priority and $tagInfo->{"Avoid"}
!ll&&!rl&&r
20995300755
MC/DC100%2/2
not defined $priority and $tagInfo->{"Avoid"}
not defined $priority $tagInfo->{"Avoid"}
Truth table100%3/3
not(A) and B
A= not defined $priorityB= $tagInfo->{"Avoid"}
ABresult
0X0
100
111
9451 }
9452 61467 ▶ $grps[0] or $grps[0] = $$self{SET_GROUP0};
Branch: 1 branch
BranchTrueFalseTotal
$grps[0] or $grps[0] = $self->{"SET_GROUP0"} 14 61453 61467
9453 61467 ▶ $grps[1] or $grps[1] = $$self{SET_GROUP1};
Branch: 1 branch
BranchTrueFalseTotal
$grps[1] or $grps[1] = $self->{"SET_GROUP1"} 14 61453 61467
9454 61467 ▶ if ($$options{IgnoreGroups}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($options->{"IgnoreGroups"}) 0 61467 61467
9455 0 foreach (0..1) {
9456 0 ▶ my $g = lc($grps[$_] || $$tagInfo{Groups}{$_} || $$tagInfo{Table}{GROUPS}{$_});
Condition0%0/6
$grps[$_] || $tagInfo->{'Groups'}{$_} || $tagInfo->{'Table'}{'GROUPS'}{$_}
l!l&&r!l&&!r
000
$grps[$_] or $tagInfo->{"Groups"}{$_}
l!l&&r!l&&!r
000
MC/DC0%0/3
$grps[$_] || $tagInfo->{'Groups'}{$_} || $tagInfo->{'Table'}{'GROUPS'}{$_}
$grps[$_] $tagInfo->{"Groups"}{$_} $tagInfo->{'Table'}{'GROUPS'}{$_}
Truth table0%0/4
A or B || C
A= $grps[$_]B= $tagInfo->{"Groups"}{$_}C= $tagInfo->{'Table'}{'GROUPS'}{$_}
ABCresult
1XX1
01X1
0011
0000
9457 0 ▶ return undef if $$options{IgnoreGroups}{$g} or $$options{IgnoreGroups}{"$_$g"};
Branch: 1 branch
BranchTrueFalseTotal
if $options->{"IgnoreGroups"}{$g} or $options->{"IgnoreGroups"}{"$_$g"} 0 0 0
Condition0%0/3
$options->{"IgnoreGroups"}{$g} or $options->{"IgnoreGroups"}{"$_$g"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$options->{"IgnoreGroups"}{$g} or $options->{"IgnoreGroups"}{"$_$g"}
$options->{"IgnoreGroups"}{$g} $options->{"IgnoreGroups"}{"$_$g"}
Truth table0%0/3
A or B
A= $options->{"IgnoreGroups"}{$g}B= $options->{"IgnoreGroups"}{"$_$g"}
ABresult
1X1
011
000
9458 }
9459 }
9460 61467 my $valueHash = $$self{VALUE};
9461  
9462 61467 ▶ if ($$tagInfo{RawConv}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tagInfo->{"RawConv"}) 9930 51537 61467
9463 # initialize @val for use in Composite RawConv expressions
9464 9930 my @val;
9465 9930 ▶ if (ref $value eq 'HASH' and $$tagInfo{IsComposite}) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value eq "HASH" and $tagInfo->{"IsComposite"}) 1840 8090 9930
Condition66%2/3
ref $value eq "HASH" and $tagInfo->{"IsComposite"}
!ll&&!rl&&r
809001840
MC/DC50%1/2
ref $value eq "HASH" and $tagInfo->{"IsComposite"}
ref $value eq "HASH" $tagInfo->{"IsComposite"}
Truth table66%2/3
A and B
A= ref $value eq "HASH"B= $tagInfo->{"IsComposite"}
ABresult
0X0
100
111
9466 1840 foreach (keys %$value) { $val[$_] = $$valueHash{$$value{$_}}; }
9467 }
9468 9930 my $conv = $$tagInfo{RawConv};
9469 9930 local $SIG{'__WARN__'} = \&SetWarning;
9470 9930 undef $evalWarning;
9471 9930 ▶ if (ref $conv eq 'CODE') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $conv eq 'CODE') { } 241 9689 9930
9472 241 $value = &$conv($value, $self);
9473 0 ▶ $$self{grps} and @grps = @{$$self{grps}}, delete $$self{grps};
Branch: 1 branch
BranchTrueFalseTotal
$self->{"grps"} and @grps = @{$self->{"grps"};}, delete $self->{"grps"} 0 241 241
9474 } else {
9475 9689 my $val = $value; # do this so eval can use $val
9476 # NOTE: RawConv is also evaluated in Writer.pl
9477 #### eval RawConv ($self, $val, $tag, $tagInfo, $priority, @grps)
9478 9689 $value = eval $conv;
9479 9689 ▶ $@ and $evalWarning = $@;
Branch: 1 branch
BranchTrueFalseTotal
$@ and $Image::ExifTool::evalWarning = $@ 0 9689 9689
9480 }
9481 9930 ▶ $self->Warn("RawConv $tag: " . CleanWarning()) if $evalWarning;
Branch: 1 branch
BranchTrueFalseTotal
if $Image::ExifTool::evalWarning 0 9930 9930
9482 9930 ▶ return undef unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 2735 7195 9930
9483 }
9484 # ignore specified tags (AFTER doing RawConv if necessary!)
9485 58732 ▶ if ($$options{IgnoreTags}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($options->{"IgnoreTags"}) 0 58732 58732
9486 0 ▶ if ($$options{IgnoreTags}{all}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($options->{'IgnoreTags'}{'all'}) { } 0 0 0
9487 0 ▶ return undef unless $$self{REQ_TAG_LOOKUP}{lc $tag};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"REQ_TAG_LOOKUP"}{lc $tag} 0 0 0
9488 } else {
9489 0 ▶ return undef if $$options{IgnoreTags}{lc $tag};
Branch: 1 branch
BranchTrueFalseTotal
if $options->{"IgnoreTags"}{lc $tag} 0 0 0
9490 }
9491 }
9492 # handle duplicate tag names
9493 58732 ▶ if (defined $$valueHash{$tag}) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $valueHash->{$tag}) { } 7035 51697 58732
elsif ($priority) { } 1915 49782 51697
9494 # add to list if there is an active list for this tag
9495 7035 ▶ if ($$self{LIST_TAGS}{$tagInfo}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"LIST_TAGS"}{$tagInfo}) 701 6334 7035
9496 701 $tag = $$self{LIST_TAGS}{$tagInfo}; # use key from previous list tag
9497 701 ▶ if (defined $$self{NO_LIST}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'NO_LIST'}) { } 65 636 701
9498 # accumulate list in TAG_EXTRA "NoList" element
9499 65 ▶ if (defined $$self{TAG_EXTRA}{$tag}{NoList}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'TAG_EXTRA'}{$tag}{'NoList'}) { } 31 34 65
9500 31 push @{$$self{TAG_EXTRA}{$tag}{NoList}}, $value;
9501 } else {
9502 34 $$self{TAG_EXTRA}{$tag}{NoList} = [ $$valueHash{$tag}, $value ];
9503 }
9504 65 $noListDel = 1; # set flag to delete this tag if re-listed
9505 } else {
9506 636 ▶ if (ref $$valueHash{$tag} ne 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $valueHash->{$tag} ne "ARRAY") 319 317 636
9507 319 $$valueHash{$tag} = [ $$valueHash{$tag} ];
9508 }
9509 636 push @{$$valueHash{$tag}}, $value;
9510 636 return $tag; # return without creating a new entry
9511 }
9512 }
9513 # get next available tag key
9514 6399 ▶ my $nextInd = $$self{DUPL_TAG}{$tag} = ($$self{DUPL_TAG}{$tag} || 0) + 1;
Condition100%2/2
$self->{'DUPL_TAG'}{$tag} || 0
l!l
17844615
MC/DC100%1/1
$self->{'DUPL_TAG'}{$tag} || 0
$self->{'DUPL_TAG'}{$tag}
Truth table100%2/2
A
A= $self->{'DUPL_TAG'}{$tag}
Aresult
11
00
9515 6399 my $nextTag = "$tag ($nextInd)";
9516 #
9517 # take tag with highest priority
9518 #
9519 # promote existing 0-priority tag so it takes precedence over a new 0-tag
9520 # (unless old tag was a sub-document and new tag isn't. Also, never override
9521 # a Warning tag because they may be added by ValueConv, which could be confusing)
9522 6399 my $oldPriority = $$self{PRIORITY}{$tag};
9523 6399 ▶ unless ($oldPriority) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($oldPriority) 5408 991 6399
9524 5408 ▶ if ($$self{DOC_NUM} or $tag eq 'Warning' or not $$self{TAG_EXTRA}{$tag}{G3}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'DOC_NUM'} or $tag eq 'Warning' or not $self->{'TAG_EXTRA'}{$tag}{'G3'}) { } 5373 35 5408
Condition100%6/6
$self->{"DOC_NUM"} or $tag eq "Warning" or not $self->{"TAG_EXTRA"}{$tag}{"G3"}
l!l&&r!l&&!r
1056431735
$self->{"DOC_NUM"} or $tag eq "Warning"
l!l&&r!l&&!r
1041154352
MC/DC100%3/3
$self->{"DOC_NUM"} or $tag eq "Warning" or not $self->{"TAG_EXTRA"}{$tag}{"G3"}
$self->{"DOC_NUM"} $tag eq "Warning" not $self->{"TAG_EXTRA"}{$tag}{"G3"}
Truth table100%4/4
A or B or not(C)
A= $self->{"DOC_NUM"}B= $tag eq "Warning"C= not $self->{"TAG_EXTRA"}{$tag}{"G3"}
ABCresult
1XX1
01X1
0011
0000
9525 5373 $oldPriority = 1;
9526 } else {
9527 35 $oldPriority = 0; # don't promote sub-document tag over main document
9528 }
9529 }
9530 # set priority for this tag
9531 6399 ▶ if (defined $priority) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $priority) { } 2134 4265 6399
elsif ($self->{'LOW_PRIORITY_DIR'}{'*'} or $self->{'DIR_NAME'} and $self->{'LOW_PRIORITY_DIR'}{$self->{'DIR_NAME'}}) { } 411 3854 4265
9532 # increase 0-priority tags if this is the priority directory
9533 $priority = 1 if not $priority and $$self{DIR_NAME} and
9534 2134 ▶ $$self{DIR_NAME} eq $$self{PRIORITY_DIR};
Branch: 1 branch
BranchTrueFalseTotal
if not $priority and $self->{"DIR_NAME"} and $self->{"DIR_NAME"} eq $self->{"PRIORITY_DIR"} 40 2094 2134
Condition100%6/6
not $priority and $self->{"DIR_NAME"} and $self->{"DIR_NAME"} eq $self->{"PRIORITY_DIR"}
!ll&&!rl&&r
255183940
not $priority and $self->{"DIR_NAME"}
!ll&&!rl&&r
961591879
MC/DC100%3/3
not $priority and $self->{"DIR_NAME"} and $self->{"DIR_NAME"} eq $self->{"PRIORITY_DIR"}
not $priority $self->{"DIR_NAME"} $self->{"DIR_NAME"} eq $self->{"PRIORITY_DIR"}
Truth table100%4/4
not(A) and B and C
A= not $priorityB= $self->{"DIR_NAME"}C= $self->{"DIR_NAME"} eq $self->{"PRIORITY_DIR"}
ABCresult
0XX0
10X0
1100
1111
9535 ▶ } elsif ($$self{LOW_PRIORITY_DIR}{'*'} or
Condition83%5/6
$self->{"LOW_PRIORITY_DIR"}{"*"} or $self->{"DIR_NAME"} and $self->{"LOW_PRIORITY_DIR"}{$self->{"DIR_NAME"}}
l!l&&r!l&&!r
04113854
$self->{"DIR_NAME"} and $self->{"LOW_PRIORITY_DIR"}{$self->{"DIR_NAME"}}
!ll&&!rl&&r
6033251411
MC/DC66%2/3
$self->{"LOW_PRIORITY_DIR"}{"*"} or $self->{"DIR_NAME"} and $self->{"LOW_PRIORITY_DIR"}{$self->{"DIR_NAME"}}
$self->{"LOW_PRIORITY_DIR"}{"*"} $self->{"DIR_NAME"} $self->{"LOW_PRIORITY_DIR"}{$self->{"DIR_NAME"}}
Truth table75%3/4
A or B and C
A= $self->{"LOW_PRIORITY_DIR"}{"*"}B= $self->{"DIR_NAME"}C= $self->{"LOW_PRIORITY_DIR"}{$self->{"DIR_NAME"}}
ABCresult
1XX1
0111
00X0
0100
9536 ($$self{DIR_NAME} and $$self{LOW_PRIORITY_DIR}{$$self{DIR_NAME}}))
9537 {
9538 411 $priority = 0; # default is 0 for a LOW_PRIORITY_DIR
9539 } else {
9540 3854 $priority = 1; # the normal default
9541 }
9542 6399 ▶ if ($priority >= $oldPriority and (not $$self{DOC_NUM} or ($$self{TAG_EXTRA}{$tag}{G3} and
Branch: 1 branch
BranchTrueFalseTotal
if ($priority >= $oldPriority and !$self->{'DOC_NUM'} || $self->{'TAG_EXTRA'}{$tag}{'G3'} && $self->{'DOC_NUM'} eq $self->{'TAG_EXTRA'}{$tag}{'G3'} and not $noListDel) { } 2957 3442 6399
Condition100%12/12
$priority >= $oldPriority and !$self->{"DOC_NUM"} || $self->{"TAG_EXTRA"}{$tag}{"G3"} && $self->{"DOC_NUM"} eq $self->{"TAG_EXTRA"}{$tag}{"G3"} and not $noListDel
!ll&&!rl&&r
3389532957
$priority >= $oldPriority and !$self->{"DOC_NUM"} || $self->{"TAG_EXTRA"}{$tag}{"G3"} && $self->{"DOC_NUM"} eq $self->{"TAG_EXTRA"}{$tag}{"G3"}
!ll&&!rl&&r
238810013010
not $self->{"DOC_NUM"} or $self->{"TAG_EXTRA"}{$tag}{"G3"} and $self->{"DOC_NUM"} eq $self->{"TAG_EXTRA"}{$tag}{"G3"}
l!l&&r!l&&!r
2992181001
$self->{"TAG_EXTRA"}{$tag}{"G3"} and $self->{"DOC_NUM"} eq $self->{"TAG_EXTRA"}{$tag}{"G3"}
!ll&&!rl&&r
59240918
MC/DC100%5/5
$priority >= $oldPriority and !$self->{"DOC_NUM"} || $self->{"TAG_EXTRA"}{$tag}{"G3"} && $self->{"DOC_NUM"} eq $self->{"TAG_EXTRA"}{$tag}{"G3"} and not $noListDel
$priority >= $oldPriority not $self->{"DOC_NUM"} $self->{"TAG_EXTRA"}{$tag}{"G3"} $self->{"DOC_NUM"} eq $self->{"TAG_EXTRA"}{$tag}{"G3"} not $noListDel
Truth table85%6/7
A and not(B) or C and D and not(E)
A= $priority >= $oldPriorityB= not $self->{"DOC_NUM"}C= $self->{"TAG_EXTRA"}{$tag}{"G3"}D= $self->{"DOC_NUM"} eq $self->{"TAG_EXTRA"}{$tag}{"G3"}E= not $noListDel
ABCDEresult
0XXXX0
100XX0
1010X0
11XX00
101100
11XX11
101111
9543 $$self{DOC_NUM} eq $$self{TAG_EXTRA}{$tag}{G3})) and not $noListDel)
9544 {
9545 # move existing tag out of the way since this tag is higher priority
9546 # (NOTE: any new members added here must also be added to DeleteTag())
9547 2957 $$self{PRIORITY}{$nextTag} = $$self{PRIORITY}{$tag};
9548 2957 $$valueHash{$nextTag} = $$valueHash{$tag};
9549 2957 $$self{FILE_ORDER}{$nextTag} = $$self{FILE_ORDER}{$tag};
9550 2957 my $oldInfo = $$self{TAG_INFO}{$nextTag} = $$self{TAG_INFO}{$tag};
9551 2957 $$self{TAG_EXTRA}{$nextTag} = $$self{TAG_EXTRA}{$tag};
9552 2957 $$self{TAG_EXTRA}{$tag} = { };
9553 2957 delete $$self{BOTH}{$tag};
9554 # update tag key for list if necessary
9555 2957 ▶ $$self{LIST_TAGS}{$oldInfo} = $nextTag if $$self{LIST_TAGS}{$oldInfo};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"LIST_TAGS"}{$oldInfo} 7 2950 2957
9556 # update this key if used in a Composite tag
9557 2957 ▶ if ($$self{COMP_KEYS}{$tag}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"COMP_KEYS"}{$tag}) 97 2860 2957
9558 97 $$_[0]{$$_[1]} = $nextTag foreach @{$$self{COMP_KEYS}{$tag}};
9559 97 $$self{COMP_KEYS}{$nextTag} = $$self{COMP_KEYS}{$tag};
9560 97 delete $$self{COMP_KEYS}{$tag};
9561 }
9562 } else {
9563 3442 $tag = $nextTag; # don't override the existing tag
9564 }
9565 6399 $$self{PRIORITY}{$tag} = $priority;
9566 6399 ▶ $$self{TAG_EXTRA}{$tag}{NoListDel} = 1 if $noListDel;
Branch: 1 branch
BranchTrueFalseTotal
if $noListDel 65 6334 6399
9567 } elsif ($priority) {
9568 # set tag priority (only if exists and is non-zero)
9569 1915 $$self{PRIORITY}{$tag} = $priority;
9570 }
9571  
9572 # save the raw value, file order, tagInfo ref, group1 name,
9573 # and tag key for lists if necessary
9574 58096 $$valueHash{$tag} = $value;
9575 58096 $$self{FILE_ORDER}{$tag} = ++$$self{NUM_FOUND};
9576 58096 $$self{TAG_INFO}{$tag} = $tagInfo;
9577 58096 ▶ $$self{TAG_EXTRA}{$tag} = { } unless $$self{TAG_EXTRA}{$tag};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"TAG_EXTRA"}{$tag} 55074 3022 58096
9578 # set dynamic groups 0, 1 and 3 if necessary
9579 58096 ▶ $$self{TAG_EXTRA}{$tag}{G0} = $grps[0] if $grps[0];
Branch: 1 branch
BranchTrueFalseTotal
if $grps[0] 517 57579 58096
9580 58096 ▶ $$self{TAG_EXTRA}{$tag}{G1} = $grps[1] if $grps[1];
Branch: 1 branch
BranchTrueFalseTotal
if $grps[1] 4701 53395 58096
9581 58096 ▶ if ($$self{DOC_NUM}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"DOC_NUM"}) 1798 56298 58096
9582 1798 $$self{TAG_EXTRA}{$tag}{G3} = $$self{DOC_NUM};
9583 1798 $$self{HAS_DOC}{$$self{DOC_NUM}} = 1;
9584 1798 ▶ if ($$self{DOC_NUM} =~ /^(\d+)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"DOC_NUM"} =~ /^(\d+)/) 1798 0 1798
9585 # keep track of maximum 1st-level sub-document number
9586 1798 ▶ $$self{DOC_COUNT} = $1 unless $$self{DOC_COUNT} >= $1;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"DOC_COUNT"} >= $1 33 1765 1798
9587 }
9588 }
9589 # save path if requested
9590 58096 ▶ $$self{TAG_EXTRA}{$tag}{G5} = $self->MetadataPath() if $$options{SavePath};
Branch: 1 branch
BranchTrueFalseTotal
if $options->{"SavePath"} 258 57838 58096
9591  
9592 # remember this tagInfo if we will be accumulating values in a list
9593 # (but don't override earlier list if this may be deleted by NoListDel flag)
9594 58096 ▶ if ($$tagInfo{List} and not $$self{NO_LIST} and not $noListDel) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tagInfo->{"List"} and not $self->{"NO_LIST"} and not $noListDel) 1166 56930 58096
Condition100%6/6
$tagInfo->{"List"} and not $self->{"NO_LIST"} and not $noListDel
!ll&&!rl&&r
56865651166
$tagInfo->{"List"} and not $self->{"NO_LIST"}
!ll&&!rl&&r
567491161231
MC/DC100%3/3
$tagInfo->{"List"} and not $self->{"NO_LIST"} and not $noListDel
$tagInfo->{"List"} not $self->{"NO_LIST"} not $noListDel
Truth table100%4/4
A and not(B) and not(C)
A= $tagInfo->{"List"}B= not $self->{"NO_LIST"}C= not $noListDel
ABCresult
0XX0
10X0
1100
1111
9595 1166 $$self{LIST_TAGS}{$tagInfo} = $tag;
9596 }
9597  
9598 # validate tag if requested (but only for simple values -- could result
9599 # in infinite recursion if called for a Composite tag (HASH ref value)
9600 # because FoundTag is called in the middle of building Composite tags
9601 58096 ▶ if ($$options{Validate} and not ref $value) {
Branch: 1 branch
BranchTrueFalseTotal
if ($options->{"Validate"} and not ref $value) 213 57883 58096
Condition100%3/3
$options->{"Validate"} and not ref $value
!ll&&!rl&&r
5786122213
MC/DC100%2/2
$options->{"Validate"} and not ref $value
$options->{"Validate"} not ref $value
Truth table100%3/3
A and not(B)
A= $options->{"Validate"}B= not ref $value
ABresult
0X0
100
111
9602 213 Image::ExifTool::Validate::ValidateRaw($self, $tag, $value);
9603 }
9604  
9605 58096 return $tag;
9606 }
9607  
9608 #------------------------------------------------------------------------------
9609 # Make current directory the priority directory if not set already
9610 # Inputs: 0) ExifTool object reference
9611 sub SetPriorityDir($)
9612 22 ▶{
Subroutine SetPriorityDir: called CC=2 SCAR=7.2
Pod undocumented
9613 22 my $self = shift;
9614 22 ▶ $$self{PRIORITY_DIR} = $$self{DIR_NAME} unless $$self{PRIORITY_DIR};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"PRIORITY_DIR"} 22 0 22
9615 }
9616  
9617 #------------------------------------------------------------------------------
9618 # Set family 0 or 1 group name specific to this tag instance
9619 # Inputs: 0) ExifTool ref, 1) tag key, 2) group name, 3) family (default 1)
9620 sub SetGroup($$$;$)
9621 13786 ▶{
Subroutine SetGroup: called CC=2 SCAR=7.2
Pod undocumented
9622 13786 my ($self, $tagKey, $extra, $fam) = @_;
9623 13786 ▶ $$self{TAG_EXTRA}{$tagKey}{defined $fam ? "G$fam" : 'G1'} = $extra;
Branch: 1 branch
BranchTrueFalseTotal
defined $fam ? : 0 13786 13786
9624 }
9625  
9626 #------------------------------------------------------------------------------
9627 # Delete specified tag
9628 # Inputs: 0) ExifTool object ref, 1) tag key
9629 sub DeleteTag($$)
9630 224 ▶{
Subroutine DeleteTag: called CC=1 SCAR=0.0
Pod undocumented
9631 224 my ($self, $tag) = @_;
9632 224 delete $$self{VALUE}{$tag};
9633 224 delete $$self{FILE_ORDER}{$tag};
9634 224 delete $$self{TAG_INFO}{$tag};
9635 224 delete $$self{TAG_EXTRA}{$tag};
9636 224 delete $$self{PRIORITY}{$tag};
9637 224 delete $$self{BOTH}{$tag};
9638 }
9639  
9640 #------------------------------------------------------------------------------
9641 # Escape all elements of a value
9642 # Inputs: 0) value, 1) escape proc
9643 sub DoEscape($$)
9644 173 ▶{
Subroutine DoEscape: called CC=6 SCAR=18.8
Pod undocumented
9645 173 my ($val, $key);
9646 173 ▶ if (not ref $_[0]) {
Branch: 3 branches
BranchTrueFalseTotal
if (not ref $_[0]) { } 167 6 173
elsif (ref $_[0] eq 'ARRAY') { } 4 2 6
elsif (ref $_[0] eq 'HASH') { } 0 2 2
9647 167 $_[0] = &{$_[1]}($_[0]);
9648 } elsif (ref $_[0] eq 'ARRAY') {
9649 4 foreach $val (@{$_[0]}) {
9650 10 DoEscape($val, $_[1]);
9651 }
9652 } elsif (ref $_[0] eq 'HASH') {
9653 0 foreach $key (keys %{$_[0]}) {
9654 0 DoEscape($_[0]{$key}, $_[1]);
9655 }
9656 }
9657 }
9658  
9659 #------------------------------------------------------------------------------
9660 # Set the FileType and MIMEType tags
9661 # Inputs: 0) ExifTool object reference
9662 # 1) Optional file type (uses FILE_TYPE if not specified)
9663 # 2) Optional MIME type (uses our lookup if not specified)
9664 # 3) Optional recommended extension (converted to lower case; uses FileType if undef)
9665 # Notes: Will NOT set file type twice (subsequent calls ignored)
9666 sub SetFileType($;$$$)
9667 676 ▶{
Subroutine SetFileType: called CC=19 SCAR=29.5
Pod undocumented
9668 676 my ($self, $fileType, $mimeType, $normExt) = @_;
9669 # use only the first FileType set if called again for the main document
9670 676 ▶ unless ($$self{FileType} and not $$self{DOC_NUM}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"FileType"} and not $self->{"DOC_NUM"}) 627 49 676
Condition66%2/3
$self->{"FileType"} and not $self->{"DOC_NUM"}
!ll&&!rl&&r
627049
MC/DC50%1/2
$self->{"FileType"} and not $self->{"DOC_NUM"}
$self->{"FileType"} not $self->{"DOC_NUM"}
Truth table66%2/3
A and not(B)
A= $self->{"FileType"}B= not $self->{"DOC_NUM"}
ABresult
0X0
100
111
9671 627 my $baseType = $$self{FILE_TYPE};
9672 627 my $ext = $$self{FILE_EXT};
9673 627 ▶ $fileType or $fileType = $baseType;
Branch: 1 branch
BranchTrueFalseTotal
$fileType or $fileType = $baseType 149 478 627
9674 # handle sub-types which are identified by extension
9675 627 ▶ if (defined $ext and $ext ne $fileType and not $$self{DOC_NUM}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ext and $ext ne $fileType and not $self->{"DOC_NUM"}) 275 352 627
Condition83%5/6
defined $ext and $ext ne $fileType and not $self->{"DOC_NUM"}
!ll&&!rl&&r
3520275
defined $ext and $ext ne $fileType
!ll&&!rl&&r
44308275
MC/DC66%2/3
defined $ext and $ext ne $fileType and not $self->{"DOC_NUM"}
defined $ext $ext ne $fileType not $self->{"DOC_NUM"}
Truth table75%3/4
A and B and not(C)
A= defined $extB= $ext ne $fileTypeC= not $self->{"DOC_NUM"}
ABCresult
0XX0
10X0
1100
1111
9676 275 my ($f,$e) = @fileTypeLookup{$fileType,$ext};
9677 275 ▶ if (ref $f eq 'ARRAY' and ref $e eq 'ARRAY' and $$f[0] eq $$e[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $f eq "ARRAY" and ref $e eq "ARRAY" and $f->[0] eq $e->[0]) 10 265 275
Condition100%6/6
ref $f eq "ARRAY" and ref $e eq "ARRAY" and $f->[0] eq $e->[0]
!ll&&!rl&&r
262310
ref $f eq "ARRAY" and ref $e eq "ARRAY"
!ll&&!rl&&r
1524713
MC/DC100%3/3
ref $f eq "ARRAY" and ref $e eq "ARRAY" and $f->[0] eq $e->[0]
ref $f eq "ARRAY" ref $e eq "ARRAY" $f->[0] eq $e->[0]
Truth table100%4/4
A and B and C
A= ref $f eq "ARRAY"B= ref $e eq "ARRAY"C= $f->[0] eq $e->[0]
ABCresult
0XX0
10X0
1100
1111
9678 # make sure $fileType was a root type and not another sub-type
9679 10 ▶ $fileType = $ext if $$f[0] eq $fileType or not $fileTypeLookup{$$f[0]};
Branch: 1 branch
BranchTrueFalseTotal
if $f->[0] eq $fileType or not $Image::ExifTool::fileTypeLookup{$f->[0]} 4 6 10
Condition66%2/3
$f->[0] eq $fileType or not $Image::ExifTool::fileTypeLookup{$f->[0]}
l!l&&r!l&&!r
406
MC/DC50%1/2
$f->[0] eq $fileType or not $Image::ExifTool::fileTypeLookup{$f->[0]}
$f->[0] eq $fileType not $Image::ExifTool::fileTypeLookup{$f->[0]}
Truth table66%2/3
A or not(B)
A= $f->[0] eq $fileTypeB= not $Image::ExifTool::fileTypeLookup{$f->[0]}
ABresult
1X1
011
000
9680 }
9681 }
9682 627 ▶ $mimeType or $mimeType = $mimeType{$fileType};
Branch: 1 branch
BranchTrueFalseTotal
$mimeType or $mimeType = $Image::ExifTool::mimeType{$fileType} 25 602 627
9683 # use base file type if necessary (except if 'TIFF', which is a special case)
9684 627 ▶ $mimeType = $mimeType{$baseType} unless $mimeType or $baseType eq 'TIFF';
Branch: 1 branch
BranchTrueFalseTotal
unless $mimeType or $baseType eq "TIFF" 21 606 627
Condition66%2/3
$mimeType or $baseType eq "TIFF"
l!l&&r!l&&!r
606021
MC/DC50%1/2
$mimeType or $baseType eq "TIFF"
$mimeType $baseType eq "TIFF"
Truth table66%2/3
A or B
A= $mimeTypeB= $baseType eq "TIFF"
ABresult
1X1
011
000
9685 627 ▶ unless (defined $normExt) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $normExt) 617 10 627
9686 617 $normExt = $fileTypeExt{$fileType};
9687 617 ▶ $normExt = $fileType unless defined $normExt;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $normExt 351 266 617
9688 }
9689 # ($$self{FileType} is the file type of the main document)
9690 627 ▶ $$self{FileType} = $fileType unless $$self{DOC_NUM};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"DOC_NUM"} 627 0 627
9691 627 $self->FoundTag('FileType', $fileType);
9692 627 $self->FoundTag('FileTypeExtension', uc $normExt);
9693 627 ▶ $self->FoundTag('MIMEType', $mimeType || 'application/unknown');
Condition100%2/2
$mimeType || 'application/unknown'
l!l
6243
MC/DC100%1/1
$mimeType || 'application/unknown'
$mimeType
Truth table100%2/2
A
A= $mimeType
Aresult
11
00
9694 }
9695 }
9696  
9697 #------------------------------------------------------------------------------
9698 # Override the FileType and MIMEType tags
9699 # Inputs: 0) ExifTool object ref, 1) file type, 2) MIME type, 3) normal extension (lower case)
9700 # Notes: does nothing if FileType was not previously defined (ie. when writing)
9701 sub OverrideFileType($$;$$)
9702 18 ▶{
Subroutine OverrideFileType: called CC=9 SCAR=24.0
Pod undocumented
9703 18 my ($self, $fileType, $mimeType, $normExt) = @_;
9704 18 ▶ if (defined $$self{VALUE}{FileType} and $fileType ne $$self{VALUE}{FileType}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"VALUE"}{"FileType"} and $fileType ne $self->{"VALUE"}{"FileType"}) 12 6 18
Condition66%2/3
defined $self->{"VALUE"}{"FileType"} and $fileType ne $self->{"VALUE"}{"FileType"}
!ll&&!rl&&r
0612
MC/DC50%1/2
defined $self->{"VALUE"}{"FileType"} and $fileType ne $self->{"VALUE"}{"FileType"}
defined $self->{"VALUE"}{"FileType"} $fileType ne $self->{"VALUE"}{"FileType"}
Truth table66%2/3
A and B
A= defined $self->{"VALUE"}{"FileType"}B= $fileType ne $self->{"VALUE"}{"FileType"}
ABresult
0X0
100
111
9705 12 $$self{FileType} = $fileType;
9706 12 $$self{VALUE}{FileType} = $fileType;
9707 12 ▶ unless (defined $normExt) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $normExt) 5 7 12
9708 5 $normExt = $fileTypeExt{$fileType};
9709 5 ▶ $normExt = $fileType unless defined $normExt;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $normExt 5 0 5
9710 }
9711 12 $$self{VALUE}{FileTypeExtension} = uc $normExt;
9712 12 ▶ $mimeType or $mimeType = $mimeType{$fileType};
Branch: 1 branch
BranchTrueFalseTotal
$mimeType or $mimeType = $Image::ExifTool::mimeType{$fileType} 0 12 12
9713 12 ▶ $$self{VALUE}{MIMEType} = $mimeType if $mimeType;
Branch: 1 branch
BranchTrueFalseTotal
if $mimeType 5 7 12
9714 12 ▶ if ($$self{OPTIONS}{Verbose}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"OPTIONS"}{"Verbose"}) 0 12 12
9715 0 $self->VPrint(0,"$$self{INDENT}FileType [override] = $fileType\n");
9716 0 $self->VPrint(0,"$$self{INDENT}FileTypeExtension [override] = $$self{VALUE}{FileTypeExtension}\n");
9717 0 ▶ $self->VPrint(0,"$$self{INDENT}MIMEType [override] = $mimeType\n") if $mimeType;
Branch: 1 branch
BranchTrueFalseTotal
if $mimeType 0 0 0
9718 }
9719 }
9720 }
9721  
9722 #------------------------------------------------------------------------------
9723 # Modify the value of the MIMEType tag
9724 # Inputs: 0) ExifTool object reference, 1) file or MIME type
9725 # Notes: combines existing type with new type: ie) a/b + c/d => c/b-d
9726 sub ModifyMimeType($;$)
9727 8 ▶{
Subroutine ModifyMimeType: called CC=4 SCAR=14.8
Pod undocumented
9728 8 my ($self, $mime) = @_;
9729 8 ▶ $mime =~ m{/} or $mime = $mimeType{$mime} or return;
Branch: 1 branch
BranchTrueFalseTotal
$mime =~ m[/] or $mime = $Image::ExifTool::mimeType{$mime} or return 8 0 8
Condition33%1/3
$mime =~ m[/] or $mime = $Image::ExifTool::mimeType{$mime}
l!l&&r!l&&!r
800
MC/DC0%0/2
$mime =~ m[/] or $mime = $Image::ExifTool::mimeType{$mime}
$mime =~ m[/] $mime = $Image::ExifTool::mimeType{$mime}
Truth table33%1/3
A or B
A= $mime =~ m[/]B= $mime = $Image::ExifTool::mimeType{$mime}
ABresult
1X1
011
000
9730 8 my $old = $$self{VALUE}{MIMEType};
9731 8 ▶ if (defined $old) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $old) { } 8 0 8
9732 8 my ($a, $b) = split '/', $old;
9733 8 my ($c, $d) = split '/', $mime;
9734 8 $d =~ s/^x-//;
9735 8 $$self{VALUE}{MIMEType} = "$c/$b-$d";
9736 8 $self->VPrint(0, " Modified MIMEType = $c/$b-$d\n");
9737 } else {
9738 0 $self->FoundTag('MIMEType', $mime);
9739 }
9740 }
9741  
9742 #------------------------------------------------------------------------------
9743 # Print verbose output
9744 # Inputs: 0) ExifTool ref, 1) verbose level (prints if level > this), 2-N) print args
9745 sub VPrint($$@)
9746 12499 ▶{
Subroutine VPrint: called CC=4 SCAR=14.0
Pod undocumented
9747 12499 my $self = shift;
9748 12499 my $level = shift;
9749 12499 ▶ if ($$self{OPTIONS}{Verbose} and $$self{OPTIONS}{Verbose} > $level) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"OPTIONS"}{"Verbose"} and $self->{"OPTIONS"}{"Verbose"} > $level) 4 12495 12499
Condition66%2/3
$self->{"OPTIONS"}{"Verbose"} and $self->{"OPTIONS"}{"Verbose"} > $level
!ll&&!rl&&r
1249504
MC/DC50%1/2
$self->{"OPTIONS"}{"Verbose"} and $self->{"OPTIONS"}{"Verbose"} > $level
$self->{"OPTIONS"}{"Verbose"} $self->{"OPTIONS"}{"Verbose"} > $level
Truth table66%2/3
A and B
A= $self->{"OPTIONS"}{"Verbose"}B= $self->{"OPTIONS"}{"Verbose"} > $level
ABresult
0X0
100
111
9750 4 my $out = $$self{OPTIONS}{TextOut};
9751 4 print $out @_;
9752 4 ▶ print $out "\n" unless $_[-1] =~ /\n$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $_[-1] =~ /\n$/ 0 4 4
9753 }
9754 }
9755  
9756 #------------------------------------------------------------------------------
9757 # Print verbose directory information
9758 # Inputs: 0) ExifTool object reference, 1) directory name or dirInfo ref
9759 # 2) number of entries in directory (or 0 if unknown)
9760 # 3) optional size of directory in bytes, 4) optional byte order for -v3 output
9761 sub VerboseDir($$;$$$)
9762 2009 ▶{
Subroutine VerboseDir: called CC=12 SCAR=27.4
Pod undocumented
9763 2009 my ($self, $name, $entries, $size, $byteOrder) = @_;
9764 2009 ▶ return unless $$self{OPTIONS}{Verbose};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"OPTIONS"}{"Verbose"} 1965 44 2009
9765 44 ▶ if (ref $name eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $name eq "HASH") 0 44 44
9766 0 ▶ $size = $$name{DirLen} unless $size;
Branch: 1 branch
BranchTrueFalseTotal
unless $size 0 0 0
9767 0 ▶ $name = $$name{Name} || $$name{DirName};
Condition0%0/3
$name->{'Name'} || $name->{'DirName'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$name->{'Name'} || $name->{'DirName'}
$name->{'Name'} $name->{'DirName'}
Truth table0%0/3
A || B
A= $name->{'Name'}B= $name->{'DirName'}
ABresult
1X1
011
000
9768 }
9769 44 my $indent = substr($$self{INDENT}, 0, -2);
9770 44 my $out = $$self{OPTIONS}{TextOut};
9771 44 ▶ my $str = ($entries or defined $entries and not $size) ? " with $entries entries" : '';
Branch: 1 branch
BranchTrueFalseTotal
$entries || defined $entries && !$size ? : 22 22 44
Condition66%4/6
$entries or defined $entries and not $size
l!l&&r!l&&!r
22022
defined $entries and not $size
!ll&&!rl&&r
2110
MC/DC33%1/3
$entries or defined $entries and not $size
$entries defined $entries not $size
Truth table75%3/4
A or B and not(C)
A= $entriesB= defined $entriesC= not $size
ABCresult
1XX1
0111
00X0
0100
9772 44 ▶ $str .= ", $size bytes" if $size;
Branch: 1 branch
BranchTrueFalseTotal
if $size 22 22 44
9773 44 ▶ if ($byteOrder and $$self{OPTIONS}{Verbose} > 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($byteOrder and $self->{"OPTIONS"}{"Verbose"} > 2) 11 33 44
Condition100%3/3
$byteOrder and $self->{"OPTIONS"}{"Verbose"} > 2
!ll&&!rl&&r
112211
MC/DC100%2/2
$byteOrder and $self->{"OPTIONS"}{"Verbose"} > 2
$byteOrder $self->{"OPTIONS"}{"Verbose"} > 2
Truth table100%3/3
A and B
A= $byteOrderB= $self->{"OPTIONS"}{"Verbose"} > 2
ABresult
0X0
100
111
9774 11 ▶ $str .= ', ' . (GetByteOrder() eq 'II' ? 'Little-endian' : 'Big-endian');
Branch: 1 branch
BranchTrueFalseTotal
&GetByteOrder() eq 'II' ? : 11 0 11
9775 }
9776 44 print $out "$indent+ [$name directory$str]\n";
9777 }
9778  
9779 #------------------------------------------------------------------------------
9780 # Verbose dump
9781 # Inputs: 0) ExifTool ref, 1) data ref, 2-N) HexDump options
9782 sub VerboseDump($$;%)
9783 1666 ▶{
Subroutine VerboseDump: called CC=5 SCAR=23.4
Pod undocumented
9784 1666 my $self = shift;
9785 1666 my $dataPt = shift;
9786 1666 my $verbose = $$self{OPTIONS}{Verbose};
9787 1666 ▶ if ($verbose and $verbose > 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($verbose and $verbose > 2) 0 1666 1666
Condition33%1/3
$verbose and $verbose > 2
!ll&&!rl&&r
166600
MC/DC0%0/2
$verbose and $verbose > 2
$verbose $verbose > 2
Truth table33%1/3
A and B
A= $verboseB= $verbose > 2
ABresult
0X0
100
111
9788 my %parms = (
9789 Prefix => $$self{INDENT},
9790 Out => $$self{OPTIONS}{TextOut},
9791 0 ▶ MaxLen => $verbose < 4 ? 96 : $verbose < 5 ? 2048 : undef,
Branch: 2 branches
BranchTrueFalseTotal
$verbose < 4 ? : 0 0 0
$verbose < 5 ? : 0 0 0
9792 );
9793 0 HexDump($dataPt, undef, %parms, @_);
9794 }
9795 }
9796  
9797 #------------------------------------------------------------------------------
9798 # Print data in hex
9799 # Inputs: 0) data
9800 # Returns: hex string
9801 # (this is a convenience function for use in debugging PrintConv statements)
9802 sub PrintHex($)
9803 0 ▶{
Subroutine PrintHex: not called CC=1 SCAR=6.9
Pod undocumented
9804 0 my $val = shift;
9805 0 return join(' ', unpack('H2' x length($val), $val));
9806 }
9807  
9808 #------------------------------------------------------------------------------
9809 # Extract binary data from file
9810 # 0) ExifTool object reference, 1) offset, 2) length, 3) tag name if conditional
9811 # Returns: binary data, or undef on error
9812 # Notes: Returns "Binary data #### bytes" instead of data unless tag is
9813 # specifically requested or the Binary option is set
9814 sub ExtractBinary($$$;$)
9815 47 ▶{
Subroutine ExtractBinary: called CC=13 SCAR=26.5
Pod undocumented
9816 47 my ($self, $offset, $length, $tag) = @_;
9817 47 my ($isPreview, $buff);
9818  
9819 47 ▶ if ($tag) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag) 43 4 47
9820 43 ▶ if ($tag eq 'PreviewImage') {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag eq "PreviewImage") 29 14 43
9821 # save PreviewImage start/length in case we want to dump trailer
9822 29 $$self{PreviewImageStart} = $offset;
9823 29 $$self{PreviewImageLength} = $length;
9824 29 $isPreview = 1;
9825 }
9826 43 my $lcTag = lc $tag;
9827 43 my $options = $$self{OPTIONS};
9828 43 ▶ if ((not $$options{Binary} or $$self{EXCL_TAG_LOOKUP}{$lcTag}) and
Branch: 1 branch
BranchTrueFalseTotal
if (!$options->{"Binary"} || $self->{"EXCL_TAG_LOOKUP"}{$lcTag} and not $options->{"Verbose"} and not $options->{"Validate"} and not $self->{"REQ_TAG_LOOKUP"}{$lcTag}) 32 11 43
Condition75%9/12
!$options->{"Binary"} || $self->{"EXCL_TAG_LOOKUP"}{$lcTag} and not $options->{"Verbose"} and not $options->{"Validate"} and not $self->{"REQ_TAG_LOOKUP"}{$lcTag}
!ll&&!rl&&r
11032
!$options->{"Binary"} || $self->{"EXCL_TAG_LOOKUP"}{$lcTag} and not $options->{"Verbose"} and not $options->{"Validate"}
!ll&&!rl&&r
9232
!$options->{"Binary"} || $self->{"EXCL_TAG_LOOKUP"}{$lcTag} and not $options->{"Verbose"}
!ll&&!rl&&r
9034
not $options->{"Binary"} or $self->{"EXCL_TAG_LOOKUP"}{$lcTag}
l!l&&r!l&&!r
3409
MC/DC40%2/5
!$options->{"Binary"} || $self->{"EXCL_TAG_LOOKUP"}{$lcTag} and not $options->{"Verbose"} and not $options->{"Validate"} and not $self->{"REQ_TAG_LOOKUP"}{$lcTag}
not $options->{"Binary"} $self->{"EXCL_TAG_LOOKUP"}{$lcTag} not $options->{"Verbose"} not $options->{"Validate"} not $self->{"REQ_TAG_LOOKUP"}{$lcTag}
Truth table33%3/9
not(A) or B and not(C) and not(D) and not(E)
A= not $options->{"Binary"}B= $self->{"EXCL_TAG_LOOKUP"}{$lcTag}C= not $options->{"Verbose"}D= not $options->{"Validate"}E= not $self->{"REQ_TAG_LOOKUP"}{$lcTag}
ABCDEresult
00XXX0
1X0XX0
010XX0
1X10X0
0110X0
1X1100
011100
1X1111
011111
9829 not $$options{Verbose} and not $$options{Validate} and
9830 not $$self{REQ_TAG_LOOKUP}{$lcTag})
9831 {
9832 32 return "Binary data $length bytes";
9833 }
9834 }
9835 15 ▶ unless ($$self{RAF}->Seek($offset,0)
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"RAF"}->Seek($offset, 0) and $self->{"RAF"}->Read($buff, $length) == $length) 5 10 15
Condition66%2/3
$self->{"RAF"}->Seek($offset, 0) and $self->{"RAF"}->Read($buff, $length) == $length
!ll&&!rl&&r
0510
MC/DC50%1/2
$self->{"RAF"}->Seek($offset, 0) and $self->{"RAF"}->Read($buff, $length) == $length
$self->{"RAF"}->Seek($offset, 0) $self->{"RAF"}->Read($buff, $length) == $length
Truth table66%2/3
A and B
A= $self->{"RAF"}->Seek($offset, 0)B= $self->{"RAF"}->Read($buff, $length) == $length
ABresult
0X0
100
111
9836 and $$self{RAF}->Read($buff, $length) == $length)
9837 {
9838 5 ▶ $tag or $tag = 'binary data';
Branch: 1 branch
BranchTrueFalseTotal
$tag or $tag = "binary data" 5 0 5
9839 5 ▶ if ($isPreview and not $$self{BuildingComposite}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($isPreview and not $self->{'BuildingComposite'}) { } 0 5 5
Condition33%1/3
$isPreview and not $self->{"BuildingComposite"}
!ll&&!rl&&r
050
MC/DC0%0/2
$isPreview and not $self->{"BuildingComposite"}
$isPreview not $self->{"BuildingComposite"}
Truth table33%1/3
A and not(B)
A= $isPreviewB= not $self->{"BuildingComposite"}
ABresult
0X0
100
111
9840 0 $$self{PreviewError} = 1;
9841 } else {
9842 5 $self->Warn("Error reading $tag from file", $isPreview);
9843 }
9844 5 return undef;
9845 }
9846 10 return $buff;
9847 }
9848  
9849 #------------------------------------------------------------------------------
9850 # Process binary data
9851 # Inputs: 0) ExifTool object ref, 1) directory information ref, 2) tag table ref
9852 # Returns: 1 on success
9853 # Notes: dirInfo may contain VarFormatData (reference to empty list) to return
9854 # details about any variable-length-format tags in the table (used when writing)
9855 sub ProcessBinaryData($$$)
9856 2224 ▶{
Subroutine ProcessBinaryData: called CC=120 SCAR=66.6
Pod undocumented
9857 2224 my ($self, $dirInfo, $tagTablePtr) = @_;
9858 2224 my $dataPt = $$dirInfo{DataPt};
9859 2224 my $dataLen = length $$dataPt;
9860 2224 ▶ my $dirStart = $$dirInfo{DirStart} || 0;
Condition100%2/2
$dirInfo->{'DirStart'} || 0
l!l
1373851
MC/DC100%1/1
$dirInfo->{'DirStart'} || 0
$dirInfo->{'DirStart'}
Truth table100%2/2
A
A= $dirInfo->{'DirStart'}
Aresult
11
00
9861 2224 my $maxLen = $dataLen - $dirStart;
9862 2224 my $size = $$dirInfo{DirLen};
9863 2224 ▶ my $base = $$dirInfo{Base} || 0;
Condition100%2/2
$dirInfo->{'Base'} || 0
l!l
11431081
MC/DC100%1/1
$dirInfo->{'Base'} || 0
$dirInfo->{'Base'}
Truth table100%2/2
A
A= $dirInfo->{'Base'}
Aresult
11
00
9864 2224 my $verbose = $$self{OPTIONS}{Verbose};
9865 2224 my $unknown = $$self{OPTIONS}{Unknown};
9866 2224 ▶ my $dataPos = $$dirInfo{DataPos} || 0;
Condition100%2/2
$dirInfo->{'DataPos'} || 0
l!l
8631361
MC/DC100%1/1
$dirInfo->{'DataPos'} || 0
$dirInfo->{'DataPos'}
Truth table100%2/2
A
A= $dirInfo->{'DataPos'}
Aresult
11
00
9867  
9868 2224 ▶ $size = $maxLen if not defined $size or $size > $maxLen;
Branch: 1 branch
BranchTrueFalseTotal
if not defined $size or $size > $maxLen 33 2191 2224
Condition66%2/3
not defined $size or $size > $maxLen
l!l&&r!l&&!r
3302191
MC/DC50%1/2
not defined $size or $size > $maxLen
not defined $size $size > $maxLen
Truth table66%2/3
not(A) or B
A= not defined $sizeB= $size > $maxLen
ABresult
1X1
011
000
9869 # get default format ('int8u' unless specified)
9870 2224 ▶ my $defaultFormat = $$tagTablePtr{FORMAT} || 'int8u';
Condition100%2/2
$tagTablePtr->{'FORMAT'} || 'int8u'
l!l
1441783
MC/DC100%1/1
$tagTablePtr->{'FORMAT'} || 'int8u'
$tagTablePtr->{'FORMAT'}
Truth table100%2/2
A
A= $tagTablePtr->{'FORMAT'}
Aresult
11
00
9871 2224 my $increment = $formatSize{$defaultFormat};
9872 2224 ▶ unless ($increment) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($increment) 0 2224 2224
9873 0 warn "Unknown format $defaultFormat\n";
9874 0 $defaultFormat = 'int8u';
9875 0 $increment = $formatSize{$defaultFormat};
9876 }
9877 # prepare list of tag numbers to extract
9878 2224 my (@tags, $topIndex, $binVal);
9879 2224 ▶ if ($unknown > 1 and defined $$tagTablePtr{FIRST_ENTRY}) {
Branch: 3 branches
BranchTrueFalseTotal
if ($unknown > 1 and defined $tagTablePtr->{'FIRST_ENTRY'}) { } 0 2224 2224
elsif ($dirInfo->{'DataMember'}) { } 220 2004 2224
elsif ($dirInfo->{'MixedTags'}) { } 48 1956 2004
Condition33%1/3
$unknown > 1 and defined $tagTablePtr->{"FIRST_ENTRY"}
!ll&&!rl&&r
222400
MC/DC0%0/2
$unknown > 1 and defined $tagTablePtr->{"FIRST_ENTRY"}
$unknown > 1 defined $tagTablePtr->{"FIRST_ENTRY"}
Truth table33%1/3
A and B
A= $unknown > 1B= defined $tagTablePtr->{"FIRST_ENTRY"}
ABresult
0X0
100
111
9880 # don't create a stupid number of tags if data is huge
9881 0 ▶ my $sizeLimit = $size < 65536 ? $size : 65536;
Branch: 1 branch
BranchTrueFalseTotal
$size < 65536 ? : 0 0 0
9882 # scan through entire binary table
9883 0 $topIndex = int($sizeLimit/$increment);
9884 0 @tags = ($$tagTablePtr{FIRST_ENTRY}..($topIndex - 1));
9885 # add in floating point tag ID's if they exist
9886 0 my @ftags = grep /\./, TagTableKeys($tagTablePtr);
9887 0 ▶ @tags = sort { $a <=> $b } @tags, @ftags if @ftags;
Branch: 1 branch
BranchTrueFalseTotal
if @ftags 0 0 0
9888 } elsif ($$dirInfo{DataMember}) {
9889 220 @tags = @{$$dirInfo{DataMember}};
9890 220 $verbose = 0; # no verbose output of extracted values when writing
9891 } elsif ($$dirInfo{MixedTags}) {
9892 # process sorted integer-ID tags only
9893 48 @tags = sort { $a <=> $b } grep /^\d+$/, TagTableKeys($tagTablePtr);
9894 } else {
9895 # extract known tags in numerical order
9896 1956 ▶ @tags = sort { ($a < 0 ? $a + 1e9 : $a) <=> ($b < 0 ? $b + 1e9 : $b) } TagTableKeys($tagTablePtr);
Branch: 2 branches
BranchTrueFalseTotal
$a < 0 ? : 0 58632 58632
$b < 0 ? : 0 58632 58632
9897 }
9898 2224 ▶ $self->VerboseDir('BinaryData', undef, $size, GetByteOrder()) if $verbose;
Branch: 1 branch
BranchTrueFalseTotal
if $verbose 19 2205 2224
9899 # avoid creating unknown tags for tags that fail condition if Unknown is 1
9900 2224 ▶ $$self{NO_UNKNOWN} = 1 if $unknown < 2;
Branch: 1 branch
BranchTrueFalseTotal
if $unknown < 2 2224 0 2224
9901 2224 my ($index, %val);
9902 2224 my $nextIndex = 0;
9903 2224 my $varSize = 0;
9904 2224 foreach $index (@tags) {
9905 18428 my ($tagInfo, $val, $saveNextIndex, $len, $mask, $wasVar, $rational, $offAdj);
9906 18428 ▶ if ($$tagTablePtr{$index}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($tagTablePtr->{$index}) { } 18428 0 18428
elsif ($topIndex and $$tagTablePtr{$index - $topIndex}) { } 0 0 0
9907 18428 $tagInfo = $self->GetTagInfo($tagTablePtr, $index);
9908 18428 ▶ unless ($tagInfo) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($tagInfo) 789 17639 18428
9909 789 ▶ next unless defined $tagInfo;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $tagInfo 738 51 789
9910 # $entry = offset of value relative to directory start (or end if negative)
9911 51 my $entry = int($index) * $increment + $varSize;
9912 51 ▶ if ($entry < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($entry < 0) 0 51 51
9913 0 $entry += $size;
9914 0 ▶ next if $entry < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $entry < 0 0 0 0
9915 }
9916 51 ▶ next if $entry >= $size;
Branch: 1 branch
BranchTrueFalseTotal
if $entry >= $size 44 7 51
9917 7 my $more = $size - $entry;
9918 7 ▶ $more = 128 if $more > 128;
Branch: 1 branch
BranchTrueFalseTotal
if $more > 128 0 7 7
9919 7 my $v = substr($$dataPt, $entry+$dirStart, $more);
9920 7 $tagInfo = $self->GetTagInfo($tagTablePtr, $index, \$v);
9921 7 ▶ next unless $tagInfo;
Branch: 1 branch
BranchTrueFalseTotal
unless $tagInfo 0 7 7
9922 }
9923 next if $$tagInfo{Unknown} and
9924 17646 ▶ ($$tagInfo{Unknown} > $unknown or $index < $nextIndex);
Branch: 1 branch
BranchTrueFalseTotal
if $tagInfo->{"Unknown"} and $tagInfo->{"Unknown"} > $unknown || $index < $nextIndex 1 17645 17646
Condition83%5/6
$tagInfo->{"Unknown"} and $tagInfo->{"Unknown"} > $unknown || $index < $nextIndex
!ll&&!rl&&r
173842611
$tagInfo->{"Unknown"} > $unknown or $index < $nextIndex
l!l&&r!l&&!r
10261
MC/DC66%2/3
$tagInfo->{"Unknown"} and $tagInfo->{"Unknown"} > $unknown || $index < $nextIndex
$tagInfo->{"Unknown"} $tagInfo->{"Unknown"} > $unknown $index < $nextIndex
Truth table75%3/4
A and B or C
A= $tagInfo->{"Unknown"}B= $tagInfo->{"Unknown"} > $unknownC= $index < $nextIndex
ABCresult
0XX0
1000
11X1
1011
9925 ▶ } elsif ($topIndex and $$tagTablePtr{$index - $topIndex}) {
Condition0%0/3
$topIndex and $$tagTablePtr{$index - $topIndex}
!ll&&!rl&&r
000
MC/DC0%0/2
$topIndex and $$tagTablePtr{$index - $topIndex}
$topIndex $$tagTablePtr{$index - $topIndex}
Truth table0%0/3
A and B
A= $topIndexB= $$tagTablePtr{$index - $topIndex}
ABresult
0X0
100
111
9926 0 ▶ $tagInfo = $self->GetTagInfo($tagTablePtr, $index - $topIndex) or next;
Branch: 1 branch
BranchTrueFalseTotal
$tagInfo = $self->GetTagInfo($tagTablePtr, $index - $topIndex) or next 0 0 0
9927 } else {
9928 # don't generate unknown tags in binary tables unless Unknown > 1
9929 0 ▶ next unless $unknown > 1;
Branch: 1 branch
BranchTrueFalseTotal
unless $unknown > 1 0 0 0
9930 0 ▶ next if $index < $nextIndex; # skip if data already used
Branch: 1 branch
BranchTrueFalseTotal
if $index < $nextIndex 0 0 0
9931 0 ▶ $tagInfo = $self->GetTagInfo($tagTablePtr, $index) or next;
Branch: 1 branch
BranchTrueFalseTotal
$tagInfo = $self->GetTagInfo($tagTablePtr, $index) or next 0 0 0
9932 0 $$tagInfo{Unknown} = 2; # set unknown to 2 for binary unknowns
9933 }
9934 # get relative offset of this entry
9935 17645 my $entry = int($index) * $increment + $varSize;
9936 # allow negative indices to represent bytes from end
9937 17645 ▶ if ($entry < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($entry < 0) 0 17645 17645
9938 0 $entry += $size;
9939 0 ▶ next if $entry < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $entry < 0 0 0 0
9940 }
9941 17645 my $more = $size - $entry;
9942 17645 ▶ last if $more <= 0; # all done if we have reached the end of data
Branch: 1 branch
BranchTrueFalseTotal
if $more <= 0 304 17341 17645
9943 17341 my $count = 1;
9944 17341 my $format = $$tagInfo{Format};
9945 17341 ▶ if (not $format) {
Branch: 4 branches
BranchTrueFalseTotal
if (not $format) { } 9978 7363 17341
elsif ($format eq 'string') { } 127 7236 7363
elsif ($format eq 'pstring') { } 0 7236 7236
elsif (not $formatSize{$format}) { } 3354 3882 7236
9946 9978 $format = $defaultFormat;
9947 } elsif ($format eq 'string') {
9948 # string with no specified count runs to end of block
9949 127 $count = $more;
9950 } elsif ($format eq 'pstring') {
9951 0 $format = 'string';
9952 0 $count = Get8u($dataPt, ($entry++)+$dirStart);
9953 0 --$more;
9954 } elsif (not $formatSize{$format}) {
9955 3354 ▶ if ($format =~ /(.*)\[(.*)\]/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($format =~ /(.*)\[(.*)\]/) { } 3170 184 3354
elsif ($format =~ /^var_/) { } 184 0 184
9956 # handle format count field
9957 3170 $format = $1;
9958 3170 $count = $2;
9959 # evaluate count to allow count to be based on previous values
9960 #### eval Format size (%val, $size, $varSize, $self)
9961 3170 $count = eval $count;
9962 3170 ▶ $@ and warn("Format $$tagInfo{Name}: $@"), next;
Branch: 1 branch
BranchTrueFalseTotal
$@ and warn(qq[Format $tagInfo->{"Name"}: $@]), next 0 3170 3170
9963 3170 ▶ next if $count < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $count < 0 0 3170 3170
9964 # allow a variable-length value of any format
9965 # (note: the next incremental index points to data immediately after
9966 # this value, regardless of the size of this value, even if it is zero)
9967 3170 ▶ if ($format =~ s/^var_//) {
Branch: 1 branch
BranchTrueFalseTotal
if ($format =~ s/^var_//) 0 3170 3170
9968 0 ▶ $varSize += $count * ($formatSize{$format} || 1) - $increment;
Condition0%0/2
$formatSize{$format} || 1
l!l
00
MC/DC0%0/1
$formatSize{$format} || 1
$formatSize{$format}
Truth table0%0/2
A
A= $formatSize{$format}
Aresult
11
00
9969 0 $wasVar = 1;
9970 # save variable size data if required for writing
9971 0 ▶ if ($$dirInfo{VarFormatData}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dirInfo->{"VarFormatData"}) 0 0 0
9972 0 push @{$$dirInfo{VarFormatData}}, [ $index, $varSize, $format ];
9973 }
9974 # don't extract value if large and we wanted it just to get
9975 # the variable-format information when writing
9976 0 ▶ next if $$tagInfo{LargeTag} and $$dirInfo{VarFormatData};
Branch: 1 branch
BranchTrueFalseTotal
if $tagInfo->{"LargeTag"} and $dirInfo->{"VarFormatData"} 0 0 0
Condition0%0/3
$tagInfo->{"LargeTag"} and $dirInfo->{"VarFormatData"}
!ll&&!rl&&r
000
MC/DC0%0/2
$tagInfo->{"LargeTag"} and $dirInfo->{"VarFormatData"}
$tagInfo->{"LargeTag"} $dirInfo->{"VarFormatData"}
Truth table0%0/3
A and B
A= $tagInfo->{"LargeTag"}B= $dirInfo->{"VarFormatData"}
ABresult
0X0
100
111
9977 }
9978 } elsif ($format =~ /^var_/) {
9979 # handle variable-length string formats
9980 184 $format = substr($format, 4);
9981 184 pos($$dataPt) = $entry + $dirStart;
9982 184 undef $count;
9983 184 ▶ if ($format eq 'ustring') {
Branch: 6 branches
BranchTrueFalseTotal
if ($format eq 'ustring') { } 0 184 184
elsif ($format eq 'pstring') { } 0 184 184
elsif ($format eq 'pstr32' or $format eq 'ustr32') { } 170 14 184
elsif ($format eq 'int16u') { } 10 4 14
elsif ($format eq 'ue7') { } 3 1 4
elsif ($$dataPt =~ /\0/g) { } 1 0 1
9984 0 ▶ $count = pos($$dataPt) - ($entry+$dirStart) if $$dataPt =~ /\G(..)*?\0\0/sg;
Branch: 1 branch
BranchTrueFalseTotal
if $$dataPt =~ /\G(..)*?\0\0/gs 0 0 0
9985 0 $varSize -= 2; # ($count includes base size of 2 bytes)
9986 } elsif ($format eq 'pstring') {
9987 0 $count = Get8u($dataPt, ($entry++)+$dirStart);
9988 0 --$more;
9989 ▶ } elsif ($format eq 'pstr32' or $format eq 'ustr32') {
Condition100%3/3
$format eq "pstr32" or $format eq "ustr32"
l!l&&r!l&&!r
216814
MC/DC100%2/2
$format eq "pstr32" or $format eq "ustr32"
$format eq "pstr32" $format eq "ustr32"
Truth table100%3/3
A or B
A= $format eq "pstr32"B= $format eq "ustr32"
ABresult
1X1
011
000
9990 170 ▶ last if $more < 4;
Branch: 1 branch
BranchTrueFalseTotal
if $more < 4 0 170 170
9991 170 $count = Get32u($dataPt, $entry + $dirStart);
9992 170 ▶ $count *= 2 if $format eq 'ustr32';
Branch: 1 branch
BranchTrueFalseTotal
if $format eq "ustr32" 168 2 170
9993 170 $entry += 4;
9994 170 $more -= 4;
9995 170 $nextIndex += 4 / $increment; # (increment next index for int32u)
9996 } elsif ($format eq 'int16u') {
9997 # int16u size of binary data to follow
9998 10 ▶ last if $more < 2;
Branch: 1 branch
BranchTrueFalseTotal
if $more < 2 0 10 10
9999 10 $count = Get16u($dataPt, $entry + $dirStart) + 2;
10000 10 $varSize -= 2; # ($count includes size word)
10001 10 $format = 'undef';
10002 } elsif ($format eq 'ue7') {
10003 3 require Image::ExifTool::BPG;
10004 3 ($val, $count) = Image::ExifTool::BPG::Get_ue7($dataPt, $entry + $dirStart);
10005 3 ▶ last unless defined $val;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $val 0 3 3
10006 3 --$varSize; # ($count includes base size of 1 byte)
10007 } elsif ($$dataPt =~ /\0/g) {
10008 1 $count = pos($$dataPt) - ($entry+$dirStart);
10009 1 --$varSize; # ($count includes base size of 1 byte)
10010 }
10011 184 ▶ $count = $more if not defined $count or $count > $more;
Branch: 1 branch
BranchTrueFalseTotal
if not defined $count or $count > $more 0 184 184
Condition33%1/3
not defined $count or $count > $more
l!l&&r!l&&!r
00184
MC/DC0%0/2
not defined $count or $count > $more
not defined $count $count > $more
Truth table33%1/3
not(A) or B
A= not defined $countB= $count > $more
ABresult
1X1
011
000
10012 184 $varSize += $count; # shift subsequent indices
10013 184 ▶ unless (defined $val) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $val) 181 3 184
10014 181 $val = substr($$dataPt, $entry+$dirStart, $count);
10015 181 ▶ $val = $self->Decode($val, 'UTF16') if $format eq 'ustring' or $format eq 'ustr32';
Branch: 1 branch
BranchTrueFalseTotal
if $format eq "ustring" or $format eq "ustr32" 168 13 181
Condition66%2/3
$format eq "ustring" or $format eq "ustr32"
l!l&&r!l&&!r
016813
MC/DC50%1/2
$format eq "ustring" or $format eq "ustr32"
$format eq "ustring" $format eq "ustr32"
Truth table66%2/3
A or B
A= $format eq "ustring"B= $format eq "ustr32"
ABresult
1X1
011
000
10016 181 ▶ $val =~ s/\0.*//s unless $format eq 'undef'; # truncate at null
Branch: 1 branch
BranchTrueFalseTotal
unless $format eq "undef" 171 10 181
10017 }
10018 184 ▶ $binVal = substr($$dataPt, $entry+$dirStart, $count) if $$self{OPTIONS}{SaveBin};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"OPTIONS"}{"SaveBin"} 0 184 184
10019 184 $wasVar = 1;
10020 # save variable size data if required for writing
10021 184 ▶ if ($$dirInfo{VarFormatData}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dirInfo->{"VarFormatData"}) 5 179 184
10022 5 push @{$$dirInfo{VarFormatData}}, [ $index, $varSize, $format ];
10023 }
10024 }
10025 }
10026 # hook to allow format, etc to be set dynamically
10027 17341 ▶ if (defined $$tagInfo{Hook}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $tagInfo->{"Hook"}) 691 16650 17341
10028 691 my $oldVarSize = $varSize;
10029 691 my $pos = $entry + $dirStart;
10030 #### eval Hook ($format, $varSize, $size, $dataPt, $pos)
10031 691 eval $$tagInfo{Hook};
10032 # save variable size data if required for writing (in case changed by Hook)
10033 691 ▶ if ($$dirInfo{VarFormatData}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($dirInfo->{'VarFormatData'}) { } 322 369 691
elsif ($varSize != $oldVarSize and $verbose > 2) { } 0 736 736
10034 0 ▶ $#{$$dirInfo{VarFormatData}} -= 1 if $wasVar; # remove previous entry for this tag
Branch: 1 branch
BranchTrueFalseTotal
if $wasVar 0 322 322
10035 322 push @{$$dirInfo{VarFormatData}}, [ $index, $varSize, $format ];
10036 ▶ } elsif ($varSize != $oldVarSize and $verbose > 2) {
Condition66%2/3
$varSize != $oldVarSize and $verbose > 2
!ll&&!rl&&r
36720
MC/DC0%0/2
$varSize != $oldVarSize and $verbose > 2
$varSize != $oldVarSize $verbose > 2
Truth table66%2/3
A and B
A= $varSize != $oldVarSizeB= $verbose > 2
ABresult
0X0
100
111
10037 0 my ($tmp, $sign) = ($varSize, '+');
10038 0 ▶ $tmp < 0 and $tmp = -$tmp, $sign = '-';
Branch: 1 branch
BranchTrueFalseTotal
$tmp < 0 and $tmp = -$tmp, $sign = "-" 0 0 0
10039 0 $offAdj = sprintf("$$self{INDENT}\[offsets adjusted by ${sign}0x%.4x after 0x%.4x $$tagInfo{Name}]\n", $tmp, $index);
10040 }
10041 }
10042 17341 ▶ if ($unknown > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($unknown > 1) 0 17341 17341
10043 # calculate next valid index for unknown tag
10044 0 my $ni = int $index;
10045 0 ▶ $ni += (($formatSize{$format} || 1) * $count) / $increment unless $wasVar;
Branch: 1 branch
BranchTrueFalseTotal
unless $wasVar 0 0 0
Condition0%0/2
$formatSize{$format} || 1
l!l
00
MC/DC0%0/1
$formatSize{$format} || 1
$formatSize{$format}
Truth table0%0/2
A
A= $formatSize{$format}
Aresult
11
00
10046 0 $saveNextIndex = $nextIndex;
10047 0 ▶ $nextIndex = $ni unless $nextIndex > $ni;
Branch: 1 branch
BranchTrueFalseTotal
unless $nextIndex > $ni 0 0 0
10048 }
10049 # allow large tags to be excluded from extraction
10050 # (provides a work-around for some tight memory situations)
10051 17341 ▶ next if $$tagInfo{LargeTag} and $$self{EXCL_TAG_LOOKUP}{lc $$tagInfo{Name}};
Branch: 1 branch
BranchTrueFalseTotal
if $tagInfo->{"LargeTag"} and $self->{"EXCL_TAG_LOOKUP"}{lc $tagInfo->{"Name"}} 0 17341 17341
Condition33%1/3
$tagInfo->{"LargeTag"} and $self->{"EXCL_TAG_LOOKUP"}{lc $tagInfo->{"Name"}}
!ll&&!rl&&r
1734100
MC/DC0%0/2
$tagInfo->{"LargeTag"} and $self->{"EXCL_TAG_LOOKUP"}{lc $tagInfo->{"Name"}}
$tagInfo->{"LargeTag"} $self->{"EXCL_TAG_LOOKUP"}{lc $tagInfo->{"Name"}}
Truth table33%1/3
A and B
A= $tagInfo->{"LargeTag"}B= $self->{"EXCL_TAG_LOOKUP"}{lc $tagInfo->{"Name"}}
ABresult
0X0
100
111
10052 # read value now if necessary
10053 17341 ▶ unless (defined $val and not $$tagInfo{SubDirectory}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $val and not $tagInfo->{"SubDirectory"}) 17157 184 17341
Condition66%2/3
defined $val and not $tagInfo->{"SubDirectory"}
!ll&&!rl&&r
171570184
MC/DC50%1/2
defined $val and not $tagInfo->{"SubDirectory"}
defined $val not $tagInfo->{"SubDirectory"}
Truth table66%2/3
A and not(B)
A= defined $valB= not $tagInfo->{"SubDirectory"}
ABresult
0X0
100
111
10054 17157 $val = ReadValue($dataPt, $entry+$dirStart, $format, $count, $more, \$rational);
10055 17157 ▶ next unless defined $val;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $val 0 17157 17157
10056 17157 $mask = $$tagInfo{Mask};
10057 17157 ▶ $val = ($val & $mask) >> $$tagInfo{BitShift} if $mask;
Branch: 1 branch
BranchTrueFalseTotal
if $mask 454 16703 17157
10058 }
10059 17341 ▶ if ($verbose and not $$tagInfo{Hidden}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($verbose and not $tagInfo->{"Hidden"}) 198 17143 17341
Condition66%2/3
$verbose and not $tagInfo->{"Hidden"}
!ll&&!rl&&r
171430198
MC/DC50%1/2
$verbose and not $tagInfo->{"Hidden"}
$verbose not $tagInfo->{"Hidden"}
Truth table66%2/3
A and not(B)
A= $verboseB= not $tagInfo->{"Hidden"}
ABresult
0X0
100
111
10060 198 ▶ if (not $$tagInfo{SubDirectory} or $$tagInfo{Format}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $tagInfo->{'SubDirectory'} or $tagInfo->{'Format'}) { } 198 0 198
Condition33%1/3
not $tagInfo->{"SubDirectory"} or $tagInfo->{"Format"}
l!l&&r!l&&!r
19800
MC/DC0%0/2
not $tagInfo->{"SubDirectory"} or $tagInfo->{"Format"}
not $tagInfo->{"SubDirectory"} $tagInfo->{"Format"}
Truth table33%1/3
not(A) or B
A= not $tagInfo->{"SubDirectory"}B= $tagInfo->{"Format"}
ABresult
1X1
011
000
10061 198 ▶ $len = $count * ($formatSize{$format} || 1);
Condition50%1/2
$formatSize{$format} || 1
l!l
1980
MC/DC0%0/1
$formatSize{$format} || 1
$formatSize{$format}
Truth table50%1/2
A
A= $formatSize{$format}
Aresult
11
00
10062 198 ▶ $len = $more if $len > $more;
Branch: 1 branch
BranchTrueFalseTotal
if $len > $more 0 198 198
10063 } else {
10064 0 $len = $more;
10065 }
10066 198 ▶ $self->VerboseInfo($index, $tagInfo,
Branch: 1 branch
BranchTrueFalseTotal
$mask ? : 2 196 198
10067 Table => $tagTablePtr,
10068 Value => $val,
10069 DataPt => $dataPt,
10070 Size => $len,
10071 Start => $entry+$dirStart,
10072 Addr => $entry+$dirStart+$base+$dataPos,
10073 Format => $format,
10074 Count => $count,
10075 Extra => $mask ? sprintf(', mask 0x%.2x',$mask) : undef,
10076 );
10077 }
10078 17341 ▶ $offAdj and $self->VPrint(2, $offAdj);
Branch: 1 branch
BranchTrueFalseTotal
$offAdj and $self->VPrint(2, $offAdj) 0 17341 17341
10079 # parse nested BinaryData directories
10080 17341 ▶ if ($$tagInfo{SubDirectory}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tagInfo->{"SubDirectory"}) 14 17327 17341
10081 14 my $subdir = $$tagInfo{SubDirectory};
10082 14 my $subTablePtr = GetTagTable($$subdir{TagTable});
10083 # use specified subdirectory length if given
10084 14 ▶ if ($$tagInfo{Format} and $formatSize{$format}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tagInfo->{'Format'} and $formatSize{$format}) { } 12 2 14
Condition66%2/3
$tagInfo->{"Format"} and $formatSize{$format}
!ll&&!rl&&r
2012
MC/DC50%1/2
$tagInfo->{"Format"} and $formatSize{$format}
$tagInfo->{"Format"} $formatSize{$format}
Truth table66%2/3
A and B
A= $tagInfo->{"Format"}B= $formatSize{$format}
ABresult
0X0
100
111
10085 12 $len = $count * $formatSize{$format};
10086 12 ▶ $len = $more if $len > $more;
Branch: 1 branch
BranchTrueFalseTotal
if $len > $more 0 12 12
10087 } else {
10088 2 $len = $more; # directory size is all of remaining data
10089 2 ▶ if ($$subTablePtr{PROCESS_PROC} and
Branch: 1 branch
BranchTrueFalseTotal
if ($subTablePtr->{"PROCESS_PROC"} and $subTablePtr->{"PROCESS_PROC"} eq \&Image::ExifTool::ProcessBinaryData) 2 0 2
Condition33%1/3
$subTablePtr->{"PROCESS_PROC"} and $subTablePtr->{"PROCESS_PROC"} eq \&Image::ExifTool::ProcessBinaryData
!ll&&!rl&&r
002
MC/DC0%0/2
$subTablePtr->{"PROCESS_PROC"} and $subTablePtr->{"PROCESS_PROC"} eq \&Image::ExifTool::ProcessBinaryData
$subTablePtr->{"PROCESS_PROC"} $subTablePtr->{"PROCESS_PROC"} eq \&Image::ExifTool::ProcessBinaryData
Truth table33%1/3
A and B
A= $subTablePtr->{"PROCESS_PROC"}B= $subTablePtr->{"PROCESS_PROC"} eq \&Image::ExifTool::ProcessBinaryData
ABresult
0X0
100
111
10090 $$subTablePtr{PROCESS_PROC} eq \&ProcessBinaryData)
10091 {
10092 # the rest of the data will be printed in the subdirectory
10093 2 $nextIndex = $size / $increment;
10094 }
10095 }
10096 14 my $subdirBase = $base;
10097 14 ▶ if (defined $$subdir{Base}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $subdir->{"Base"}) 0 14 14
10098 #### eval Base ($start,$base)
10099 0 my $start = $entry + $dirStart + $dataPos;
10100 0 $subdirBase = eval($$subdir{Base}) + $base;
10101 }
10102 14 ▶ my $start = $$subdir{Start} || 0;
Condition50%1/2
$subdir->{'Start'} || 0
l!l
014
MC/DC0%0/1
$subdir->{'Start'} || 0
$subdir->{'Start'}
Truth table50%1/2
A
A= $subdir->{'Start'}
Aresult
11
00
10103 14 my $notDup;
10104 14 ▶ if ($start =~ /\$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($start =~ /\$/) { } 0 14 14
10105 # ignore directories with a zero offset (ie. missing Nikon ShotInfo entries)
10106 0 ▶ next unless $val;
Branch: 1 branch
BranchTrueFalseTotal
unless $val 0 0 0
10107 #### eval Start ($val, $dirStart)
10108 0 $start = eval($start);
10109 0 ▶ next if $start < $dirStart or $start > $dataLen;
Branch: 1 branch
BranchTrueFalseTotal
if $start < $dirStart or $start > $dataLen 0 0 0
Condition0%0/3
$start < $dirStart or $start > $dataLen
l!l&&r!l&&!r
000
MC/DC0%0/2
$start < $dirStart or $start > $dataLen
$start < $dirStart $start > $dataLen
Truth table0%0/3
A or B
A= $start < $dirStartB= $start > $dataLen
ABresult
1X1
011
000
10110 0 $len = $$subdir{DirLen};
10111 0 ▶ $len = $dataLen - $start unless $len and $len <= $dataLen - $start;
Branch: 1 branch
BranchTrueFalseTotal
unless $len and $len <= $dataLen - $start 0 0 0
Condition0%0/3
$len and $len <= $dataLen - $start
!ll&&!rl&&r
000
MC/DC0%0/2
$len and $len <= $dataLen - $start
$len $len <= $dataLen - $start
Truth table0%0/3
A and B
A= $lenB= $len <= $dataLen - $start
ABresult
0X0
100
111
10112 } else {
10113 14 $start += $dirStart + $entry;
10114 14 $notDup = 1,
10115 }
10116 14 my %subdirInfo = (
10117 DataPt => $dataPt,
10118 DataPos => $dataPos,
10119 DataLen => $dataLen,
10120 DirStart => $start,
10121 DirLen => $len,
10122 Base => $subdirBase,
10123 NotDup => $notDup,
10124 );
10125 14 delete $$self{NO_UNKNOWN};
10126 14 $self->ProcessDirectory(\%subdirInfo, $subTablePtr, $$subdir{ProcessProc});
10127 14 ▶ $$self{NO_UNKNOWN} = 1 if $unknown < 2;
Branch: 1 branch
BranchTrueFalseTotal
if $unknown < 2 14 0 14
10128 14 next;
10129 }
10130 17327 ▶ if ($$tagInfo{IsOffset} and $$tagInfo{IsOffset} ne '3') {
Branch: 1 branch
BranchTrueFalseTotal
if ($tagInfo->{"IsOffset"} and $tagInfo->{"IsOffset"} ne 3) 38 17289 17327
Condition66%2/3
$tagInfo->{"IsOffset"} and $tagInfo->{"IsOffset"} ne 3
!ll&&!rl&&r
17289038
MC/DC50%1/2
$tagInfo->{"IsOffset"} and $tagInfo->{"IsOffset"} ne 3
$tagInfo->{"IsOffset"} $tagInfo->{"IsOffset"} ne 3
Truth table66%2/3
A and B
A= $tagInfo->{"IsOffset"}B= $tagInfo->{"IsOffset"} ne 3
ABresult
0X0
100
111
10131 38 my $et = $self;
10132 #### eval IsOffset ($val, $et)
10133 38 ▶ $val += $base + $$self{BASE} if eval $$tagInfo{IsOffset};
Branch: 1 branch
BranchTrueFalseTotal
if eval $tagInfo->{"IsOffset"} 19 19 38
10134 }
10135 17327 $val{$index} = $val;
10136 17327 my $oldBase;
10137 17327 ▶ if ($$tagInfo{SetBase}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tagInfo->{"SetBase"}) 0 17327 17327
10138 0 $oldBase = $$self{BASE};
10139 0 $$self{BASE} += $base;
10140 }
10141 17327 my $key = $self->FoundTag($tagInfo,$val);
10142 17327 ▶ $$self{BASE} = $oldBase if defined $oldBase;
Branch: 1 branch
BranchTrueFalseTotal
if defined $oldBase 0 17327 17327
10143 17327 ▶ if ($key) {
Branch: 1 branch
BranchTrueFalseTotal
if ($key) { } 15834 1493 17327
10144 15834 ▶ $$self{TAG_EXTRA}{$key}{Rational} = $rational if defined $rational;
Branch: 1 branch
BranchTrueFalseTotal
if defined $rational 49 15785 15834
10145 15834 ▶ $$self{TAG_EXTRA}{$key}{BinVal} = $binVal if defined $binVal;
Branch: 1 branch
BranchTrueFalseTotal
if defined $binVal 0 15834 15834
10146 } else {
10147 # don't increment nextIndex if we didn't extract a tag
10148 1493 ▶ $nextIndex = $saveNextIndex if defined $saveNextIndex;
Branch: 1 branch
BranchTrueFalseTotal
if defined $saveNextIndex 0 1493 1493
10149 }
10150 }
10151 2224 delete $$self{NO_UNKNOWN};
10152 2224 return 1;
10153 }
10154  
10155 #..............................................................................
10156 # Load .ExifTool_config file from user's home directory
10157 # (use of noConfig is now deprecated, use configFile = '' instead)
10158 113 ▶push @configFiles, $configFile if defined $configFile;
Branch: 1 branch
BranchTrueFalseTotal
if defined $Image::ExifTool::configFile 113 0 113
10159 113 ▶until ($noConfig) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($Image::ExifTool::noConfig) 113 0 113
10160 113 my $config = shift @configFiles;
10161 113 my $file;
10162 113 ▶ if (not defined $config) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $config) { } 0 113 113
10163 0 $config = '.ExifTool_config';
10164 # get our home directory (HOMEDRIVE and HOMEPATH are used in Windows cmd shell)
10165 my $home = $ENV{EXIFTOOL_HOME} || $ENV{HOME} ||
10166 0 ▶ ($ENV{HOMEDRIVE} || '') . ($ENV{HOMEPATH} || '') || '.';
Condition0%0/12
$ENV{'EXIFTOOL_HOME'} || $ENV{'HOME'} || ($ENV{'HOMEDRIVE'} || '') . ($ENV{'HOMEPATH'} || '') || '.'
l!l
00
$ENV{"EXIFTOOL_HOME"} or $ENV{"HOME"} or ($ENV{"HOMEDRIVE"} || "") . ($ENV{"HOMEPATH"} || "")
l!l&&r!l&&!r
000
$ENV{"EXIFTOOL_HOME"} or $ENV{"HOME"}
l!l&&r!l&&!r
000
$ENV{'HOMEDRIVE'} || ''
l!l
00
$ENV{'HOMEPATH'} || ''
l!l
00
MC/DC0%0/3
$ENV{'EXIFTOOL_HOME'} || $ENV{'HOME'} || ($ENV{'HOMEDRIVE'} || '') . ($ENV{'HOMEPATH'} || '') || '.'
$ENV{"EXIFTOOL_HOME"} $ENV{"HOME"} $ENV{'HOMEDRIVE'}
MC/DC0%0/1
$ENV{'HOMEPATH'} || ''
$ENV{'HOMEPATH'}
Truth table0%0/4
A or B or C
A= $ENV{"EXIFTOOL_HOME"}B= $ENV{"HOME"}C= $ENV{'HOMEDRIVE'}
ABCresult
1XX1
01X1
0011
0000
Truth table0%0/2
A
A= $ENV{'HOMEPATH'}
Aresult
11
00
10167 # look for the config file in 1) the home directory, 2) the program dir
10168 0 $file = "$home/$config";
10169 } else {
10170 113 ▶ length $config or last; # filename of "" disables configuration
Branch: 1 branch
BranchTrueFalseTotal
length $config or last 0 113 113
10171 0 $file = $config;
10172 }
10173 # also check executable directory unless path is absolute
10174 0 ▶ $exeDir = ($0 =~ /(.*)[\\\/]/) ? $1 : '.' unless defined $exeDir;
Branch: 2 branches
BranchTrueFalseTotal
unless defined $Image::ExifTool::exeDir 0 0 0
$0 =~ m[(.*)[\\/]] ? : 0 0 0
10175 0 ▶ -r $file or $config =~ /^\// or $file = "$exeDir/$config";
Branch: 1 branch
BranchTrueFalseTotal
-r $file or $config =~ m[^/] or $file = "$Image::ExifTool::exeDir/$config" 0 0 0
Condition0%0/3
-r $file or $config =~ m[^/]
l!l&&r!l&&!r
000
MC/DC0%0/2
-r $file or $config =~ m[^/]
-r $file $config =~ m[^/]
Truth table0%0/3
A or B
A= -r $fileB= $config =~ m[^/]
ABresult
1X1
011
000
10176 0 ▶ unless (-r $file) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-r $file) 0 0 0
10177 0 ▶ warn("Config file not found\n") if defined $Image::ExifTool::configFile;
Branch: 1 branch
BranchTrueFalseTotal
if defined $Image::ExifTool::configFile 0 0 0
10178 0 last;
10179 }
10180 0 unshift @INC, '.'; # look in current directory first
10181 0 eval { require $file }; # load the config file
10182 0 shift @INC;
10183 # print warning (minus "Compilation failed" part)
10184 0 ▶ $@ and $_=$@, s/Compilation failed.*//s, warn $_;
Branch: 1 branch
BranchTrueFalseTotal
$@ and $_ = $@, s/Compilation failed.*//s, warn($_) 0 0 0
10185 0 ▶ last unless @configFiles;
Branch: 1 branch
BranchTrueFalseTotal
unless @Image::ExifTool::configFiles 0 0 0
10186 }
10187 # read user-defined lenses (may have been defined by script instead of config file)
10188 113 ▶if (@Image::ExifTool::UserDefined::Lenses) {
Branch: 1 branch
BranchTrueFalseTotal
if (@Image::ExifTool::UserDefined::Lenses) 0 113 113
10189 0 foreach (@Image::ExifTool::UserDefined::Lenses) {
10190 0 $Image::ExifTool::userLens{$_} = 1;
10191 }
10192 }
10193 # add user-defined file types
10194 113 ▶if (%Image::ExifTool::UserDefined::FileTypes) {
Branch: 1 branch
BranchTrueFalseTotal
if (%Image::ExifTool::UserDefined::FileTypes) 0 113 113
10195 0 foreach (sort keys %Image::ExifTool::UserDefined::FileTypes) {
10196 0 my $fileInfo = $Image::ExifTool::UserDefined::FileTypes{$_};
10197 0 my $type = uc $_;
10198 0 ▶ ref $fileInfo eq 'HASH' or $fileTypeLookup{$type} = $fileInfo, next;
Branch: 1 branch
BranchTrueFalseTotal
ref $fileInfo eq "HASH" or $Image::ExifTool::fileTypeLookup{$type} = $fileInfo, next 0 0 0
10199 0 my $baseType = $$fileInfo{BaseType};
10200 0 ▶ if ($baseType) {
Branch: 1 branch
BranchTrueFalseTotal
if ($baseType) { } 0 0 0
10201 0 ▶ if ($$fileInfo{Description}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fileInfo->{'Description'}) { } 0 0 0
10202 0 $fileTypeLookup{$type} = [ $baseType, $$fileInfo{Description} ];
10203 } else {
10204 0 $fileTypeLookup{$type} = $baseType;
10205 }
10206 0 ▶ if (defined $$fileInfo{Writable} and not $$fileInfo{Writable}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fileInfo->{"Writable"} and not $fileInfo->{"Writable"}) 0 0 0
Condition0%0/3
defined $fileInfo->{"Writable"} and not $fileInfo->{"Writable"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $fileInfo->{"Writable"} and not $fileInfo->{"Writable"}
defined $fileInfo->{"Writable"} not $fileInfo->{"Writable"}
Truth table0%0/3
A and not(B)
A= defined $fileInfo->{"Writable"}B= not $fileInfo->{"Writable"}
ABresult
0X0
100
111
10207 # first make sure we are using an actual base type and not a derived type
10208 0 ▶ $baseType = $fileTypeLookup{$baseType} while $baseType and not ref $fileTypeLookup{$baseType};
Branch: 1 branch
BranchTrueFalseTotal
$baseType and not ref $Image::ExifTool::fileTypeLookup{$baseType} and do { $baseType = $Image::ExifTool::fileTypeLookup{$baseType} } 0 0 0
Condition0%0/3
$baseType and not ref $Image::ExifTool::fileTypeLookup{$baseType}
!ll&&!rl&&r
000
MC/DC0%0/2
$baseType and not ref $Image::ExifTool::fileTypeLookup{$baseType}
$baseType not ref $Image::ExifTool::fileTypeLookup{$baseType}
Truth table0%0/3
A and not(B)
A= $baseTypeB= not ref $Image::ExifTool::fileTypeLookup{$baseType}
ABresult
0X0
100
111
10209 # mark this type as not writable
10210 0 ▶ $noWriteFile{$baseType} or $noWriteFile{$baseType} = [ ];
Branch: 1 branch
BranchTrueFalseTotal
$Image::ExifTool::noWriteFile{$baseType} or $Image::ExifTool::noWriteFile{$baseType} = [] 0 0 0
10211 0 push @{$noWriteFile{$baseType}}, $type;
10212 }
10213 } else {
10214 0 ▶ $fileTypeLookup{$type} = [ $type, $$fileInfo{Description} || $type ];
Condition0%0/3
$fileInfo->{'Description'} || $type
l!l&&r!l&&!r
000
MC/DC0%0/2
$fileInfo->{'Description'} || $type
$fileInfo->{'Description'} $type
Truth table0%0/3
A || B
A= $fileInfo->{'Description'}B= $type
ABresult
1X1
011
000
10215 0 $moduleName{$type} = 0; # not supported
10216 0 ▶ if ($$fileInfo{Magic}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fileInfo->{"Magic"}) 0 0 0
10217 0 $magicNumber{$type} = $$fileInfo{Magic};
10218 0 ▶ push @fileTypes, $type unless grep /^$type$/, @fileTypes;
Branch: 1 branch
BranchTrueFalseTotal
unless grep /^$type$/, @Image::ExifTool::fileTypes 0 0 0
10219 }
10220 }
10221 0 ▶ $mimeType{$type} = $$fileInfo{MIMEType} if defined $$fileInfo{MIMEType};
Branch: 1 branch
BranchTrueFalseTotal
if defined $fileInfo->{"MIMEType"} 0 0 0
10222 }
10223 }
10224  
10225 #------------------------------------------------------------------------------
10226 113 1; # end
« Image/ExifTool/GIF.pm ↑ Summary Image/ExifTool/TagInfoXML.pm »