diff options
Diffstat (limited to 'lib/ref/metadata')
| -rw-r--r-- | lib/ref/metadata/exif.dart | 646 | ||||
| -rw-r--r-- | lib/ref/metadata/geotiff.dart | 29 | ||||
| -rw-r--r-- | lib/ref/metadata/iptc.dart | 8 | ||||
| -rw-r--r-- | lib/ref/metadata/xmp.dart | 114 |
4 files changed, 797 insertions, 0 deletions
diff --git a/lib/ref/metadata/exif.dart b/lib/ref/metadata/exif.dart new file mode 100644 index 0000000..cd3ecad --- /dev/null +++ b/lib/ref/metadata/exif.dart @@ -0,0 +1,646 @@ +class Exif { + // constants used by GPS related Exif tags + // they are locale independent + static const String latitudeNorth = 'N'; + static const String latitudeSouth = 'S'; + static const String longitudeEast = 'E'; + static const String longitudeWest = 'W'; + + static String getColorSpaceDescription(String valueString) { + final value = int.tryParse(valueString); + if (value == null) return valueString; + switch (value) { + case 1: + return 'sRGB'; + case 65535: + return 'Uncalibrated'; + default: + return 'Unknown ($value)'; + } + } + + static String getContrastDescription(String valueString) { + final value = int.tryParse(valueString); + if (value == null) return valueString; + switch (value) { + case 0: + return 'Normal'; + case 1: + return 'Soft'; + case 2: + return 'Hard'; + default: + return 'Unknown ($value)'; + } + } + + // adapted from `metadata-extractor` + static String getCompressionDescription(String valueString) { + final value = int.tryParse(valueString); + if (value == null) return valueString; + switch (value) { + case 1: + return 'Uncompressed'; + case 2: + return 'CCITT 1D'; + case 3: + return 'T4/Group 3 Fax'; + case 4: + return 'T6/Group 4 Fax'; + case 5: + return 'LZW'; + case 6: + return 'JPEG (old-style)'; + case 7: + return 'JPEG'; + case 8: + return 'Adobe Deflate'; + case 9: + return 'JBIG B&W'; + case 10: + return 'JBIG Color'; + case 99: + return 'JPEG'; + case 262: + return 'Kodak 262'; + case 32766: + return 'Next'; + case 32767: + return 'Sony ARW Compressed'; + case 32769: + return 'Packed RAW'; + case 32770: + return 'Samsung SRW Compressed'; + case 32771: + return 'CCIRLEW'; + case 32772: + return 'Samsung SRW Compressed 2'; + case 32773: + return 'PackBits'; + case 32809: + return 'Thunderscan'; + case 32867: + return 'Kodak KDC Compressed'; + case 32895: + return 'IT8CTPAD'; + case 32896: + return 'IT8LW'; + case 32897: + return 'IT8MP'; + case 32898: + return 'IT8BL'; + case 32908: + return 'PixarFilm'; + case 32909: + return 'PixarLog'; + case 32946: + return 'Deflate'; + case 32947: + return 'DCS'; + case 34661: + return 'JBIG'; + case 34676: + return 'SGILog'; + case 34677: + return 'SGILog24'; + case 34712: + return 'JPEG 2000'; + case 34713: + return 'Nikon NEF Compressed'; + case 34715: + return 'JBIG2 TIFF FX'; + case 34718: + return 'Microsoft Document Imaging (MDI) Binary Level Codec'; + case 34719: + return 'Microsoft Document Imaging (MDI) Progressive Transform Codec'; + case 34720: + return 'Microsoft Document Imaging (MDI) Vector'; + case 34892: + return 'Lossy JPEG'; + case 65000: + return 'Kodak DCR Compressed'; + case 65535: + return 'Pentax PEF Compressed'; + default: + return 'Unknown ($value)'; + } + } + + static String getCustomRenderedDescription(String valueString) { + final value = int.tryParse(valueString); + if (value == null) return valueString; + switch (value) { + case 0: + return 'Normal process'; + case 1: + return 'Custom process'; + default: + return 'Unknown ($value)'; + } + } + + static String getExifVersionDescription(String valueString) { + if (valueString.length == 4) { + final major = int.tryParse(valueString.substring(0, 2)); + final minor = int.tryParse(valueString.substring(2, 4)); + if (major != null && minor != null) { + return '$major.$minor'; + } + } + return valueString; + } + + static String getExposureModeDescription(String valueString) { + final value = int.tryParse(valueString); + if (value == null) return valueString; + switch (value) { + case 0: + return 'Auto exposure'; + case 1: + return 'Manual exposure'; + case 2: + return 'Auto bracket'; + default: + return 'Unknown ($value)'; + } + } + + static String getExposureProgramDescription(String valueString) { + final value = int.tryParse(valueString); + if (value == null) return valueString; + switch (value) { + case 1: + return 'Manual'; + case 2: + return 'Normal program'; + case 3: + return 'Aperture priority'; + case 4: + return 'Shutter priority'; + case 5: + return 'Creative program'; + case 6: + return 'Action program'; + case 7: + return 'Portrait mode'; + case 8: + return 'Landscape mode'; + default: + return 'Unknown ($value)'; + } + } + + // adapted from `metadata-extractor` + static String getFileSourceDescription(String valueString) { + final value = int.tryParse(valueString); + if (value == null) return valueString; + switch (value) { + case 1: + return 'Film Scanner'; + case 2: + return 'Reflection Print Scanner'; + case 3: + return 'Digital Still Camera (DSC)'; + default: + return 'Unknown ($value)'; + } + } + + static String getLightSourceDescription(String valueString) { + final value = int.tryParse(valueString); + if (value == null) return valueString; + switch (value) { + case 0: + return 'Unknown'; + case 1: + return 'Daylight'; + case 2: + return 'Fluorescent'; + case 3: + return 'Tungsten (Incandescent)'; + case 4: + return 'Flash'; + case 9: + return 'Fine Weather'; + case 10: + return 'Cloudy Weather'; + case 11: + return 'Shade'; + case 12: + return 'Daylight Fluorescent (D 5700 – 7100K)'; + case 13: + return 'Day White Fluorescent (N 4600 – 5400K)'; + case 14: + return 'Cool White Fluorescent (W 3900 – 4500K)'; + case 15: + return 'White Fluorescent (WW 3200 – 3700K)'; + case 16: + return 'Warm White Fluorescent (WW 2600 - 3250K)'; + case 17: + return 'Standard light A'; + case 18: + return 'Standard light B'; + case 19: + return 'Standard light C'; + case 20: + return 'D55'; + case 21: + return 'D65'; + case 22: + return 'D75'; + case 23: + return 'D50'; + case 24: + return 'ISO Studio Tungsten'; + case 255: + return 'Other'; + default: + return 'Unknown ($value)'; + } + } + + // adapted from `metadata-extractor` + static String getOrientationDescription(String valueString) { + final value = int.tryParse(valueString); + if (value == null) return valueString; + switch (value) { + case 1: + return 'Top, left side (Horizontal / normal)'; + case 2: + return 'Top, right side (Mirror horizontal)'; + case 3: + return 'Bottom, right side (Rotate 180)'; + case 4: + return 'Bottom, left side (Mirror vertical)'; + case 5: + return 'Left side, top (Mirror horizontal and rotate 270 CW)'; + case 6: + return 'Right side, top (Rotate 90 CW)'; + case 7: + return 'Right side, bottom (Mirror horizontal and rotate 90 CW)'; + case 8: + return 'Left side, bottom (Rotate 270 CW)'; + default: + return 'Unknown ($value)'; + } + } + + // adapted from `metadata-extractor` + static String getPhotometricInterpretationDescription(String valueString) { + final value = int.tryParse(valueString); + if (value == null) return valueString; + switch (value) { + case 0: + return 'WhiteIsZero'; + case 1: + return 'BlackIsZero'; + case 2: + return 'RGB'; + case 3: + return 'RGB Palette'; + case 4: + return 'Transparency Mask'; + case 5: + return 'CMYK'; + case 6: + return 'YCbCr'; + case 8: + return 'CIELab'; + case 9: + return 'ICCLab'; + case 10: + return 'ITULab'; + case 32803: + return 'Color Filter Array'; + case 32844: + return 'Pixar LogL'; + case 32845: + return 'Pixar LogLuv'; + case 32892: + return 'Linear Raw'; + default: + return 'Unknown ($value)'; + } + } + + // adapted from `metadata-extractor` + static String getPlanarConfigurationDescription(String valueString) { + final value = int.tryParse(valueString); + if (value == null) return valueString; + switch (value) { + case 1: + return 'Chunky (contiguous for each subsampling pixel)'; + case 2: + return 'Separate (Y-plane/Cb-plane/Cr-plane format)'; + default: + return 'Unknown ($value)'; + } + } + + // adapted from `metadata-extractor` + static String getResolutionUnitDescription(String valueString) { + final value = int.tryParse(valueString); + if (value == null) return valueString; + switch (value) { + case 1: + return '(No unit)'; + case 2: + return 'Inch'; + case 3: + return 'cm'; + default: + return 'Unknown ($value)'; + } + } + + static String getGainControlDescription(String valueString) { + final value = int.tryParse(valueString); + if (value == null) return valueString; + switch (value) { + case 0: + return 'None'; + case 1: + return 'Low gain up'; + case 2: + return 'High gain up'; + case 3: + return 'Low gain down'; + case 4: + return 'High gain down'; + default: + return 'Unknown ($value)'; + } + } + + static String getMeteringModeDescription(String valueString) { + final value = int.tryParse(valueString); + if (value == null) return valueString; + switch (value) { + case 0: + return 'Unknown'; + case 1: + return 'Average'; + case 2: + return 'Center weighted average'; + case 3: + return 'Spot'; + case 4: + return 'Multi-spot'; + case 5: + return 'Pattern'; + case 6: + return 'Partial'; + case 255: + return 'Other'; + default: + return 'Unknown ($value)'; + } + } + + static String getSaturationDescription(String valueString) { + final value = int.tryParse(valueString); + if (value == null) return valueString; + switch (value) { + case 0: + return 'Normal'; + case 1: + return 'Low saturation'; + case 2: + return 'High saturation'; + default: + return 'Unknown ($value)'; + } + } + + static String getSceneCaptureTypeDescription(String valueString) { + final value = int.tryParse(valueString); + if (value == null) return valueString; + switch (value) { + case 0: + return 'Standard'; + case 1: + return 'Landscape'; + case 2: + return 'Portrait'; + case 3: + return 'Night scene'; + default: + return 'Unknown ($value)'; + } + } + + static String getSceneTypeDescription(String valueString) { + final value = int.tryParse(valueString); + if (value == null) return valueString; + switch (value) { + case 1: + return 'Directly photographed image'; + default: + return 'Unknown ($value)'; + } + } + + static String getSensingMethodDescription(String valueString) { + final value = int.tryParse(valueString); + if (value == null) return valueString; + switch (value) { + case 1: + return 'Not defined'; + case 2: + return 'One-chip colour area sensor'; + case 3: + return 'Two-chip colour area sensor'; + case 4: + return 'Three-chip colour area sensor'; + case 5: + return 'Colour sequential area sensor'; + case 7: + return 'Trilinear sensor'; + case 8: + return 'Colour sequential linear sensor'; + default: + return 'Unknown ($value)'; + } + } + + static String getSharpnessDescription(String valueString) { + final value = int.tryParse(valueString); + if (value == null) return valueString; + switch (value) { + case 0: + return 'Normal'; + case 1: + return 'Soft'; + case 2: + return 'Hard'; + default: + return 'Unknown ($value)'; + } + } + + static String getSubjectDistanceRangeDescription(String valueString) { + final value = int.tryParse(valueString); + if (value == null) return valueString; + switch (value) { + case 0: + return 'Unknown'; + case 1: + return 'Macro'; + case 2: + return 'Close view'; + case 3: + return 'Distant view'; + default: + return 'Unknown ($value)'; + } + } + + static String getWhiteBalanceDescription(String valueString) { + final value = int.tryParse(valueString); + if (value == null) return valueString; + switch (value) { + case 0: + return 'Auto'; + case 1: + return 'Manual'; + default: + return 'Unknown ($value)'; + } + } + + static String getYCbCrPositioningDescription(String valueString) { + final value = int.tryParse(valueString); + if (value == null) return valueString; + switch (value) { + case 1: + return 'Centered'; + case 2: + return 'Co-sited'; + default: + return 'Unknown ($value)'; + } + } + + // Flash + + static String getFlashModeDescription(String valueString) { + final value = int.tryParse(valueString); + if (value == null) return valueString; + switch (value) { + case 0: + return 'Unknown'; + case 1: + return 'Compulsory flash firing'; + case 2: + return 'Compulsory flash suppression'; + case 3: + return 'Auto mode'; + default: + return 'Unknown ($value)'; + } + } + + static String getFlashReturnDescription(String valueString) { + final value = int.tryParse(valueString); + if (value == null) return valueString; + switch (value) { + case 0: + return 'No strobe return detection'; + case 2: + return 'Strobe return light not detected'; + case 3: + return 'Strobe return light detected'; + default: + return 'Unknown ($value)'; + } + } + + // GPS + + static String getGPSAltitudeRefDescription(String valueString) { + final value = int.tryParse(valueString); + if (value == null) return valueString; + switch (value) { + case 0: + return 'Above sea level'; + case 1: + return 'Below sea level'; + default: + return 'Unknown ($value)'; + } + } + + static String getGPSDifferentialDescription(String valueString) { + final value = int.tryParse(valueString); + if (value == null) return valueString; + switch (value) { + case 0: + return 'Without correction'; + case 1: + return 'Correction applied'; + default: + return 'Unknown ($value)'; + } + } + + static String getGPSDirectionRefDescription(String value) { + switch (value) { + case 'T': + return 'True direction'; + case 'M': + return 'Magnetic direction'; + default: + return 'Unknown ($value)'; + } + } + + static String getGPSMeasureModeDescription(String valueString) { + final value = int.tryParse(valueString); + if (value == null) return valueString; + switch (value) { + case 2: + return 'Two-dimensional measurement'; + case 3: + return 'Three-dimensional measurement'; + default: + return 'Unknown ($value)'; + } + } + + static String getGPSDestDistanceRefDescription(String value) { + switch (value) { + case 'K': + return 'kilometers'; + case 'M': + return 'miles'; + case 'N': + return 'knots'; + default: + return 'Unknown ($value)'; + } + } + + static String getGPSSpeedRefDescription(String value) { + switch (value) { + case 'K': + return 'kilometers per hour'; + case 'M': + return 'miles per hour'; + case 'N': + return 'knots'; + default: + return 'Unknown ($value)'; + } + } + + static String getGPSStatusDescription(String value) { + switch (value) { + case 'A': + return 'Measurement in progress'; + case 'V': + return 'Measurement is interoperability'; + default: + return 'Unknown ($value)'; + } + } +} diff --git a/lib/ref/metadata/geotiff.dart b/lib/ref/metadata/geotiff.dart new file mode 100644 index 0000000..d8c5dec --- /dev/null +++ b/lib/ref/metadata/geotiff.dart @@ -0,0 +1,29 @@ +class GeoTiffExifTags { + static const int modelPixelScale = 0x830e; + static const int modelTiePoints = 0x8482; + static const int modelTransformation = 0x85d8; + static const int geoKeyDirectory = 0x87af; + static const int geoDoubleParams = 0x87b0; + static const int geoAsciiParams = 0x87b1; +} + +class GeoTiffKeys { + static const int modelType = 0x0400; + static const int rasterType = 0x0401; + static const int geographicType = 0x0800; + static const int geogGeodeticDatum = 0x0802; + static const int geogAngularUnits = 0x0806; + static const int geogEllipsoid = 0x0808; + static const int projCSType = 0x0c00; + static const int projection = 0x0c02; + static const int projCoordinateTransform = 0x0c03; + static const int projLinearUnits = 0x0c04; + static const int verticalUnits = 0x1003; +} + +class GeoTiffUnits { + static const int linearMeter = 9001; + static const int linearFootUSSurvey = 9003; + + double footUSSurveyToMeter(double input) => input * 1200 / 3937; +} diff --git a/lib/ref/metadata/iptc.dart b/lib/ref/metadata/iptc.dart new file mode 100644 index 0000000..5ef584d --- /dev/null +++ b/lib/ref/metadata/iptc.dart @@ -0,0 +1,8 @@ +class IPTC { + static const int applicationRecord = 2; + + // ApplicationRecord tags + static const int objectName = 5; + static const int keywordsTag = 25; + static const int captionAbstractTag = 120; +} diff --git a/lib/ref/metadata/xmp.dart b/lib/ref/metadata/xmp.dart new file mode 100644 index 0000000..311d7a4 --- /dev/null +++ b/lib/ref/metadata/xmp.dart @@ -0,0 +1,114 @@ +class XmpNamespaces { + static const acdsee = 'http://ns.acdsee.com/iptc/1.0/'; + static const adsmlat = 'http://adsml.org/xmlns/'; + static const appleDepthData = 'http://ns.apple.com/depthData/1.0/'; + static const appleDesktop = 'http://ns.apple.com/namespace/1.0/'; + static const appleHDRGainMap = 'http://ns.apple.com/HDRGainMap/1.0/'; + static const applePixelDataInfo = 'http://ns.apple.com/pixeldatainfo/1.0/'; + static const avm = 'http://www.communicatingastronomy.org/avm/1.0/'; + static const camera = 'http://pix4d.com/camera/1.0/'; + static const cc = 'http://creativecommons.org/ns#'; + static const creatorAtom = 'http://ns.adobe.com/creatorAtom/1.0/'; + static const crd = 'http://ns.adobe.com/camera-raw-defaults/1.0/'; + static const crlcp = 'http://ns.adobe.com/camera-raw-embedded-lens-profile/1.0/'; + static const crs = 'http://ns.adobe.com/camera-raw-settings/1.0/'; + static const crss = 'http://ns.adobe.com/camera-raw-saved-settings/1.0/'; + static const darktable = 'http://darktable.sf.net/'; + static const dc = 'http://purl.org/dc/elements/1.1/'; + static const dcterms = 'http://purl.org/dc/terms/'; + static const dicom = 'http://ns.adobe.com/DICOM/'; + static const digiKam = 'http://www.digikam.org/ns/1.0/'; + static const droneDji = 'http://www.dji.com/drone-dji/1.0/'; + static const dwc = 'http://rs.tdwg.org/dwc/index.htm'; + static const dwciri = 'http://rs.tdwg.org/dwc/iri/'; + static const exif = 'http://ns.adobe.com/exif/1.0/'; + static const exifAux = 'http://ns.adobe.com/exif/1.0/aux/'; + static const exifEx = 'http://cipa.jp/exif/1.0/'; + static const fstop = 'http://www.fstopapp.com/xmp/'; + static const gAudio = 'http://ns.google.com/photos/1.0/audio/'; + static const gCamera = 'http://ns.google.com/photos/1.0/camera/'; + static const gContainer = 'http://ns.google.com/photos/1.0/container/'; + static const gContainerItem = 'http://ns.google.com/photos/1.0/container/item/'; + static const gCreations = 'http://ns.google.com/photos/1.0/creations/'; + static const gDepth = 'http://ns.google.com/photos/1.0/depthmap/'; + static const gDevice = 'http://ns.google.com/photos/dd/1.0/device/'; + static const gDeviceCamera = 'http://ns.google.com/photos/dd/1.0/camera/'; + static const gDeviceContainer = 'http://ns.google.com/photos/dd/1.0/container/'; + static const gDeviceItem = 'http://ns.google.com/photos/dd/1.0/item/'; + static const gFocus = 'http://ns.google.com/photos/1.0/focus/'; + static const gImage = 'http://ns.google.com/photos/1.0/image/'; + static const gPano = 'http://ns.google.com/photos/1.0/panorama/'; + static const gPhotoScan = 'http://ns.google.com/photos/1.0/photoscan/'; + static const gSpherical = 'http://ns.google.com/videos/1.0/spherical/'; + static const gettyImagesGift = 'http://xmp.gettyimages.com/gift/1.0/'; + static const gimp210 = 'http://www.gimp.org/ns/2.10/'; + static const gimpXmp = 'http://www.gimp.org/xmp/'; + static const hdrgm = 'http://ns.adobe.com/hdr-gain-map/1.0/'; + static const illustrator = 'http://ns.adobe.com/illustrator/1.0/'; + static const iptc4xmpCore = 'http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/'; + static const iptc4xmpExt = 'http://iptc.org/std/Iptc4xmpExt/2008-02-29/'; + static const lr = 'http://ns.adobe.com/lightroom/1.0/'; + static const mediapro = 'http://ns.iview-multimedia.com/mediapro/1.0/'; + static const miCamera = 'http://ns.xiaomi.com/photos/1.0/camera/'; + + // also seen in the wild for prefix `MicrosoftPhoto`: 'http://ns.microsoft.com/photo/1.0' + static const microsoftPhoto = 'http://ns.microsoft.com/photo/1.0/'; + static const mp1 = 'http://ns.microsoft.com/photo/1.1'; + static const mp = 'http://ns.microsoft.com/photo/1.2/'; + static const mpri = 'http://ns.microsoft.com/photo/1.2/t/RegionInfo#'; + static const mpreg = 'http://ns.microsoft.com/photo/1.2/t/Region#'; + static const mwgrs = 'http://www.metadataworkinggroup.com/schemas/regions/'; + static const nga = 'https://standards.nga.gov/metadata/media/image/artobject/1.0'; + static const opMedia = 'http://ns.oneplus.com/media/1.0/'; + static const panorama = 'http://ns.adobe.com/photoshop/1.0/panorama-profile'; + static const panoStudio = 'http://www.tshsoft.com/xmlns'; + static const pdf = 'http://ns.adobe.com/pdf/1.3/'; + static const pdfX = 'http://ns.adobe.com/pdfx/1.3/'; + static const photoMechanic = 'http://ns.camerabits.com/photomechanic/1.0/'; + static const photoshop = 'http://ns.adobe.com/photoshop/1.0/'; + static const plus = 'http://ns.useplus.org/ldf/xmp/1.0/'; + static const pmtm = 'http://www.hdrsoft.com/photomatix_settings01'; + static const rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'; + static const stCamera = 'http://ns.adobe.com/photoshop/1.0/camera-profile'; + static const stEvt = 'http://ns.adobe.com/xap/1.0/sType/ResourceEvent#'; + static const stRef = 'http://ns.adobe.com/xap/1.0/sType/ResourceRef#'; + static const tiff = 'http://ns.adobe.com/tiff/1.0/'; + static const x = 'adobe:ns:meta/'; + static const xmp = 'http://ns.adobe.com/xap/1.0/'; + static const xmpBJ = 'http://ns.adobe.com/xap/1.0/bj/'; + static const xmpDM = 'http://ns.adobe.com/xmp/1.0/DynamicMedia/'; + static const xmpGImg = 'http://ns.adobe.com/xap/1.0/g/img/'; + static const xmpMM = 'http://ns.adobe.com/xap/1.0/mm/'; + static const xmpNote = 'http://ns.adobe.com/xmp/note/'; + static const xmpRights = 'http://ns.adobe.com/xap/1.0/rights/'; + static const xmpTPg = 'http://ns.adobe.com/xap/1.0/t/pg/'; + static const xperiaCamera = 'http://xmlns.sony.net/xperia/camera/1.0/'; +} + +class XmpElements { + static const xXmpmeta = 'xmpmeta'; + static const rdfRoot = 'RDF'; + static const rdfDescription = 'Description'; + static const containerDirectory = 'Directory'; + static const dcDescription = 'description'; + static const dcSubject = 'subject'; + static const dcTitle = 'title'; + static const msPhotoRating = 'Rating'; + static const xmpRating = 'Rating'; +} + +class XmpAttributes { + static const xXmptk = 'xmptk'; + static const rdfAbout = 'about'; + static const gCameraMicroVideo = 'MicroVideo'; + static const gCameraMicroVideoVersion = 'MicroVideoVersion'; + static const gCameraMicroVideoOffset = 'MicroVideoOffset'; + static const gCameraMicroVideoPresentationTimestampUs = 'MicroVideoPresentationTimestampUs'; + static const gCameraMotionPhoto = 'MotionPhoto'; + static const gCameraMotionPhotoVersion = 'MotionPhotoVersion'; + static const gCameraMotionPhotoPresentationTimestampUs = 'MotionPhotoPresentationTimestampUs'; + static const xmpCreateDate = 'CreateDate'; + static const xmpMetadataDate = 'MetadataDate'; + static const xmpModifyDate = 'ModifyDate'; + static const xmpNoteHasExtendedXMP = 'HasExtendedXMP'; +} |
