Branch: Tag:

2003-04-14

2003-04-14 13:39:19 by Martin Nilsson <mani@lysator.liu.se>

Save 17K in empty arrays.

Rev: lib/modules/Standards.pmod/EXIF.pmod:1.18

3:   //! This module implements EXIF (Exchangeable image file format for   //! Digital Still Cameras) 2.2 parsing.    - // $Id: EXIF.pmod,v 1.17 2003/04/14 13:06:48 nilsson Exp $ + // $Id: EXIF.pmod,v 1.18 2003/04/14 13:39:19 nilsson Exp $   // Johan Schön <js@roxen.com>, July 2001.   // Based on Exiftool by Robert F. Tobler <rft@cg.tuwien.ac.at>.   //
258:    0x0002: ({"MN_Multi1", "CUSTOM", canon_multi1 }),    0x0004: ({"MN_Multi3", "CUSTOM", canon_multi3 }),    0x0005: ({"MN_Multi4", "CUSTOM", canon_multi4 }), -  0x0006: ({"MN_ImageType", 0, ([]) }), -  0x0007: ({"MN_FirmwareVersion", 0, ([]) }), -  0x0008: ({"MN_ImageNumber", 0, ([]) }), -  0x0009: ({"MN_OwnerName", 0, ([]) }), -  0x000C: ({"MN_CameraSerialNumber", 0, ([]) }), +  0x0006: ({"MN_ImageType", }), +  0x0007: ({"MN_FirmwareVersion", }), +  0x0008: ({"MN_ImageNumber", }), +  0x0009: ({"MN_OwnerName", }), +  0x000C: ({"MN_CameraSerialNumber", }),    // 0x000F: ({"MN_CustomFunctions", "CUSTOM", canon_custom }),   ]);   
276:      // NIKON 990, D1 (more?)   static mapping NIKON_990_MAKERNOTE = ([ -  0x0001: ({"MN_0x0001", 0, ([]) }), +  0x0001: ({"MN_0x0001", }),    0x0002: ({"MN_ISOSetting", "CUSTOM", nikon_iso }), -  0x0003: ({"MN_ColorMode", 0, ([]) }), -  0x0004: ({"MN_Quality", 0, ([]) }), -  0x0005: ({"MN_Whitebalance", 0, ([]) }), -  0x0006: ({"MN_ImageSharpening", 0, ([]) }), -  0x0007: ({"MN_FocusMode", 0, ([]) }), -  0x0008: ({"MN_FlashSetting", 0, ([]) }), -  0x000A: ({"MN_0x000A", 0, ([]) }), -  0x000F: ({"MN_ISOSelection", 0, ([]) }), -  0x0080: ({"MN_ImageAdjustment", 0, ([]) }), -  0x0082: ({"MN_AuxiliaryLens", 0, ([]) }), -  0x0085: ({"MN_ManualFocusDistance", "FLOAT", ([]) }), -  0x0086: ({"MN_DigitalZoomFactor", "FLOAT", ([]) }), +  0x0003: ({"MN_ColorMode", }), +  0x0004: ({"MN_Quality", }), +  0x0005: ({"MN_Whitebalance", }), +  0x0006: ({"MN_ImageSharpening", }), +  0x0007: ({"MN_FocusMode", }), +  0x0008: ({"MN_FlashSetting", }), +  0x000A: ({"MN_0x000A", }), +  0x000F: ({"MN_ISOSelection", }), +  0x0080: ({"MN_ImageAdjustment", }), +  0x0082: ({"MN_AuxiliaryLens", }), +  0x0085: ({"MN_ManualFocusDistance", "FLOAT" }), +  0x0086: ({"MN_DigitalZoomFactor", "FLOAT" }),    0x0088: ({"MN_AFFocusPosition", "MAP",    ([ "\00\00\00\00": "Center",    "\00\01\00\00": "Top",
297:    "\00\03\00\00": "Left",    "\00\04\00\00": "Right",    ]) }), -  0x0010: ({"MN_DataDump", 0, ([]) }), +  0x0010: ({"MN_DataDump", }),   ]);      static mapping sanyo_specialmode(array(int) data) {
334:   }      static mapping SANYO_MAKERNOTE = ([ -  0x00ff: ({"MN_StartOffset", 0, ([]) }), -  0x0100: ({"MN_JPEGThumbnail", 0, ([]) }), +  0x00ff: ({"MN_StartOffset", }), +  0x0100: ({"MN_JPEGThumbnail", }),    0x0200: ({"MN_SpecialMode", "CUSTOM", sanyo_specialmode }),    0x0201: ({"MN_JPEGQuality", "CUTSOM", sanyo_jpegquality }),    0x0202: ({"MN_Macro", "MAP",
343:    1:"Macro",    2:"View",    3:"Manual" ]) }), -  0x0204: ({"MN_DigitalZoom", 0, ([]) }), -  0x0207: ({"MN_SoftwareRelease", 0, ([]) }), -  0x0208: ({"MN_PictInfo", 0, ([]) }), -  0x0209: ({"MN_CameraID", 0, ([]) }), +  0x0204: ({"MN_DigitalZoom", }), +  0x0207: ({"MN_SoftwareRelease", }), +  0x0208: ({"MN_PictInfo", }), +  0x0209: ({"MN_CameraID", }),    0x020e: ({"MN_SequentialShotMethod", "MAP",    ([ 0:"None",    1:"Standard",
372:    3:"Night",    4:"User 1",    5:"User 2" ]) }), -  0x0223: ({"MN_ManualFocalDistance", 0, ([]) }), +  0x0223: ({"MN_ManualFocalDistance", }),    0x0224: ({"MN_SequentialShotInterval", "MAP",    ([ 0:"5 frames/s",    1:"10 frames/s",
383:    1:"Force",    2:"Disabled",    3:"Red eye" ]) }), -  0x0e00: ({"MN_PrintIMFlags", 0, ([]) }), -  0x0f00: ({"MN_DataDump", 0, ([]) }), +  0x0e00: ({"MN_PrintIMFlags", }), +  0x0f00: ({"MN_DataDump", }),   ]);      static mapping OLYMPUS_MAKERNOTE = ([
395:    2:"SHQ" ]) }),    0x0202: ({"MN_Macro", "MAP", ([ 0:"No", 1:"Yes" ]) }),    0x0204: ({"MN_DigitalZoom", "MAP", ([ 0:"1x", 1:"2x" ]) }), -  0x0207: ({"MN_SoftwareRelease", 0, ([]) }), -  0x0208: ({"MN_PictInfo", 0, ([]) }), -  0x0209: ({"MN_CameraID", 0, ([]) }), -  0x0f00: ({"MN_DataDump", 0, ([]) }), +  0x0207: ({"MN_SoftwareRelease", }), +  0x0208: ({"MN_PictInfo", }), +  0x0209: ({"MN_CameraID", }), +  0x0f00: ({"MN_DataDump", }),   ]);      // Nikon E700/E800/E900/E900S/E910/E950   static mapping NIKON_MAKERNOTE = ([ -  0x0002: ({"MN_0x0002", 0, ([]), }), +  0x0002: ({"MN_0x0002", }),    0x0003: ({"MN_Quality", "MAP",    ([ 1:"VGA Basic",    2:"VGA Normal",
431:    4:"Flourescense",    5:"Cloudy",    6:"SpeedLight" ]) }), -  0x0008: ({"MN_Focus", 0, ([]) }), -  0x0009: ({"MN_0x0009", 0, ([]) }), -  0x000a: ({"MN_DigitalZoom", 0, ([]) }), +  0x0008: ({"MN_Focus", }), +  0x0009: ({"MN_0x0009", }), +  0x000a: ({"MN_DigitalZoom", }),    0x000b: ({"MN_Converter", "MAP", ([ 1:"Fisheye converter" ]) }), -  0x0f00: ({"MN_0x0f00", 0, ([]) }), +  0x0f00: ({"MN_0x0f00", }),   ]);      static mapping CASIO_MAKERNOTE = ([
467:    ([ 11:"Weak",    13:"Normal",    15:"Strong" ]) }), -  0x0006: ({"MN_ObjectDistance", 0, ([]) }), +  0x0006: ({"MN_ObjectDistance", }),    0x0007: ({"MN_WhiteBalance", "MAP",    ([ 1:"Auto",    2:"Tungsten",
500:   ]);      static mapping FUJIFILM_MAKERNOTE = ([ -  0x0000: ({"MN_Version", 0, ([]) }), -  0x1000: ({"MN_Quality", 0, ([]) }), +  0x0000: ({"MN_Version", }), +  0x1000: ({"MN_Quality", }),    0x1001: ({"MN_Sharpness", "MAP",    ([ 1:"Soft",    2:"Soft",
530:    1:"On",    2:"Off",    3:"Red-eye reduction" ]) }), -  0x1011: ({"MN_FlashStrength", 0, ([]) }), +  0x1011: ({"MN_FlashStrength", }),    0x1020: ({"MN_Macro", "MAP", ([ 0:"Off", 1:"On" ]) }),    0x1021: ({"MN_FocusMode", "MAP", ([ 0:"Auto focus", 1:"Manual focus" ]) }),    0x1030: ({"MN_SlowSync", "MAP", ([ 0:"Off", 1:"On" ]) }),
550:   ]);      static mapping TAG_INFO = ([ -  0x0001: ({"InteroperabilityIndex", 0, ([]) }), -  0x0002: ({"InteroperabilityVersion", 0, ([]) }), -  0x00fe: ({"NewSubFileType", 0, ([]) }), -  0x0100: ({"ImageWidth", 0, ([]) }), -  0x0101: ({"ImageLength", 0, ([]) }), -  0x0102: ({"BitsPerSample", 0, ([]) }), -  0x0103: ({"Compression", 0, ([]) }), -  0x0106: ({"PhotometricInterpretation", 0, ([]) }), -  0x010a: ({"FillOrder", 0, ([]) }), -  0x010d: ({"DocumentName", 0, ([]) }), -  0x010e: ({"ImageDescription", 0, ([]) }), -  0x010f: ({"Make", 0, ([]) }), -  0x0110: ({"Model", 0, ([]) }), -  0x0111: ({"StripOffsets", 0, ([]) }), -  0x0112: ({"Orientation", 0, ([]) }), -  0x0115: ({"SamplesPerPixel", 0, ([]) }), -  0x0116: ({"RowsPerStrip", 0, ([]) }), -  0x0117: ({"StripByteCounts", 0, ([]) }), -  0x011a: ({"XResolution", 0, ([]) }), -  0x011b: ({"YResolution", 0, ([]) }), -  0x011c: ({"PlanarConfiguration", 0, ([]) }), +  0x0001: ({"InteroperabilityIndex", }), +  0x0002: ({"InteroperabilityVersion", }), +  0x00fe: ({"NewSubFileType", }), +  0x0100: ({"ImageWidth", }), +  0x0101: ({"ImageLength", }), +  0x0102: ({"BitsPerSample", }), +  0x0103: ({"Compression", }), +  0x0106: ({"PhotometricInterpretation", }), +  0x010a: ({"FillOrder", }), +  0x010d: ({"DocumentName", }), +  0x010e: ({"ImageDescription", }), +  0x010f: ({"Make", }), +  0x0110: ({"Model", }), +  0x0111: ({"StripOffsets", }), +  0x0112: ({"Orientation", }), +  0x0115: ({"SamplesPerPixel", }), +  0x0116: ({"RowsPerStrip", }), +  0x0117: ({"StripByteCounts", }), +  0x011a: ({"XResolution", }), +  0x011b: ({"YResolution", }), +  0x011c: ({"PlanarConfiguration", }),    0x0128: ({"ResolutionUnit", "MAP",    ([ 1: "Not Absolute",    2: "Inch",    3: "Centimeter", ]) }), -  0x012d: ({"TransferFunction", 0, ([]) }), -  0x0131: ({"Software", 0, ([]) }), -  0x0132: ({"DateTime", 0, ([]) }), -  0x013b: ({"Artist", 0, ([]) }), -  0x013e: ({"WhitePoint", 0, ([]) }), -  0x013f: ({"PrimaryChromaticities", 0, ([]) }), -  0x0142: ({"TileWidth", 0, ([]) }), -  0x0143: ({"TileLength", 0, ([]) }), -  0x0144: ({"TileOffsets", 0, ([]) }), -  0x0145: ({"TileByteCounts", 0, ([]) }), -  0x014a: ({"SubIFDs", 0, ([]) }), -  0x0156: ({"TransferRange", 0, ([]) }), -  0x015b: ({"JPEGTables", 0, ([]) }), -  0x0200: ({"JPEGProc", 0, ([]) }), -  0x0201: ({"JPEGInterchangeFormat", 0, ([]) }), // from EXIFread -  0x0202: ({"JPEGInterchangeFormatLength", 0, ([]) }), // from EXIFread -  0x0211: ({"YCbCrCoefficients", 0, ([]) }), -  0x0212: ({"YCbCrSubSampling", 0, ([]) }), -  0x0213: ({"YCbCrPositioning", 0, ([]) }), -  0x0214: ({"ReferenceBlackWhite", 0, ([]) }), -  0x1000: ({"RelatedImageFileFormat", 0, ([]) }), -  0x1001: ({"RelatedImageWidth", 0, ([]) }), -  0x1002: ({"RelatedImageLength", 0, ([]) }), -  0x828d: ({"CFARepeatPatternDim", 0, ([]) }), -  0x828f: ({"BatteryLevel", 0, ([]) }), -  0x8298: ({"Copyright", 0, ([]) }), -  0x829a: ({"ExposureTime", "EXPOSURE", ([]) }), -  0x829d: ({"FNumber", "FLOAT", ([]) }), -  0x83bb: ({"IPTC_NAA", 0, ([]) }), -  0x8769: ({"ExifOffset", 0, ([]) }), -  0x8773: ({"InterColorProfile", 0, ([]) }), +  0x012d: ({"TransferFunction", }), +  0x0131: ({"Software", }), +  0x0132: ({"DateTime", }), +  0x013b: ({"Artist", }), +  0x013e: ({"WhitePoint", }), +  0x013f: ({"PrimaryChromaticities", }), +  0x0142: ({"TileWidth", }), +  0x0143: ({"TileLength", }), +  0x0144: ({"TileOffsets", }), +  0x0145: ({"TileByteCounts", }), +  0x014a: ({"SubIFDs", }), +  0x0156: ({"TransferRange", }), +  0x015b: ({"JPEGTables", }), +  0x0200: ({"JPEGProc", }), +  0x0201: ({"JPEGInterchangeFormat", }), // from EXIFread +  0x0202: ({"JPEGInterchangeFormatLength", }), // from EXIFread +  0x0211: ({"YCbCrCoefficients", }), +  0x0212: ({"YCbCrSubSampling", }), +  0x0213: ({"YCbCrPositioning", }), +  0x0214: ({"ReferenceBlackWhite", }), +  0x1000: ({"RelatedImageFileFormat", }), +  0x1001: ({"RelatedImageWidth", }), +  0x1002: ({"RelatedImageLength", }), +  0x828d: ({"CFARepeatPatternDim", }), +  0x828f: ({"BatteryLevel", }), +  0x8298: ({"Copyright", }), +  0x829a: ({"ExposureTime", "EXPOSURE" }), +  0x829d: ({"FNumber", "FLOAT" }), +  0x83bb: ({"IPTC_NAA", }), +  0x8769: ({"ExifOffset", }), +  0x8773: ({"InterColorProfile", }),    0x8822: ({"ExposureProgram", "MAP",    ([ 0: "Unidentified",    1: "Manual",
616:    6: "Program Action",    7: "Portrait Mode",    8: "Landscape Mode", ]) }), -  0x8824: ({"SpectralSensitivity", 0, ([]) }), -  0x8825: ({"GPSInfo", 0, ([]) }), -  0x8827: ({"ISOSpeedRating", 0, ([]) }), -  0x8828: ({"OECF", 0, ([]) }), -  0x8829: ({"Interlace", 0, ([]) }), -  0x882a: ({"TimeZoneOffset", 0, ([]) }), -  0x882b: ({"SelfTimerMode", 0, ([]) }), -  0x9000: ({"ExifVersion", 0, ([]) }), // from EXIFread -  0x9003: ({"DateTimeOriginal", 0, ([]) }), -  0x9004: ({"DateTimeDigitized", 0, ([]) }), // from EXIFread +  0x8824: ({"SpectralSensitivity", }), +  0x8825: ({"GPSInfo", }), +  0x8827: ({"ISOSpeedRating", }), +  0x8828: ({"OECF", }), +  0x8829: ({"Interlace", }), +  0x882a: ({"TimeZoneOffset", }), +  0x882b: ({"SelfTimerMode", }), +  0x9000: ({"ExifVersion", }), // from EXIFread +  0x9003: ({"DateTimeOriginal", }), +  0x9004: ({"DateTimeDigitized", }), // from EXIFread    0x9101: ({"ComponentsConfiguration", "CUSTOM", components_config }), -  0x9102: ({"CompressedBitsPerPixel", 0, ([]) }), -  0x9201: ({"ShutterSpeedValue", 0, ([]) }), -  0x9202: ({"ApertureValue", 0, ([]) }), -  0x9203: ({"BrightnessValue", 0, ([]) }), -  0x9204: ({"ExposureBiasValue", "BIAS", ([]) }), -  0x9205: ({"MaxApertureValue", "FLOAT", ([]) }), -  0x9206: ({"SubjectDistance", 0, ([]) }), +  0x9102: ({"CompressedBitsPerPixel", }), +  0x9201: ({"ShutterSpeedValue", }), +  0x9202: ({"ApertureValue", }), +  0x9203: ({"BrightnessValue", }), +  0x9204: ({"ExposureBiasValue", "BIAS" }), +  0x9205: ({"MaxApertureValue", "FLOAT" }), +  0x9206: ({"SubjectDistance", }),    0x9207: ({"MeteringMode", "MAP",    ([ 0: "Unidentified",    1: "Average",
688:    89: "red-eye auto fired",    93: "red-eye auto fired (?)",    95: "red-eye auto fired (!)", ]) }), -  0x920a: ({"FocalLength", "FLOAT", ([]) }), -  0x920b: ({"FlashEnergy", 0, ([]) }), -  0x920c: ({"SpatialFrequencyResponse", 0, ([]) }), -  0x920d: ({"Noise", 0, ([]) }), -  0x920e: ({"FocalPlaneXResolution", 0, ([]) }), -  0x920f: ({"FocalPlaneYResolution", 0, ([]) }), -  0x9210: ({"FocalPlaneResolutionUnit", 0, ([]) }), -  0x9211: ({"ImageNumber", 0, ([]) }), -  0x9212: ({"SecurityClassification", 0, ([]) }), -  0x9213: ({"ImageHistory", 0, ([]) }), -  0x9214: ({"SubjectArea", 0, ([]) }), -  0x9215: ({"ExposureIndex", 0, ([]) }), -  0x9216: ({"TIFF_EPStandardID", 0, ([]) }), -  0x9217: ({"SensingMethod", 0, ([]) }), +  0x920a: ({"FocalLength", "FLOAT" }), +  0x920b: ({"FlashEnergy", }), +  0x920c: ({"SpatialFrequencyResponse", }), +  0x920d: ({"Noise", }), +  0x920e: ({"FocalPlaneXResolution", }), +  0x920f: ({"FocalPlaneYResolution", }), +  0x9210: ({"FocalPlaneResolutionUnit", }), +  0x9211: ({"ImageNumber", }), +  0x9212: ({"SecurityClassification", }), +  0x9213: ({"ImageHistory", }), +  0x9214: ({"SubjectArea", }), +  0x9215: ({"ExposureIndex", }), +  0x9216: ({"TIFF_EPStandardID", }), +  0x9217: ({"SensingMethod", }),    0x927c: ({"MakerNote", "MAKE_MODEL",    ([    "NIKON_E990": ({"TAGS", NIKON_990_MAKERNOTE}),
712:    "SANYO DIGITAL CAMERA": ({"TAGS", SANYO_MAKERNOTE}),    "CASIO": ({"TAGS", CASIO_MAKERNOTE}),    "": ({ 0, ([]) }) ]) }), -  0x9286: ({"UserComment", 0, ([]) }), -  0x9290: ({"SubSecTime", 0, ([]) }), -  0x9291: ({"SubSecTimeOriginal", 0, ([]) }), -  0x9292: ({"SubSecTimeDigitized", 0, ([]) }), -  0xa000: ({"FlashPixVersion", 0, ([]) }), -  0xa001: ({"ColorSpace", 0, ([]) }), -  0xa002: ({"PixelXDimension", 0, ([]) }), -  0xa003: ({"PixelYDimension", 0, ([]) }), -  0xa004: ({"RelatedSoundFile", 0, ([]) }), -  0xa005: ({"ExifInterabilityOffset", 0, ([]) }), -  0xa20b: ({"FlashEnergy", 0, ([]) }), -  0xa20c: ({"SpatialFrequencyResponse", 0, ([]) }), -  0xa20e: ({"FocalPlaneXResolution", 0, ([]) }), -  0xa20f: ({"FocalPlaneYResolution", 0, ([]) }), -  0xa210: ({"FocalPlaneResolutionUnit", 0, ([]) }), -  0xa214: ({"SubjectLocation", 0, ([]) }), -  0xa215: ({"ExposureIndex", 0, ([]) }), -  0xa217: ({"SensingMethod", 0, ([]) }), -  0xa300: ({"FileSource", 0, ([]) }), -  0xa301: ({"SceneType", 0, ([]) }), -  0xa302: ({"CFAPattern", 0, ([]) }), -  0xa401: ({"CustomRendered", 0, ([]) }), +  0x9286: ({"UserComment", }), +  0x9290: ({"SubSecTime", }), +  0x9291: ({"SubSecTimeOriginal", }), +  0x9292: ({"SubSecTimeDigitized", }), +  0xa000: ({"FlashPixVersion", }), +  0xa001: ({"ColorSpace", }), +  0xa002: ({"PixelXDimension", }), +  0xa003: ({"PixelYDimension", }), +  0xa004: ({"RelatedSoundFile", }), +  0xa005: ({"ExifInterabilityOffset", }), +  0xa20b: ({"FlashEnergy", }), +  0xa20c: ({"SpatialFrequencyResponse", }), +  0xa20e: ({"FocalPlaneXResolution", }), +  0xa20f: ({"FocalPlaneYResolution", }), +  0xa210: ({"FocalPlaneResolutionUnit", }), +  0xa214: ({"SubjectLocation", }), +  0xa215: ({"ExposureIndex", }), +  0xa217: ({"SensingMethod", }), +  0xa300: ({"FileSource", }), +  0xa301: ({"SceneType", }), +  0xa302: ({"CFAPattern", }), +  0xa401: ({"CustomRendered", }),    0xa402: ({"ExposureMode", "MAP",    ([ 0: "Auto exposure",    1: "Manual exposure",
741:    0xa403: ({"WhiteBalance", "MAP",    ([ 0: "Auto",    1: "Manual", ]) }), -  0xa404: ({"DigitalZoomRatio", "FLOAT", ([]) }), -  0xa405: ({"FocalLengthIn35mmFilm", 0, ([]) }), +  0xa404: ({"DigitalZoomRatio", "FLOAT" }), +  0xa405: ({"FocalLengthIn35mmFilm", }),    0xa406: ({"SceneCaptureType", "MAP",    ([ 0: "Standard",    1: "Landscape",
766:    ([ 0: "Normal",    1: "Soft",    2: "Hard", ]) }), -  0xa40b: ({"DeviceSettingDescription", 0, ([]) }), +  0xa40b: ({"DeviceSettingDescription", }),    0xa40c: ({"SubjectDistanceRange", "MAP",    ([ 0: "Unknown",    1: "Macro",    2: "Close view",    3: "Distant view", ]) }), -  0xa420: ({"ImageUniqueID", "ASCII", ([]) }), +  0xa420: ({"ImageUniqueID", "ASCII" }),   ]);      static mapping TAG_TYPE_INFO =
824:    int tag_count=long_value(file->read(4), order);    string make,model;    -  [string tag_name, string tag_format, mapping|function tag_map]= -  exif_info[tag_id] || ({ sprintf("%s0x%x", (exif_info->prefix||"Tag"), -  tag_id), 0, ([]) }); +  string tag_name, tag_format; +  mapping|function tag_map; +  array temp = exif_info[tag_id]; +  if(!temp || !sizeof(temp)) { +  tag_name = sprintf("%s0x%x", (exif_info->prefix||"Tag"), tag_id); +  tag_format = 0; +  tag_map = ([]); +  } +  else { +  tag_name = temp[0]; +  tag_format = sizeof(temp)>1?temp[1]:0; +  tag_map = sizeof(temp)>2?temp[2]:([]); +  }       if(tag_format=="MAKE_MODEL")    {