In which .pm file is the FileType detected?

Started by Archive, May 12, 2010, 08:54:44 AM

Previous topic - Next topic

Archive

[Originally posted by jamesgreen on 2010-01-30 12:46:30.843825-08]

Hi,

I'm not 100% sure this is the right place to ask but I can't seem to find where the file type of an input file is detected... I would like to know this so I can change things like  'FLAC' into 'Free Lossless Audio Codec' etc. to display as FileType...

Thanks in advance.

Archive

[Originally posted by exiftool on 2010-01-30 13:21:30.401516-08]

There is a description that can be accessed via the API
GetFileType() function.  It uses the following lookup table
(from ExifTool.pm):

Code:
my %fileTypeLookup = (
   '3FR' => ['TIFF', 'Hasselblad RAW format'],
   '3G2' => ['MOV',  '3rd Gen. Partnership Project 2 audio/video'],
   '3GP' => ['MOV',  '3rd Gen. Partnership Project audio/video'],
    ACR  => ['DICM', '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'],
    APE  => ['APE',  "Monkey's Audio format"],
    ARW  => ['TIFF', 'Sony Alpha RAW format'],
    ASF  => ['ASF',  'Microsoft Advanced Systems Format'],
    AVI  => ['RIFF', 'Audio Video Interleaved'],
    BMP  => ['BMP',  'Windows BitMaP'],
    BTF  => ['BTF',  'Big Tagged Image File Format'], #(unofficial)
    CIFF => ['CRW',  'Camera Image File Format'],
    COS  => ['COS',  'Capture One Settings'],
    CR2  => ['TIFF', 'Canon RAW 2 format'],
    CRW  => ['CRW',  'Canon RAW format'],
    CS1  => ['PSD',  'Sinar CaptureShop 1-Shot RAW'],
    DC3  =>  'DICM',
    DCM  =>  'DICM',
    DCP  => ['TIFF', 'DNG Camera Profile'],
    DCR  => ['TIFF', 'Kodak Digital Camera RAW'],
    DFONT=> ['Font', 'Macintosh Data fork Font'],
    DIB  => ['BMP',  'Device Independent Bitmap'],
    DIC  =>  'DICM',
    DICM => ['DICM', 'DICOM image file'],
    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'],
    DVB  => ['MOV',  'Digital Video Broadcasting'],
    DYLIB=> ['EXE',  'Mach-O Dynamic Link Library'],
    EIP  => ['ZIP',  'Capture One Enhanced Image Package'],
    EPS  => ['EPS',  'Encapsulated PostScript Format'],
    EPSF =>  'EPS',
    ERF  => ['TIFF', 'Epson Raw Format'],
    EXE  => ['EXE',  'Windows executable file'],
    EXIF => ['EXIF', 'Exchangable Image File 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'],
    FLAC => ['FLAC', 'Free Lossless Audio Codec'],
    FLA  => ['FPX',  'Macromedia/Adobe Flash project'],
    FLV  => ['FLV',  'Flash Video'],
    FPX  => ['FPX',  'FlashPix'],
    GIF  => ['GIF',  'Compuserve Graphics Interchange Format'],
    GZ   =>  'GZIP',
    GZIP => ['GZIP', 'GNU ZIP compressed archive'],
    HDP  => ['TIFF', 'Windows HD Photo'],
    HTM  =>  'HTML',
    HTML => ['HTML', 'HyperText Markup Language'],
    ICC  => ['ICC',  'International Color Consortium'],
    ICM  =>  'ICC',
    IIQ  => ['TIFF', 'Phase One Intelligent Image Quality RAW'],
    IND  => ['IND',  'Adobe InDesign'],
    INDD => ['IND',  'Adobe InDesign Document'],
    INDT => ['IND',  'Adobe InDesign Template'],
    ITC  => ['ITC',  'iTunes Cover Flow'],
    JNG  => ['PNG',  'JPG Network Graphics'],
    JP2  => ['JP2',  'JPEG 2000 file'],
    JPEG =>  'JPG',
    JPG  => ['JPEG', 'Joint Photographic Experts Group'],
    JPM  => ['JP2',  'JPEG 2000 compound image'],
    JPX  => ['JP2',  'JPEG 2000 with extensions'],
    K25  => ['TIFF', 'Kodak DC25 RAW'],
    KDC  => ['TIFF', 'Kodak Digital Camera RAW'],
    KEY  => ['ZIP',  'Apple Keynote presentation'],
    KTH  => ['ZIP',  'Apple Keynote Theme'],
    LNK  => ['LNK',  'Windows shortcut'],
    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'],
    MEF  => ['TIFF', 'Mamiya (RAW) Electronic Format'],
    MIE  => ['MIE',  'Meta Information Encapsulation format'],
    MIF  =>  'MIFF',
    MIFF => ['MIFF', 'Magick Image File Format'],
    MNG  => ['PNG',  'Multiple-image Network Graphics'],
  # MODD => ['PLIST','Sony Picture Motion Metadata'],
    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'],
    MRW  => ['MRW',  'Minolta RAW format'],
    MTS  => ['M2TS', 'MPEG-2 Transport Stream'],
    NEF  => ['TIFF', 'Nikon (RAW) Electronic Format'],
    NMBTEMPLATE => ['ZIP','Apple Numbers Template'],
    NRW  => ['TIFF', 'Nikon RAW (2)'],
    NUMBERS => ['ZIP','Apple Numbers spreadsheet'],
    OGG  => ['OGG',  'Ogg Vorbis audio file'],
    ORF  => ['ORF',  'Olympus RAW format'],
    OTF  => ['Font', 'Open Type Font'],
    PAGES => ['ZIP', 'Apple Pages document'],
    PBM  => ['PPM',  'Portable BitMap'],
    PCT  =>  'PICT',
    PDF  => ['PDF',  'Adobe Portable Document Format'],
    PEF  => ['TIFF', 'Pentax (RAW) Electronic Format'],
    PFA  => ['Font', 'PostScript Font ASCII'],
    PFB  => ['Font', 'PostScript Font Binary'],
    PFM  => ['Font', 'Printer Font Metrics'],
    PGM  => ['PPM',  'Portable Gray Map'],
    PICT => ['PICT', 'Apple PICTure'],
  # PLIST=> ['PLIST','Apple Property List'],
    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'],
    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'],
    PS   => ['PS',   'PostScript'],
    PSD  => ['PSD',  'PhotoShop Drawing'],
    PSP  => ['PSP',  'Paint Shop Pro'],
    PSPIMAGE => 'PSP',
    QIF  =>  'QTIF',
    QT   => ['MOV',  'QuickTime movie'],
    QTI  =>  'QTIF',
    QTIF => ['QTIF', 'QuickTime Image File'],
    RA   => ['Real', 'Real Audio'],
    RAF  => ['RAF',  'FujiFilm RAW Format'],
    RAM  => ['Real', 'Real Audio Metafile'],
    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'],
    RV   => ['Real', 'Real Video'],
    RW2  => ['TIFF', 'Panasonic RAW 2'],
    RWL  => ['TIFF', 'Leica RAW'],
    RWZ  => ['RWZ',  'Rawzor compressed image'],
    SO   => ['EXE',  'Shared Object file'],
    SR2  => ['TIFF', 'Sony RAW Format 2'],
    SRF  => ['TIFF', 'Sony RAW Format'],
    SVG  => ['XMP',  'Scalable Vector Graphics'],
    SWF  => ['SWF',  'Shockwave Flash'],
    THM  => ['JPEG', 'Canon Thumbnail'],
    THMX => [['ZIP','FPX'], 'Office Open XML Theme'],
    TIF  =>  'TIFF',
    TIFF => ['TIFF', 'Tagged Image File Format'],
    TTC  => ['Font', 'Trye Type Font Collection'],
    TTF  => ['Font', 'True Type Font'],
    VOB  => ['MPEG', 'Video Object'],
    VRD  => ['VRD',  'Canon VRD Recipe Data'],
    WAV  => ['RIFF', 'WAVeform (Windows digital audio)'],
    WDP  => ['TIFF', 'Windows Media Photo'],
    WMA  => ['ASF',  'Windows Media Audio'],
    WMV  => ['ASF',  'Windows Media Video'],
    X3F  => ['X3F',  'Sigma RAW format'],
    XHTML=> ['HTML', 'Extensible HyperText Markup Language'],
    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 data file'],
    ZIP  => ['ZIP',  'ZIP archive'],
);

