/
ExifTool.pm
9720 lines (9422 loc) · 413 KB
/
ExifTool.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#------------------------------------------------------------------------------
# File: ExifTool.pm
#
# Description: Read and write meta information
#
# URL: https://exiftool.org/
#
# Revisions: Nov. 12/2003 - P. Harvey Created
# (See html/history.html for revision history)
#
# Legal: Copyright (c) 2003-2024, Phil Harvey (philharvey66 at gmail.com)
# This library is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
#------------------------------------------------------------------------------
package Image::ExifTool;
use strict;
require 5.004; # require 5.004 for UNIVERSAL::isa (otherwise 5.002 would do)
require Exporter;
use File::RandomAccess;
use overload;
use vars qw($VERSION $RELEASE @ISA @EXPORT_OK %EXPORT_TAGS $AUTOLOAD @fileTypes
%allTables @tableOrder $exifAPP1hdr $xmpAPP1hdr $xmpExtAPP1hdr
$psAPP13hdr $psAPP13old @loadAllTables %UserDefined $evalWarning
%noWriteFile %magicNumber @langs $defaultLang %langName %charsetName
%mimeType $swapBytes $swapWords $currentByteOrder %unpackStd
%jpegMarker %specialTags %fileTypeLookup $testLen $exeDir
%static_vars);
$VERSION = '12.84';
$RELEASE = '';
@ISA = qw(Exporter);
%EXPORT_TAGS = (
# all public non-object-oriented functions:
Public => [qw(
ImageInfo AvailableOptions GetTagName GetShortcuts GetAllTags
GetWritableTags GetAllGroups GetDeleteGroups GetFileType CanWrite
CanCreate AddUserDefinedTags
)],
# exports not part of the public API, but used by ExifTool modules:
DataAccess => [qw(
ReadValue GetByteOrder SetByteOrder ToggleByteOrder Get8u Get8s Get16u
Get16s Get32u Get32s Get64u GetFloat GetDouble GetFixed32s Write
WriteValue Tell Set8u Set8s Set16u Set32u Set64u Set64s
)],
Utils => [qw(GetTagTable TagTableKeys GetTagInfoList AddTagToTable HexDump)],
Vars => [qw(%allTables @tableOrder @fileTypes)],
);
# set all of our EXPORT_TAGS in EXPORT_OK
Exporter::export_ok_tags(keys %EXPORT_TAGS);
# test for problems that can arise if encoding.pm is used
{ my $t = "\xff"; die "Incompatible encoding!\n" if ord($t) != 0xff; }
# The following functions defined in Image::ExifTool::Writer.pl are declared
# here so their prototypes will be available. These Writer routines will be
# autoloaded when any of them is called.
sub SetNewValue($;$$%);
sub SetNewValuesFromFile($$;@);
sub GetNewValue($$;$);
sub GetNewValues($$;$);
sub CountNewValues($);
sub SaveNewValues($);
sub RestoreNewValues($);
sub WriteInfo($$;$$);
sub SetFileModifyDate($$;$$$);
sub SetFileName($$;$$$);
sub SetSystemTags($$);
sub GetAllTags(;$);
sub GetWritableTags(;$);
sub GetAllGroups($;$);
sub GetNewGroups($);
sub GetDeleteGroups();
sub AddUserDefinedTags($%);
sub SetAlternateFile($$$);
# non-public routines below
sub InsertTagValues($$;$$$$);
sub IsWritable($);
sub IsSameFile($$$);
sub IsRawType($);
sub GetNewFileName($$);
sub LoadAllTables();
sub GetNewTagInfoList($;$);
sub GetNewTagInfoHash($@);
sub GetLangInfo($$);
sub Get64s($$);
sub Get64u($$);
sub GetFixed64s($$);
sub GetExtended($$);
sub Set64u(@);
sub Set64s(@);
sub DecodeBits($$;$);
sub EncodeBits($$;$$);
sub Filter($$$);
sub HexDump($;$%);
sub DumpTrailer($$);
sub DumpUnknownTrailer($$);
sub VerboseInfo($$$%);
sub VerboseValue($$$;$);
sub VPrint($$@);
sub Rationalize($;$);
sub Write($@);
sub GetGeolocateTags($$;$);
sub WriteTrailerBuffer($$$);
sub AddNewTrailers($;@);
sub Tell($);
sub WriteValue($$;$$$$);
sub WriteDirectory($$$;$);
sub WriteBinaryData($$$);
sub CheckBinaryData($$$);
sub WriteTIFF($$$);
sub PackUTF8(@);
sub UnpackUTF8($);
sub SetPreferredByteOrder($;$);
sub ImageDataHash($$$;$$);
sub CopyBlock($$$);
sub CopyFileAttrs($$$);
sub TimeNow(;$$);
sub InverseDateTime($$;$$);
sub NewGUID();
sub MakeTiffHeader($$$$;$$);
# other subroutine definitions
sub SplitFileName($);
sub EncodeFileName($$;$);
sub Open($*$;$);
sub Exists($$;$);
sub IsDirectory($$);
sub Rename($$$);
sub Unlink($@);
sub SetFileTime($$;$$$$);
sub DoEscape($$);
sub ConvertFileSize($;$);
sub ParseArguments($;@); #(defined in attempt to avoid mod_perl problem)
sub ReadValue($$$;$$$);
# list of main tag tables to load in LoadAllTables() (sub-tables are recursed
# automatically). Note: They will appear in this order in the documentation
# unless tweaked in BuildTagLookup::GetTableOrder().
@loadAllTables = qw(
PhotoMechanic Exif GeoTiff CanonRaw KyoceraRaw Lytro MinoltaRaw PanasonicRaw
SigmaRaw JPEG GIMP Jpeg2000 GIF BMP BMP::OS2 BMP::Extra BPG BPG::Extensions
WPG ICO PICT PNG MNG FLIF DjVu DPX OpenEXR ZISRAW MRC LIF MRC::FEI12 MIFF
PCX PGF PSP PhotoCD Radiance Other::PFM PDF PostScript Photoshop::Header
Photoshop::Layers Photoshop::ImageData FujiFilm::RAF FujiFilm::IFD
FujiFilm::MRAW Samsung::Trailer Sony::SRF2 Sony::SR2SubIFD Sony::PMP ITC ID3
ID3::Lyrics3 FLAC AAC Ogg Vorbis APE APE::NewHeader APE::OldHeader Audible
MPC MPEG::Audio MPEG::Video MPEG::Xing M2TS QuickTime QuickTime::ImageFile
QuickTime::Stream QuickTime::Tags360Fly Matroska Matroska::StdTag MOI MXF DV
Flash Flash::FLV Real::Media Real::Audio Real::Metafile Red RIFF AIFF ASF
WTV DICOM FITS XISF MIE JSON HTML XMP::SVG Palm Palm::MOBI Palm::EXTH
Torrent EXE EXE::PEVersion EXE::PEString EXE::MachO EXE::PEF EXE::ELF
EXE::AR EXE::CHM LNK Font VCard Text VCard::VCalendar VCard::VNote RSRC
Rawzor ZIP ZIP::GZIP ZIP::RAR ZIP::RAR5 RTF OOXML iWork ISO FLIR::AFF
FLIR::FPF MacOS MacOS::MDItem FlashPix::DocTable
);
# alphabetical list of current Lang modules
@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);
$defaultLang = 'en'; # default language
# language names
%langName = (
cs => 'Czech (Čeština)',
de => 'German (Deutsch)',
en => 'English',
en_ca => 'Canadian English',
en_gb => 'British English',
es => 'Spanish (Español)',
fi => 'Finnish (Suomi)',
fr => 'French (Français)',
it => 'Italian (Italiano)',
ja => 'Japanese (日本語)',
ko => 'Korean (한국어)',
nl => 'Dutch (Nederlands)',
pl => 'Polish (Polski)',
ru => 'Russian (Русский)',
sk => 'Slovak (Slovenčina)',
sv => 'Swedish (Svenska)',
'tr'=> 'Turkish (Türkçe)',
zh_cn => 'Simplified Chinese (简体中文)',
zh_tw => 'Traditional Chinese (繁體中文)',
);
# recognized file types, in the order we test unknown files
# Notes: 1) There is no need to test for like types separately here
# 2) Put types with weak file signatures at end of list to avoid false matches
# 3) PLIST must be in this list for the binary PLIST format, although it may
# cause a file to be checked twice for XML
@fileTypes = qw(JPEG EXV CRW DR4 TIFF GIF MRW RAF X3F JP2 PNG MIE MIFF PS PDF
PSD XMP BMP WPG BPG PPM RIFF AIFF ASF MOV MPEG Real SWF PSP FLV
OGG FLAC APE MPC MKV MXF DV PMP IND PGF ICC ITC FLIR FLIF FPF
LFP HTML VRD RTF FITS XISF XCF DSS QTIF FPX PICT ZIP GZIP PLIST
RAR 7Z BZ2 CZI TAR EXE EXR HDR CHM LNK WMF AVC DEX DPX RAW Font
JUMBF RSRC M2TS MacOS PHP PCX DCX DWF DWG DXF WTV Torrent VCard
LRI R3D AA PDB PFM2 MRC LIF JXL MOI ISO ALIAS JSON MP3 DICOM PCD
ICO TXT AAC);
# file types that we can write (edit)
my @writeTypes = qw(JPEG TIFF GIF CRW MRW ORF RAF RAW PNG MIE PSD XMP PPM EPS
X3F PS PDF ICC VRD DR4 JP2 JXL EXIF AI AIT IND MOV EXV FLIF
RIFF);
my %writeTypes; # lookup for writable file types (hash filled if required)
# file extensions that we can't write for various base types
# (See here for 3FR reason: https://exiftool.org/forum/index.php?msg=17570)
%noWriteFile = (
TIFF => [ qw(3FR DCR K25 KDC SRF) ],
XMP => [ qw(SVG INX) ],
JP2 => [ qw(J2C JPC) ],
MOV => [ qw(INSV) ],
);
# file extensions that we can only write for various base types
my %onlyWriteFile = ( RIFF => [ qw(WEBP) ] );
# file types that we can create from scratch
# - must update CanCreate() documentation if this list is changed!
my %createTypes = map { $_ => 1 } qw(XMP ICC MIE VRD DR4 EXIF EXV);
# file type lookup for all recognized file extensions (upper case)
# (if extension may be more than one type, the type is a list where
# the writable type should come first if it exists)
%fileTypeLookup = (
'360' => ['MOV', 'GoPro 360 video'],
'3FR' => ['TIFF', 'Hasselblad RAW format'],
'3G2' => ['MOV', '3rd Gen. Partnership Project 2 audio/video'],
'3GP' => ['MOV', '3rd Gen. Partnership Project audio/video'],
'3GP2'=> '3G2',
'3GPP'=> '3GP',
'7Z' => ['7Z', '7z archive'],
A => ['EXE', 'Static library'],
AA => ['AA', 'Audible Audiobook'],
AAC => ['AAC', 'Advanced Audio Coding'],
AAE => ['PLIST','Apple edit information'],
AAX => ['MOV', 'Audible Enhanced Audiobook'],
ACR => ['DICOM','American College of Radiology ACR-NEMA'],
ACFM => ['Font', 'Adobe Composite Font Metrics'],
AFM => ['Font', 'Adobe Font Metrics'],
AMFM => ['Font', 'Adobe Multiple Master Font Metrics'],
AI => [['PDF','PS'], 'Adobe Illustrator'],
AIF => 'AIFF',
AIFC => ['AIFF', 'Audio Interchange File Format Compressed'],
AIFF => ['AIFF', 'Audio Interchange File Format'],
AIT => 'AI',
ALIAS=> ['ALIAS','MacOS file alias'],
APE => ['APE', "Monkey's Audio format"],
APNG => ['PNG', 'Animated Portable Network Graphics'],
ARW => ['TIFF', 'Sony Alpha RAW format'],
ARQ => ['TIFF', 'Sony Alpha Pixel-Shift RAW format'],
ASF => ['ASF', 'Microsoft Advanced Systems Format'],
AVC => ['AVC', 'Advanced Video Connection'], # (extensions are actually _AU,_AD,_IM,_ID)
AVI => ['RIFF', 'Audio Video Interleaved'],
AVIF => ['MOV', 'AV1 Image File Format'],
AZW => 'MOBI', # (see http://wiki.mobileread.com/wiki/AZW)
AZW3 => 'MOBI',
BMP => ['BMP', 'Windows Bitmap'],
BPG => ['BPG', 'Better Portable Graphics'],
BTF => ['BTF', 'Big Tagged Image File Format'], #(unofficial)
BZ2 => ['BZ2', 'BZIP2 archive'],
C2PA => ['JUMBF','Coalition for Content Provenance and Authenticity'],
CHM => ['CHM', 'Microsoft Compiled HTML format'],
CIFF => ['CRW', 'Camera Image File Format'],
COS => ['COS', 'Capture One Settings'],
CR2 => ['TIFF', 'Canon RAW 2 format'],
CR3 => ['MOV', 'Canon RAW 3 format'],
CRM => ['MOV', 'Canon RAW Movie'],
CRW => ['CRW', 'Canon RAW format'],
CS1 => ['PSD', 'Sinar CaptureShop 1-Shot RAW'],
CSV => ['TXT', 'Comma-Separated Values'],
CUR => ['ICO', 'Windows Cursor'],
CZI => ['CZI', 'Zeiss Integrated Software RAW'],
DC3 => 'DICM',
DCM => 'DICM',
DCP => ['TIFF', 'DNG Camera Profile'],
DCR => ['TIFF', 'Kodak Digital Camera RAW'],
DCX => ['DCX', 'Multi-page PC Paintbrush'],
DEX => ['DEX', 'Dalvik Executable format'],
DFONT=> ['Font', 'Macintosh Data fork Font'],
DIB => ['BMP', 'Device Independent Bitmap'],
DIC => 'DICM',
DICM => ['DICOM','Digital Imaging and Communications in Medicine'],
DIR => ['DIR', 'Directory'],
DIVX => ['ASF', 'DivX media format'],
DJV => 'DJVU',
DJVU => ['AIFF', 'DjVu image'],
DLL => ['EXE', 'Windows Dynamic Link Library'],
DNG => ['TIFF', 'Digital Negative'],
DOC => ['FPX', 'Microsoft Word Document'],
DOCM => [['ZIP','FPX'], 'Office Open XML Document Macro-enabled'],
# Note: I have seen a password-protected DOCX file which was FPX-like, so I assume
# that any other MS Office file could be like this too. The only difference is
# that the ZIP and FPX formats are checked first, so if this is wrong, no biggie.
DOCX => [['ZIP','FPX'], 'Office Open XML Document'],
DOT => ['FPX', 'Microsoft Word Template'],
DOTM => [['ZIP','FPX'], 'Office Open XML Document Template Macro-enabled'],
DOTX => [['ZIP','FPX'], 'Office Open XML Document Template'],
DPX => ['DPX', 'Digital Picture Exchange' ],
DR4 => ['DR4', 'Canon VRD version 4 Recipe'],
DS2 => ['DSS', 'Digital Speech Standard 2'],
DSS => ['DSS', 'Digital Speech Standard'],
DV => ['DV', 'Digital Video'],
DVB => ['MOV', 'Digital Video Broadcasting'],
'DVR-MS'=>['ASF', 'Microsoft Digital Video recording'],
DWF => ['DWF', 'Autodesk drawing (Design Web Format)'],
DWG => ['DWG', 'AutoCAD Drawing'],
DYLIB=> ['EXE', 'Mach-O Dynamic Link Library'],
DXF => ['DXF', 'AutoCAD Drawing Exchange Format'],
EIP => ['ZIP', 'Capture One Enhanced Image Package'],
EPS => ['EPS', 'Encapsulated PostScript Format'],
EPS2 => 'EPS',
EPS3 => 'EPS',
EPSF => 'EPS',
EPUB => ['ZIP', 'Electronic Publication'],
ERF => ['TIFF', 'Epson Raw Format'],
EXE => ['EXE', 'Windows executable file'],
EXR => ['EXR', 'Open EXR'],
EXIF => ['EXIF', 'Exchangable Image File Metadata'],
EXV => ['EXV', 'Exiv2 metadata'],
F4A => ['MOV', 'Adobe Flash Player 9+ Audio'],
F4B => ['MOV', 'Adobe Flash Player 9+ audio Book'],
F4P => ['MOV', 'Adobe Flash Player 9+ Protected'],
F4V => ['MOV', 'Adobe Flash Player 9+ Video'],
FFF => [['TIFF','FLIR'], 'Hasselblad Flexible File Format'],
FIT => 'FITS',
FITS => ['FITS', 'Flexible Image Transport System'],
FLAC => ['FLAC', 'Free Lossless Audio Codec'],
FLA => ['FPX', 'Macromedia/Adobe Flash project'],
FLIF => ['FLIF', 'Free Lossless Image Format'],
FLIR => ['FLIR', 'FLIR File Format'], # (not an actual extension)
FLV => ['FLV', 'Flash Video'],
FPF => ['FPF', 'FLIR Public image Format'],
FPX => ['FPX', 'FlashPix'],
GIF => ['GIF', 'Compuserve Graphics Interchange Format'],
GLV => ['MOV', 'Garmin Low-resolution Video'],
GPR => ['TIFF', 'General Purpose RAW'], # https://gopro.github.io/gpr/
GZ => 'GZIP',
GZIP => ['GZIP', 'GNU ZIP compressed archive'],
HDP => ['TIFF', 'Windows HD Photo'],
HDR => ['HDR', 'Radiance RGBE High Dynamic Range'],
HEIC => ['MOV', 'High Efficiency Image Format still image'],
HEIF => ['MOV', 'High Efficiency Image Format'],
HIF => 'HEIF',
HTM => 'HTML',
HTML => ['HTML', 'HyperText Markup Language'],
ICAL => 'ICS',
ICC => ['ICC', 'International Color Consortium'],
ICM => 'ICC',
ICO => ['ICO', 'Windows Icon'],
ICS => ['VCard','iCalendar Schedule'],
IDML => ['ZIP', 'Adobe InDesign Markup Language'],
IIQ => ['TIFF', 'Phase One Intelligent Image Quality RAW'],
IND => ['IND', 'Adobe InDesign'],
INDD => ['IND', 'Adobe InDesign Document'],
INDT => ['IND', 'Adobe InDesign Template'],
INSV => ['MOV', 'Insta360 Video'],
INSP => ['JPEG', 'Insta360 Picture'],
INX => ['XMP', 'Adobe InDesign Interchange'],
ISO => ['ISO', 'ISO 9660 disk image'],
ITC => ['ITC', 'iTunes Cover Flow'],
J2C => ['JP2', 'JPEG 2000 codestream'],
J2K => 'J2C',
JNG => ['PNG', 'JPG Network Graphics'],
JP2 => ['JP2', 'JPEG 2000 file'],
# JP4? - looks like a JPEG but the image data is different
JPC => 'J2C',
JPE => 'JPEG',
JPEG => ['JPEG', 'Joint Photographic Experts Group'],
JPH => ['JP2', 'High-throughput JPEG 2000'],
JPF => 'JP2',
JPG => 'JPEG',
JPM => ['JP2', 'JPEG 2000 compound image'],
JPS => ['JPEG', 'JPEG Stereo image'],
JPX => ['JP2', 'JPEG 2000 with extensions'],
JSON => ['JSON', 'JavaScript Object Notation'],
JUMBF=> ['JUMBF','JPEG Universal Metadata Box Format'],
JXL => ['JXL', 'JPEG XL'],
JXR => ['TIFF', 'JPEG XR'],
K25 => ['TIFF', 'Kodak DC25 RAW'],
KDC => ['TIFF', 'Kodak Digital Camera RAW'],
KEY => ['ZIP', 'Apple Keynote presentation'],
KTH => ['ZIP', 'Apple Keynote Theme'],
LA => ['RIFF', 'Lossless Audio'],
LFP => ['LFP', 'Lytro Light Field Picture'],
LFR => 'LFP', # (Light Field RAW)
LIF => ['LIF', 'Leica Image File'],
LNK => ['LNK', 'Windows shortcut'],
LRI => ['LRI', 'Light RAW'],
LRV => ['MOV', 'Low-Resolution Video'],
M2T => 'M2TS',
M2TS => ['M2TS', 'MPEG-2 Transport Stream'],
M2V => ['MPEG', 'MPEG-2 Video'],
M4A => ['MOV', 'MPEG-4 Audio'],
M4B => ['MOV', 'MPEG-4 audio Book'],
M4P => ['MOV', 'MPEG-4 Protected'],
M4V => ['MOV', 'MPEG-4 Video'],
MACOS=> ['MacOS','MacOS ._ sidecar file'],
MAX => ['FPX', '3D Studio MAX'],
MEF => ['TIFF', 'Mamiya (RAW) Electronic Format'],
MIE => ['MIE', 'Meta Information Encapsulation format'],
MIF => 'MIFF',
MIFF => ['MIFF', 'Magick Image File Format'],
MKA => ['MKV', 'Matroska Audio'],
MKS => ['MKV', 'Matroska Subtitle'],
MKV => ['MKV', 'Matroska Video'],
MNG => ['PNG', 'Multiple-image Network Graphics'],
MOBI => ['PDB', 'Mobipocket electronic book'],
MODD => ['PLIST','Sony Picture Motion metadata'],
MOI => ['MOI', 'MOD Information file'],
MOS => ['TIFF', 'Creo Leaf Mosaic'],
MOV => ['MOV', 'Apple QuickTime movie'],
MP3 => ['MP3', 'MPEG-1 Layer 3 audio'],
MP4 => ['MOV', 'MPEG-4 video'],
MPC => ['MPC', 'Musepack Audio'],
MPEG => ['MPEG', 'MPEG-1 or MPEG-2 audio/video'],
MPG => 'MPEG',
MPO => ['JPEG', 'Extended Multi-Picture format'],
MQV => ['MOV', 'Sony Mobile Quicktime Video'],
MRC => ['MRC', 'Medical Research Council image'],
MRW => ['MRW', 'Minolta RAW format'],
MTS => 'M2TS',
MXF => ['MXF', 'Material Exchange Format'],
# NDPI => ['TIFF', 'Hamamatsu NanoZoomer Digital Pathology Image'],
NEF => ['TIFF', 'Nikon (RAW) Electronic Format'],
NEWER => 'COS',
NKSC => ['XMP', 'Nikon Sidecar'],
NMBTEMPLATE => ['ZIP','Apple Numbers Template'],
NRW => ['TIFF', 'Nikon RAW (2)'],
NUMBERS => ['ZIP','Apple Numbers spreadsheet'],
O => ['EXE', 'Relocatable Object'],
ODB => ['ZIP', 'Open Document Database'],
ODC => ['ZIP', 'Open Document Chart'],
ODF => ['ZIP', 'Open Document Formula'],
ODG => ['ZIP', 'Open Document Graphics'],
ODI => ['ZIP', 'Open Document Image'],
ODP => ['ZIP', 'Open Document Presentation'],
ODS => ['ZIP', 'Open Document Spreadsheet'],
ODT => ['ZIP', 'Open Document Text file'],
OFR => ['RIFF', 'OptimFROG audio'],
OGG => ['OGG', 'Ogg Vorbis audio file'],
OGV => ['OGG', 'Ogg Video file'],
ONP => ['JSON', 'ON1 Presets'],
OPUS => ['OGG', 'Ogg Opus audio file'],
ORF => ['ORF', 'Olympus RAW format'],
ORI => 'ORF',
OTF => ['Font', 'Open Type Font'],
PAC => ['RIFF', 'Lossless Predictive Audio Compression'],
PAGES => ['ZIP', 'Apple Pages document'],
PBM => ['PPM', 'Portable BitMap'],
PCD => ['PCD', 'Kodak Photo CD Image Pac'],
PCT => 'PICT',
PCX => ['PCX', 'PC Paintbrush'],
PDB => ['PDB', 'Palm Database'],
PDF => ['PDF', 'Adobe Portable Document Format'],
PEF => ['TIFF', 'Pentax (RAW) Electronic Format'],
PFA => ['Font', 'PostScript Font ASCII'],
PFB => ['Font', 'PostScript Font Binary'],
PFM => [['Font','PFM2'], 'Printer Font Metrics'], # (description is overridden for Portable FloatMap images)
PGF => ['PGF', 'Progressive Graphics File'],
PGM => ['PPM', 'Portable Gray Map'],
PHP => ['PHP', 'PHP Hypertext Preprocessor'],
PHP3 => 'PHP',
PHP4 => 'PHP',
PHP5 => 'PHP',
PHPS => 'PHP',
PHTML=> 'PHP',
PICT => ['PICT', 'Apple PICTure'],
PLIST=> ['PLIST','Apple Property List'],
PMP => ['PMP', 'Sony DSC-F1 Cyber-Shot PMP'], # should stand for Proprietery Metadata Package ;)
PNG => ['PNG', 'Portable Network Graphics'],
POT => ['FPX', 'Microsoft PowerPoint Template'],
POTM => [['ZIP','FPX'], 'Office Open XML Presentation Template Macro-enabled'],
POTX => [['ZIP','FPX'], 'Office Open XML Presentation Template'],
PPAM => [['ZIP','FPX'], 'Office Open XML Presentation Addin Macro-enabled'],
PPAX => [['ZIP','FPX'], 'Office Open XML Presentation Addin'],
PPM => ['PPM', 'Portable Pixel Map'],
PPS => ['FPX', 'Microsoft PowerPoint Slideshow'],
PPSM => [['ZIP','FPX'], 'Office Open XML Presentation Slideshow Macro-enabled'],
PPSX => [['ZIP','FPX'], 'Office Open XML Presentation Slideshow'],
PPT => ['FPX', 'Microsoft PowerPoint Presentation'],
PPTM => [['ZIP','FPX'], 'Office Open XML Presentation Macro-enabled'],
PPTX => [['ZIP','FPX'], 'Office Open XML Presentation'],
PRC => ['PDB', 'Palm Database'],
PS => ['PS', 'PostScript'],
PS2 => 'PS',
PS3 => 'PS',
PSB => ['PSD', 'Photoshop Large Document'],
PSD => ['PSD', 'Photoshop Document'],
PSDT => ['PSD', 'Photoshop Document Template'],
PSP => ['PSP', 'Paint Shop Pro'],
PSPFRAME => 'PSP',
PSPIMAGE => 'PSP',
PSPSHAPE => 'PSP',
PSPTUBE => 'PSP',
QIF => 'QTIF',
QT => 'MOV',
QTI => 'QTIF',
QTIF => ['QTIF', 'QuickTime Image File'],
R3D => ['R3D', 'Redcode RAW Video'],
RA => ['Real', 'Real Audio'],
RAF => ['RAF', 'FujiFilm RAW Format'],
RAM => ['Real', 'Real Audio Metafile'],
RAR => ['RAR', 'RAR Archive'],
RAW => [['RAW','TIFF'], 'Kyocera Contax N Digital RAW or Panasonic RAW'],
RIF => 'RIFF',
RIFF => ['RIFF', 'Resource Interchange File Format'],
RM => ['Real', 'Real Media'],
RMVB => ['Real', 'Real Media Variable Bitrate'],
RPM => ['Real', 'Real Media Plug-in Metafile'],
RSRC => ['RSRC', 'Mac OS Resource'],
RTF => ['RTF', 'Rich Text Format'],
RV => ['Real', 'Real Video'],
RW2 => ['TIFF', 'Panasonic RAW 2'],
RWL => ['TIFF', 'Leica RAW'],
RWZ => ['RWZ', 'Rawzor compressed image'],
SEQ => ['FLIR', 'FLIR image Sequence'],
SKETCH => ['ZIP', 'Sketch design file'],
SO => ['EXE', 'Shared Object file'],
SR2 => ['TIFF', 'Sony RAW Format 2'],
SRF => ['TIFF', 'Sony RAW Format'],
SRW => ['TIFF', 'Samsung RAW format'],
SVG => ['XMP', 'Scalable Vector Graphics'],
SWF => ['SWF', 'Shockwave Flash'],
TAR => ['TAR', 'TAR archive'],
THM => ['JPEG', 'Thumbnail'],
THMX => [['ZIP','FPX'], 'Office Open XML Theme'],
TIF => 'TIFF',
TIFF => ['TIFF', 'Tagged Image File Format'],
TORRENT => ['Torrent', 'BitTorrent description file'],
TS => 'M2TS',
TTC => ['Font', 'True Type Font Collection'],
TTF => ['Font', 'True Type Font'],
TUB => 'PSP',
TXT => ['TXT', 'Text file'],
VCARD=> ['VCard','Virtual Card'],
VCF => 'VCARD',
VOB => ['MPEG', 'Video Object'],
VNT => [['FPX','VCard'], 'Scene7 Vignette or V-Note text file'],
VRD => ['VRD', 'Canon VRD Recipe Data'],
VSD => ['FPX', 'Microsoft Visio Drawing'],
WAV => ['RIFF', 'WAVeform (Windows digital audio)'],
WDP => ['TIFF', 'Windows Media Photo'],
WEBM => ['MKV', 'Google Web Movie'],
WEBP => ['RIFF', 'Google Web Picture'],
WMA => ['ASF', 'Windows Media Audio'],
WMF => ['WMF', 'Windows Metafile Format'],
WMV => ['ASF', 'Windows Media Video'],
WV => ['RIFF', 'WavePack lossless audio'],
X3F => ['X3F', 'Sigma RAW format'],
XCF => ['XCF', 'GIMP native image format'],
XHTML=> ['HTML', 'Extensible HyperText Markup Language'],
XISF => ['XISF', 'Extensible Image Serialization Format'],
XLA => ['FPX', 'Microsoft Excel Add-in'],
XLAM => [['ZIP','FPX'], 'Office Open XML Spreadsheet Add-in Macro-enabled'],
XLS => ['FPX', 'Microsoft Excel Spreadsheet'],
XLSB => [['ZIP','FPX'], 'Office Open XML Spreadsheet Binary'],
XLSM => [['ZIP','FPX'], 'Office Open XML Spreadsheet Macro-enabled'],
XLSX => [['ZIP','FPX'], 'Office Open XML Spreadsheet'],
XLT => ['FPX', 'Microsoft Excel Template'],
XLTM => [['ZIP','FPX'], 'Office Open XML Spreadsheet Template Macro-enabled'],
XLTX => [['ZIP','FPX'], 'Office Open XML Spreadsheet Template'],
XMP => ['XMP', 'Extensible Metadata Platform'],
WOFF => ['Font', 'Web Open Font Format'],
WOFF2=> ['Font', 'Web Open Font Format2'],
WPG => ['WPG', 'WordPerfect Graphics'],
WTV => ['WTV', 'Windows recorded TV show'],
ZIP => ['ZIP', 'ZIP archive'],
);
# typical extension for each file type (if different than FileType)
# - case is not significant
my %fileTypeExt = (
'Canon 1D RAW' => 'tif',
DICOM => 'dcm',
FLIR => 'fff',
GZIP => 'gz',
JPEG => 'jpg',
M2TS => 'mts',
MPEG => 'mpg',
TIFF => 'tif',
VCard => 'vcf',
);
# descriptions for file types not found in above file extension lookup
my %fileDescription = (
DICOM => 'Digital Imaging and Communications in Medicine',
XML => 'Extensible Markup Language',
'Win32 EXE' => 'Windows 32-bit Executable',
'Win32 DLL' => 'Windows 32-bit Dynamic Link Library',
'Win64 EXE' => 'Windows 64-bit Executable',
'Win64 DLL' => 'Windows 64-bit Dynamic Link Library',
VNote => 'V-Note document',
);
# MIME types for applicable file types above
# (missing entries default to 'application/unknown', but note that other MIME
# types may be specified by some modules, eg. QuickTime.pm and RIFF.pm)
%mimeType = (
'3FR' => 'image/x-hasselblad-3fr',
'7Z' => 'application/x-7z-compressed',
AA => 'audio/audible',
AAC => 'audio/aac',
AAE => 'application/vnd.apple.photos',
AI => 'application/vnd.adobe.illustrator',
AIFF => 'audio/x-aiff',
ALIAS=> 'application/x-macos',
APE => 'audio/x-monkeys-audio',
APNG => 'image/apng',
ASF => 'video/x-ms-asf',
ARW => 'image/x-sony-arw',
BMP => 'image/bmp',
BPG => 'image/bpg',
BTF => 'image/x-tiff-big', #(NC) (ref http://www.asmail.be/msg0055371937.html)
BZ2 => 'application/bzip2',
C2PA => 'application/c2pa',
'Canon 1D RAW' => 'image/x-raw', # (uses .TIF file extension)
CHM => 'application/x-chm',
COS => 'application/octet-stream', #PH (NC)
CR2 => 'image/x-canon-cr2',
CR3 => 'image/x-canon-cr3',
CRM => 'video/x-canon-crm',
CRW => 'image/x-canon-crw',
CSV => 'text/csv',
CUR => 'image/x-cursor', #PH (NC)
CZI => 'image/x-zeiss-czi', #PH (NC)
DCP => 'application/octet-stream', #PH (NC)
DCR => 'image/x-kodak-dcr',
DCX => 'image/dcx',
DEX => 'application/octet-stream',
DFONT=> 'application/x-dfont',
DICOM=> 'application/dicom',
DIVX => 'video/divx',
DJVU => 'image/vnd.djvu',
DNG => 'image/x-adobe-dng',
DOC => 'application/msword',
DOCM => 'application/vnd.ms-word.document.macroEnabled.12',
DOCX => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
DOT => 'application/msword',
DOTM => 'application/vnd.ms-word.template.macroEnabledTemplate',
DOTX => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
DPX => 'image/x-dpx',
DR4 => 'application/octet-stream', #PH (NC)
DS2 => 'audio/x-ds2',
DSS => 'audio/x-dss',
DV => 'video/x-dv',
'DVR-MS' => 'video/x-ms-dvr',
DWF => 'model/vnd.dwf',
DWG => 'image/vnd.dwg',
DXF => 'application/dxf',
EIP => 'application/x-captureone', #(NC)
EPS => 'application/postscript',
ERF => 'image/x-epson-erf',
EXE => 'application/octet-stream',
EXR => 'image/x-exr',
EXV => 'image/x-exv',
FFF => 'image/x-hasselblad-fff',
FITS => 'image/fits',
FLA => 'application/vnd.adobe.fla',
FLAC => 'audio/flac',
FLIF => 'image/flif',
FLIR => 'image/x-flir-fff', #PH (NC)
FLV => 'video/x-flv',
Font => 'application/x-font-type1', # covers PFA, PFB and PFM (not sure about PFM)
FPF => 'image/x-flir-fpf', #PH (NC)
FPX => 'image/vnd.fpx',
GIF => 'image/gif',
GPR => 'image/x-gopro-gpr',
GZIP => 'application/x-gzip',
HDP => 'image/vnd.ms-photo',
HDR => 'image/vnd.radiance',
HTML => 'text/html',
ICC => 'application/vnd.iccprofile',
ICO => 'image/x-icon', #PH (NC)
ICS => 'text/calendar',
IDML => 'application/vnd.adobe.indesign-idml-package',
IIQ => 'image/x-raw',
IND => 'application/x-indesign',
INX => 'application/x-indesign-interchange', #PH (NC)
ISO => 'application/x-iso9660-image',
ITC => 'application/itunes',
J2C => 'image/x-j2c', #PH (NC)
JNG => 'image/jng',
JP2 => 'image/jp2',
JPEG => 'image/jpeg',
JPH => 'image/jph',
JPM => 'image/jpm',
JPS => 'image/x-jps',
JPX => 'image/jpx',
JSON => 'application/json',
JUMBF=> 'application/octet-stream', #PH (invented format)
JXL => 'image/jxl', #PH (NC)
JXR => 'image/jxr',
K25 => 'image/x-kodak-k25',
KDC => 'image/x-kodak-kdc',
KEY => 'application/x-iwork-keynote-sffkey',
LFP => 'image/x-lytro-lfp', #PH (NC)
LIF => 'image/x-lif',
LNK => 'application/octet-stream',
LRI => 'image/x-light-lri',
M2T => 'video/mpeg',
M2TS => 'video/m2ts',
MAX => 'application/x-3ds',
MEF => 'image/x-mamiya-mef',
MIE => 'application/x-mie',
MIFF => 'application/x-magick-image',
MKA => 'audio/x-matroska',
MKS => 'application/x-matroska',
MKV => 'video/x-matroska',
MNG => 'video/mng',
MOBI => 'application/x-mobipocket-ebook',
MOI => 'application/octet-stream', #PH (NC)
MOS => 'image/x-raw',
MOV => 'video/quicktime',
MP3 => 'audio/mpeg',
MP4 => 'video/mp4',
MPC => 'audio/x-musepack',
MPEG => 'video/mpeg',
MRC => 'image/x-mrc',
MRW => 'image/x-minolta-mrw',
MXF => 'application/mxf',
NEF => 'image/x-nikon-nef',
NKSC => 'application/x-nikon-nxstudio',
NRW => 'image/x-nikon-nrw',
NUMBERS => 'application/x-iwork-numbers-sffnumbers',
ODB => 'application/vnd.oasis.opendocument.database',
ODC => 'application/vnd.oasis.opendocument.chart',
ODF => 'application/vnd.oasis.opendocument.formula',
ODG => 'application/vnd.oasis.opendocument.graphics',
ODI => 'application/vnd.oasis.opendocument.image',
ODP => 'application/vnd.oasis.opendocument.presentation',
ODS => 'application/vnd.oasis.opendocument.spreadsheet',
ODT => 'application/vnd.oasis.opendocument.text',
OGG => 'audio/ogg',
OGV => 'video/ogg',
ONP => 'application/on1',
ORF => 'image/x-olympus-orf',
OTF => 'application/x-font-otf',
PAGES=> 'application/x-iwork-pages-sffpages',
PBM => 'image/x-portable-bitmap',
PCD => 'image/x-photo-cd',
PCX => 'image/pcx',
PDB => 'application/vnd.palm',
PDF => 'application/pdf',
PEF => 'image/x-pentax-pef',
PFA => 'application/x-font-type1', # (needed if handled by PostScript module)
PGF => 'image/pgf',
PGM => 'image/x-portable-graymap',
PHP => 'application/x-httpd-php',
PICT => 'image/pict',
PLIST=> 'application/xml', # (binary PLIST format is 'application/x-plist', recognized at run time)
PMP => 'image/x-sony-pmp', #PH (NC)
PNG => 'image/png',
POT => 'application/vnd.ms-powerpoint',
POTM => 'application/vnd.ms-powerpoint.template.macroEnabled.12',
POTX => 'application/vnd.openxmlformats-officedocument.presentationml.template',
PPAM => 'application/vnd.ms-powerpoint.addin.macroEnabled.12',
PPAX => 'application/vnd.openxmlformats-officedocument.presentationml.addin', # (NC, PH invented)
PPM => 'image/x-portable-pixmap',
PPS => 'application/vnd.ms-powerpoint',
PPSM => 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12',
PPSX => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
PPT => 'application/vnd.ms-powerpoint',
PPTM => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12',
PPTX => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
PS => 'application/postscript',
PSD => 'application/vnd.adobe.photoshop',
PSP => 'image/x-paintshoppro', #(NC)
QTIF => 'image/x-quicktime',
R3D => 'video/x-red-r3d', #PH (invented)
RA => 'audio/x-pn-realaudio',
RAF => 'image/x-fujifilm-raf',
RAM => 'audio/x-pn-realaudio',
RAR => 'application/x-rar-compressed',
RAW => 'image/x-raw',
RM => 'application/vnd.rn-realmedia',
RMVB => 'application/vnd.rn-realmedia-vbr',
RPM => 'audio/x-pn-realaudio-plugin',
RSRC => 'application/ResEdit',
RTF => 'text/rtf',
RV => 'video/vnd.rn-realvideo',
RW2 => 'image/x-panasonic-rw2',
RWL => 'image/x-leica-rwl',
RWZ => 'image/x-rawzor', #(duplicated in Rawzor.pm)
SEQ => 'image/x-flir-seq', #PH (NC)
SKETCH => 'application/sketch',
SR2 => 'image/x-sony-sr2',
SRF => 'image/x-sony-srf',
SRW => 'image/x-samsung-srw',
SVG => 'image/svg+xml',
SWF => 'application/x-shockwave-flash',
TAR => 'application/x-tar',
THMX => 'application/vnd.ms-officetheme',
TIFF => 'image/tiff',
Torrent => 'application/x-bittorrent',
TTC => 'application/x-font-ttf',
TTF => 'application/x-font-ttf',
TXT => 'text/plain',
VCard=> 'text/vcard',
VRD => 'application/octet-stream', #PH (NC)
VSD => 'application/x-visio',
WDP => 'image/vnd.ms-photo',
WEBM => 'video/webm',
WMA => 'audio/x-ms-wma',
WMF => 'application/x-wmf',
WMV => 'video/x-ms-wmv',
WPG => 'image/x-wpg',
WTV => 'video/x-ms-wtv',
X3F => 'image/x-sigma-x3f',
XCF => 'image/x-xcf',
XISF => 'image/x-xisf',
XLA => 'application/vnd.ms-excel',
XLAM => 'application/vnd.ms-excel.addin.macroEnabled.12',
XLS => 'application/vnd.ms-excel',
XLSB => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12',
XLSM => 'application/vnd.ms-excel.sheet.macroEnabled.12',
XLSX => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
XLT => 'application/vnd.ms-excel',
XLTM => 'application/vnd.ms-excel.template.macroEnabled.12',
XLTX => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
XML => 'application/xml',
XMP => 'application/rdf+xml',
ZIP => 'application/zip',
);
# module names for processing routines of each file type
# - undefined entries default to same module name as file type
# - module name '' defaults to Image::ExifTool
# - module name '0' indicates a recognized but unsupported file
my %moduleName = (
AA => 'Audible',
ALIAS=> 0,
AVC => 0,
BTF => 'BigTIFF',
BZ2 => 0,
CRW => 'CanonRaw',
CHM => 'EXE',
COS => 'CaptureOne',
CZI => 'ZISRAW',
DEX => 0,
DOCX => 'OOXML',
DCX => 0,
DIR => 0,
DR4 => 'CanonVRD',
DSS => 'Olympus',
DWF => 0,
DWG => 0,
DXF => 0,
EPS => 'PostScript',
EXIF => '',
EXR => 'OpenEXR',
EXV => '',
ICC => 'ICC_Profile',
IND => 'InDesign',
FLV => 'Flash',
FPF => 'FLIR',
FPX => 'FlashPix',
GZIP => 'ZIP',
HDR => 'Radiance',
JP2 => 'Jpeg2000',
JPEG => '',
JUMBF=> 'Jpeg2000',
JXL => 'Jpeg2000',
LFP => 'Lytro',
LRI => 0,
MOV => 'QuickTime',
MKV => 'Matroska',
MP3 => 'ID3',
MRW => 'MinoltaRaw',
OGG => 'Ogg',
ORF => 'Olympus',
PDB => 'Palm',
PCD => 'PhotoCD',
PFM2 => 'Other',
PHP => 0,
PMP => 'Sony',
PS => 'PostScript',
PSD => 'Photoshop',
QTIF => 'QuickTime',
R3D => 'Red',
RAF => 'FujiFilm',
RAR => 'ZIP',
RAW => 'KyoceraRaw',
RWZ => 'Rawzor',
SWF => 'Flash',
TAR => 0,
TIFF => '',
TXT => 'Text',
VRD => 'CanonVRD',
WMF => 0,
X3F => 'SigmaRaw',
XCF => 'GIMP',
);
$testLen = 1024; # number of bytes to read when testing for magic number
# quick "magic number" file test used to avoid loading module unnecessarily:
# - regular expression evaluated on first $testLen bytes of file
# - must match beginning at first byte in file
# - this test must not be more stringent than module logic
%magicNumber = (
AA => '.{4}\x57\x90\x75\x36',
AAC => '\xff[\xf0\xf1]',
AIFF => '(FORM....AIF[FC]|AT&TFORM)',
ALIAS=> "book\0\0\0\0mark\0\0\0\0",
APE => '(MAC |APETAGEX|ID3)',
ASF => '\x30\x26\xb2\x75\x8e\x66\xcf\x11\xa6\xd9\x00\xaa\x00\x62\xce\x6c',
AVC => '\+A\+V\+C\+',
Torrent => 'd\d+:\w+',
BMP => 'BM',
BPG => "BPG\xfb",
BTF => '(II\x2b\0|MM\0\x2b)',
BZ2 => 'BZh[1-9]\x31\x41\x59\x26\x53\x59',
CHM => 'ITSF.{20}\x10\xfd\x01\x7c\xaa\x7b\xd0\x11\x9e\x0c\0\xa0\xc9\x22\xe6\xec',
CRW => '(II|MM).{4}HEAP(CCDR|JPGM)',
CZI => 'ZISRAWFILE\0{6}',
DCX => '\xb1\x68\xde\x3a',
DEX => "dex\n035\0",
DICOM=> '(.{128}DICM|\0[\x02\x04\x06\x08]\0[\0-\x20]|[\x02\x04\x06\x08]\0[\0-\x20]\0)',
DOCX => 'PK\x03\x04',
DPX => '(SDPX|XPDS)',
DR4 => 'IIII[\x04|\x05]\0\x04\0',
DSS => '(\x02dss|\x03ds2)',
DV => '\x1f\x07\0[\x3f\xbf]', # (not tested if extension recognized)
DWF => '\(DWF V\d',
DWG => 'AC10\d{2}\0',
DXF => '\s*0\s+\0?\s*SECTION\s+2\s+HEADER',
EPS => '(%!PS|%!Ad|\xc5\xd0\xd3\xc6)',
EXE => '(MZ|\xca\xfe\xba\xbe|\xfe\xed\xfa[\xce\xcf]|[\xce\xcf]\xfa\xed\xfe|Joy!peff|\x7fELF|#!\s*/\S*bin/|!<arch>\x0a)',
EXIF => '(II\x2a\0|MM\0\x2a)',
EXR => '\x76\x2f\x31\x01',
EXV => '\xff\x01Exiv2',
FITS => 'SIMPLE = {20}T',
FLAC => '(fLaC|ID3)',
FLIF => 'FLIF[0-\x6f][0-2]',
FLIR => '[AF]FF\0',
FLV => 'FLV\x01',
Font => '((\0\x01\0\0|OTTO|true|typ1)[\0\x01]|ttcf\0[\x01\x02]\0\0|\0[\x01\x02]|' .
'(.{6})?%!(PS-(AdobeFont-|Bitstream )|FontType1-)|Start(Comp|Master)?FontMetrics|wOF[F2])',
FPF => 'FPF Public Image Format\0',
FPX => '\xd0\xcf\x11\xe0\xa1\xb1\x1a\xe1',
GIF => 'GIF8[79]a',
GZIP => '\x1f\x8b\x08',
HDR => '#\?(RADIANCE|RGBE)\x0a',
HTML => '(\xef\xbb\xbf)?\s*(?i)<(!DOCTYPE\s+HTML|HTML|\?xml)', # (case insensitive)
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}',
ICO => '\0\0[\x01\x02]\0[^0]\0', # (reasonably assume that the file contains less than 256 images)
IND => '\x06\x06\xed\xf5\xd8\x1d\x46\xe5\xbd\x31\xef\xe7\xfe\x74\xb7\x1d',
# ISO => signature is at byte 32768
ITC => '.{4}itch',
JP2 => '(\0\0\0\x0cjP( |\x1a\x1a)\x0d\x0a\x87\x0a|\xff\x4f\xff\x51\0)',
JPEG => '\xff\xd8\xff',
JSON => '(\xef\xbb\xbf)?\s*(\[\s*)?\{\s*"[^"]*"\s*:',
JUMBF=> '.{4}jumb\0.{3}jumd',
JXL => '(\xff\x0a|\0\0\0\x0cJXL \x0d\x0a......ftypjxl )',
LFP => '\x89LFP\x0d\x0a\x1a\x0a',
LIF => '\x70\0{3}.{4}\x2a.{4}<\0',
LNK => '.{4}\x01\x14\x02\0{5}\xc0\0{6}\x46',
LRI => 'LELR \0',
M2TS => '(....)?\x47',
MacOS=> '\0\x05\x16\x07\0.\0\0Mac OS X ',
MIE => '~[\x10\x18]\x04.0MIE',
MIFF => 'id=ImageMagick',
MKV => '\x1a\x45\xdf\xa3',
MOV => '.{4}(free|skip|wide|ftyp|pnot|PICT|pict|moov|mdat|junk|uuid)', # (duplicated in WriteQuickTime.pl !!)
# MP3 => difficult to rule out
MPC => '(MP\+|ID3)',
MOI => 'V6',
MPEG => '\0\0\x01[\xb0-\xbf]',
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',
MRW => '\0MR[MI]',
MXF => '\x06\x0e\x2b\x34\x02\x05\x01\x01\x0d\x01\x02', # (not tested if extension recognized)
OGG => '(OggS|ID3)',
ORF => '(II|MM)',
# PCD => signature is at byte 2048
PCX => '\x0a[\0-\x05]\x01[\x01\x02\x04\x08].{64}[\0-\x02]',
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)',
PDF => '\s*%PDF-\d+\.\d+',
PFM => 'P[Ff]\x0a\d+ \d+\x0a[-+0-9.]+\x0a',
PGF => 'PGF',
PHP => '<\?php\s',
PICT => '(.{10}|.{522})(\x11\x01|\x00\x11)',
PLIST=> '(bplist0|\s*<|\xfe\xff\x00)',
PMP => '.{8}\0{3}\x7c.{112}\xff\xd8\xff\xdb',
PNG => '(\x89P|\x8aM|\x8bJ)NG\r\n\x1a\n',
PPM => 'P[1-6]\s+',
PS => '(%!PS|%!Ad|\xc5\xd0\xd3\xc6)',
PSD => '8BPS\0[\x01\x02]',
PSP => 'Paint Shop Pro Image File\x0a\x1a\0{5}',
QTIF => '.{4}(idsc|idat|iicc)',
R3D => '\0\0..RED(1|2)',
RAF => 'FUJIFILM',
RAR => 'Rar!\x1a\x07\x01?\0',
RAW => '(.{25}ARECOYK|II|MM)',
Real => '(\.RMF|\.ra\xfd|pnm://|rtsp://|http://)',
RIFF => '(RIFF|LA0[234]|OFR |LPAC|wvpk|RF64)', # RIFF plus other variants
RSRC => '(....)?\0\0\x01\0',
RTF => '[\n\r]*\\{[\n\r]*\\\\rtf',