- Phil

Archive

[Originally posted by jamesgreen on 2010-01-30 13:37:12.757034-08]

Thanks for your quick reply.. I already found that in the ExifTool.pm file but I was hoping for a solution from the command line. I can't use the API from the command line can I?

I know I need
Code:
my $desc = Image::ExifTool::GetFileType($filename, 1);
If I'd use the API but I don't know how to use it from AppleScript, I only have the option to run command line applications from it. I know OS X can execute perl script from the command line but I don't know if that's what I need for the API. If I only need to run that line (+ setting filename) in a perl script then I can test it.

By the way, ExifTool is awesome!

Archive

[Originally posted by exiftool on 2010-01-31 12:38:45.216153-08]

You can do this by adding a user-defined tag (called "MyType") with this
config file:

Code:
%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        MyType => {
            Require => 'FileType',
            ValueConv => 'GetFileType($val,1)',
        },
    },
);
1;  #end

See the https://exiftool.org/config.html" target="_blank">config
file documentation for details about how to use a
configuration file.

- Phil

Archive

[Originally posted by exiftool on 2010-02-01 06:35:59.119017-08]

I realized that this isn't quite right since I am passing the
file type to GetFileType(), but it expects the file extension.
For most files, the file type and extension are the same,
but not for all.  In the next release I will change
GetFileType() to be able to handle this properly for
all file types.

- Phil

Archive

[Originally posted by exiftool on 2010-02-01 06:56:14.815902-08]

I hit a bit of a snag implementing this.  Some file types are
generated dynamically, so I can't generate a description
for all file types.  I will do what I can to improve GetFileType(),
but to handle the remaining cases the user-defined tag
should be changed as follows:

Code:
%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        MyType => {
            Require => 'FileType',
            ValueConv => 'GetFileType($val,1) || $val',
        },
    },
);
1;  #end

which will return the original file type if a better
description doesn't exist.

- Phil

Archive

[Originally posted by jamesgreen on 2010-02-01 07:34:10.242239-08]

It works. Thank you.