public ExifSignedRationalArray(ExifTag <SignedRational[]> tag)
     : base(tag)
 {
 }
Exemplo n.º 2
0
 public ExifString(ExifTag <string> tag)
     : base(tag)
 {
 }
Exemplo n.º 3
0
 public ExifNumber(ExifTag <Number> tag)
     : base(tag)
 {
 }
Exemplo n.º 4
0
        /// <summary>
        /// Creates a new <see cref="ExifValue"/>
        /// </summary>
        /// <param name="tag">The tag.</param>
        /// <param name="value">The value.</param>
        /// <returns>
        /// The <see cref="ExifValue"/>.
        /// </returns>
        /// <exception cref="NotSupportedException">
        /// Thrown if the tag is not supported.
        /// </exception>
        internal static ExifValue Create(ExifTag tag, object value)
        {
            Guard.IsFalse(tag == ExifTag.Unknown, nameof(tag), "Invalid Tag");

            switch (tag)
            {
            case ExifTag.ImageDescription:
            case ExifTag.Make:
            case ExifTag.Model:
            case ExifTag.Software:
            case ExifTag.DateTime:
            case ExifTag.Artist:
            case ExifTag.HostComputer:
            case ExifTag.Copyright:
            case ExifTag.DocumentName:
            case ExifTag.PageName:
            case ExifTag.InkNames:
            case ExifTag.TargetPrinter:
            case ExifTag.ImageID:
            case ExifTag.MDLabName:
            case ExifTag.MDSampleInfo:
            case ExifTag.MDPrepDate:
            case ExifTag.MDPrepTime:
            case ExifTag.MDFileUnits:
            case ExifTag.SEMInfo:
            case ExifTag.SpectralSensitivity:
            case ExifTag.DateTimeOriginal:
            case ExifTag.DateTimeDigitized:
            case ExifTag.SubsecTime:
            case ExifTag.SubsecTimeOriginal:
            case ExifTag.SubsecTimeDigitized:
            case ExifTag.FaxSubaddress:
            case ExifTag.OffsetTime:
            case ExifTag.OffsetTimeOriginal:
            case ExifTag.OffsetTimeDigitized:
            case ExifTag.SecurityClassification:
            case ExifTag.ImageHistory:
            case ExifTag.ImageUniqueID:
            case ExifTag.OwnerName:
            case ExifTag.SerialNumber:
            case ExifTag.LensMake:
            case ExifTag.LensModel:
            case ExifTag.LensSerialNumber:
            case ExifTag.GDALMetadata:
            case ExifTag.GDALNoData:
            case ExifTag.GPSLatitudeRef:
            case ExifTag.GPSLongitudeRef:
            case ExifTag.GPSSatellites:
            case ExifTag.GPSStatus:
            case ExifTag.GPSMeasureMode:
            case ExifTag.GPSSpeedRef:
            case ExifTag.GPSTrackRef:
            case ExifTag.GPSImgDirectionRef:
            case ExifTag.GPSMapDatum:
            case ExifTag.GPSDestLatitudeRef:
            case ExifTag.GPSDestLongitudeRef:
            case ExifTag.GPSDestBearingRef:
            case ExifTag.GPSDestDistanceRef:
            case ExifTag.GPSDateStamp:
                return(new ExifValue(tag, ExifDataType.Ascii, value, true));

            case ExifTag.ClipPath:
            case ExifTag.VersionYear:
            case ExifTag.XMP:
            case ExifTag.CFAPattern2:
            case ExifTag.TIFFEPStandardID:
            case ExifTag.XPTitle:
            case ExifTag.XPComment:
            case ExifTag.XPAuthor:
            case ExifTag.XPKeywords:
            case ExifTag.XPSubject:
            case ExifTag.GPSVersionID:
                return(new ExifValue(tag, ExifDataType.Byte, value, true));

            case ExifTag.FaxProfile:
            case ExifTag.ModeNumber:
            case ExifTag.GPSAltitudeRef:
                return(new ExifValue(tag, ExifDataType.Byte, value, false));

            case ExifTag.FreeOffsets:
            case ExifTag.FreeByteCounts:
            case ExifTag.ColorResponseUnit:
            case ExifTag.TileOffsets:
            case ExifTag.SMinSampleValue:
            case ExifTag.SMaxSampleValue:
            case ExifTag.JPEGQTables:
            case ExifTag.JPEGDCTables:
            case ExifTag.JPEGACTables:
            case ExifTag.StripRowCounts:
            case ExifTag.IntergraphRegisters:
            case ExifTag.TimeZoneOffset:
                return(new ExifValue(tag, ExifDataType.Long, value, true));

            case ExifTag.SubfileType:
            case ExifTag.SubIFDOffset:
            case ExifTag.GPSIFDOffset:
            case ExifTag.T4Options:
            case ExifTag.T6Options:
            case ExifTag.XClipPathUnits:
            case ExifTag.YClipPathUnits:
            case ExifTag.ProfileType:
            case ExifTag.CodingMethods:
            case ExifTag.T82ptions:
            case ExifTag.JPEGInterchangeFormat:
            case ExifTag.JPEGInterchangeFormatLength:
            case ExifTag.MDFileTag:
            case ExifTag.StandardOutputSensitivity:
            case ExifTag.RecommendedExposureIndex:
            case ExifTag.ISOSpeed:
            case ExifTag.ISOSpeedLatitudeyyy:
            case ExifTag.ISOSpeedLatitudezzz:
            case ExifTag.FaxRecvParams:
            case ExifTag.FaxRecvTime:
            case ExifTag.ImageNumber:
                return(new ExifValue(tag, ExifDataType.Long, value, false));

            case ExifTag.WhitePoint:
            case ExifTag.PrimaryChromaticities:
            case ExifTag.YCbCrCoefficients:
            case ExifTag.ReferenceBlackWhite:
            case ExifTag.PixelScale:
            case ExifTag.IntergraphMatrix:
            case ExifTag.ModelTiePoint:
            case ExifTag.ModelTransform:
            case ExifTag.GPSLatitude:
            case ExifTag.GPSLongitude:
            case ExifTag.GPSTimestamp:
            case ExifTag.GPSDestLatitude:
            case ExifTag.GPSDestLongitude:
                return(new ExifValue(tag, ExifDataType.Rational, value, true));

            case ExifTag.XPosition:
            case ExifTag.YPosition:
            case ExifTag.XResolution:
            case ExifTag.YResolution:
            case ExifTag.BatteryLevel:
            case ExifTag.ExposureTime:
            case ExifTag.FNumber:
            case ExifTag.MDScalePixel:
            case ExifTag.CompressedBitsPerPixel:
            case ExifTag.ApertureValue:
            case ExifTag.MaxApertureValue:
            case ExifTag.SubjectDistance:
            case ExifTag.FocalLength:
            case ExifTag.FlashEnergy2:
            case ExifTag.FocalPlaneXResolution2:
            case ExifTag.FocalPlaneYResolution2:
            case ExifTag.ExposureIndex2:
            case ExifTag.Humidity:
            case ExifTag.Pressure:
            case ExifTag.Acceleration:
            case ExifTag.FlashEnergy:
            case ExifTag.FocalPlaneXResolution:
            case ExifTag.FocalPlaneYResolution:
            case ExifTag.ExposureIndex:
            case ExifTag.DigitalZoomRatio:
            case ExifTag.LensInfo:
            case ExifTag.GPSAltitude:
            case ExifTag.GPSDOP:
            case ExifTag.GPSSpeed:
            case ExifTag.GPSTrack:
            case ExifTag.GPSImgDirection:
            case ExifTag.GPSDestBearing:
            case ExifTag.GPSDestDistance:
                return(new ExifValue(tag, ExifDataType.Rational, value, false));

            case ExifTag.BitsPerSample:
            case ExifTag.MinSampleValue:
            case ExifTag.MaxSampleValue:
            case ExifTag.GrayResponseCurve:
            case ExifTag.ColorMap:
            case ExifTag.ExtraSamples:
            case ExifTag.PageNumber:
            case ExifTag.TransferFunction:
            case ExifTag.Predictor:
            case ExifTag.HalftoneHints:
            case ExifTag.SampleFormat:
            case ExifTag.TransferRange:
            case ExifTag.DefaultImageColor:
            case ExifTag.JPEGLosslessPredictors:
            case ExifTag.JPEGPointTransforms:
            case ExifTag.YCbCrSubsampling:
            case ExifTag.CFARepeatPatternDim:
            case ExifTag.IntergraphPacketData:
            case ExifTag.ISOSpeedRatings:
            case ExifTag.SubjectArea:
            case ExifTag.SubjectLocation:
                return(new ExifValue(tag, ExifDataType.Short, value, true));

            case ExifTag.OldSubfileType:
            case ExifTag.Compression:
            case ExifTag.PhotometricInterpretation:
            case ExifTag.Thresholding:
            case ExifTag.CellWidth:
            case ExifTag.CellLength:
            case ExifTag.FillOrder:
            case ExifTag.Orientation:
            case ExifTag.SamplesPerPixel:
            case ExifTag.PlanarConfiguration:
            case ExifTag.GrayResponseUnit:
            case ExifTag.ResolutionUnit:
            case ExifTag.CleanFaxData:
            case ExifTag.InkSet:
            case ExifTag.NumberOfInks:
            case ExifTag.DotRange:
            case ExifTag.Indexed:
            case ExifTag.OPIProxy:
            case ExifTag.JPEGProc:
            case ExifTag.JPEGRestartInterval:
            case ExifTag.YCbCrPositioning:
            case ExifTag.Rating:
            case ExifTag.RatingPercent:
            case ExifTag.ExposureProgram:
            case ExifTag.Interlace:
            case ExifTag.SelfTimerMode:
            case ExifTag.SensitivityType:
            case ExifTag.MeteringMode:
            case ExifTag.LightSource:
            case ExifTag.FocalPlaneResolutionUnit2:
            case ExifTag.SensingMethod2:
            case ExifTag.Flash:
            case ExifTag.ColorSpace:
            case ExifTag.FocalPlaneResolutionUnit:
            case ExifTag.SensingMethod:
            case ExifTag.CustomRendered:
            case ExifTag.ExposureMode:
            case ExifTag.WhiteBalance:
            case ExifTag.FocalLengthIn35mmFilm:
            case ExifTag.SceneCaptureType:
            case ExifTag.GainControl:
            case ExifTag.Contrast:
            case ExifTag.Saturation:
            case ExifTag.Sharpness:
            case ExifTag.SubjectDistanceRange:
            case ExifTag.GPSDifferential:
                return(new ExifValue(tag, ExifDataType.Short, value, false));

            case ExifTag.Decode:
                return(new ExifValue(tag, ExifDataType.SignedRational, value, true));

            case ExifTag.ShutterSpeedValue:
            case ExifTag.BrightnessValue:
            case ExifTag.ExposureBiasValue:
            case ExifTag.AmbientTemperature:
            case ExifTag.WaterDepth:
            case ExifTag.CameraElevationAngle:
                return(new ExifValue(tag, ExifDataType.SignedRational, value, false));

            case ExifTag.JPEGTables:
            case ExifTag.OECF:
            case ExifTag.ExifVersion:
            case ExifTag.ComponentsConfiguration:
            case ExifTag.MakerNote:
            case ExifTag.UserComment:
            case ExifTag.FlashpixVersion:
            case ExifTag.SpatialFrequencyResponse:
            case ExifTag.SpatialFrequencyResponse2:
            case ExifTag.Noise:
            case ExifTag.CFAPattern:
            case ExifTag.DeviceSettingDescription:
            case ExifTag.ImageSourceData:
            case ExifTag.GPSProcessingMethod:
            case ExifTag.GPSAreaInformation:
                return(new ExifValue(tag, ExifDataType.Undefined, value, true));

            case ExifTag.FileSource:
            case ExifTag.SceneType:
                return(new ExifValue(tag, ExifDataType.Undefined, value, false));

            case ExifTag.StripOffsets:
            case ExifTag.TileByteCounts:
            case ExifTag.ImageLayer:
                return(CreateNumber(tag, value, true));

            case ExifTag.ImageWidth:
            case ExifTag.ImageLength:
            case ExifTag.TileWidth:
            case ExifTag.TileLength:
            case ExifTag.BadFaxLines:
            case ExifTag.ConsecutiveBadFaxLines:
            case ExifTag.PixelXDimension:
            case ExifTag.PixelYDimension:
                return(CreateNumber(tag, value, false));

            default:
                throw new NotSupportedException();
            }
        }
Exemplo n.º 5
0
 public ExifByteArray(ExifTag <byte[]> tag, ExifDataType dataType)
     : base(tag) => this.DataType = dataType;
Exemplo n.º 6
0
 public ExifRationalArray(ExifTag <Rational[]> tag)
     : base(tag)
 {
 }
Exemplo n.º 7
0
 internal ExifSignedRational(ExifTag <SignedRational> tag)
     : base(tag)
 {
 }
Exemplo n.º 8
0
 protected ExifArrayValue(ExifTag <TValueType[]> tag)
     : base(tag)
 {
 }
Exemplo n.º 9
0
 public ExifLong(ExifTag <uint> tag)
     : base(tag)
 {
 }
Exemplo n.º 10
0
        private bool TryReadValue(out ExifValue exifValue)
        {
            // 2   | 2    | 4     | 4
            // tag | type | count | value offset
            if (this.RemainingLength < 12)
            {
                exifValue = default;

                return(false);
            }

            ExifTag tag  = this.ToEnum(this.ReadUInt16(), ExifTag.Unknown);
            uint    type = this.ReadUInt16();

            // Ensure that the data type is valid
            if (type == 0 || type > 12)
            {
                exifValue = new ExifValue(tag, ExifDataType.Unknown, null, false);

                return(true);
            }

            var dataType = (ExifDataType)type;

            object value;

            uint numberOfComponents = this.ReadUInt32();

            // Issue #132: ExifDataType == Undefined is treated like a byte array.
            // If numberOfComponents == 0 this value can only be handled as an inline value and must fallback to 4 (bytes)
            if (dataType == ExifDataType.Undefined && numberOfComponents == 0)
            {
                numberOfComponents = 4;
            }

            uint size = numberOfComponents * ExifValue.GetSize(dataType);

            this.TryReadSpan(4, out ReadOnlySpan <byte> offsetBuffer);

            if (size > 4)
            {
                int oldIndex = this.position;

                uint newIndex = this.ConvertToUInt32(offsetBuffer);

                // Ensure that the new index does not overrun the data
                if (newIndex > int.MaxValue)
                {
                    this.AddInvalidTag(tag);

                    exifValue = default;

                    return(false);
                }

                this.position = (int)newIndex;

                if (this.RemainingLength < size)
                {
                    this.AddInvalidTag(tag);

                    this.position = oldIndex;

                    exifValue = default;

                    return(false);
                }

                this.TryReadSpan((int)size, out ReadOnlySpan <byte> dataBuffer);

                value         = this.ConvertValue(dataType, dataBuffer, numberOfComponents);
                this.position = oldIndex;
            }
            else
            {
                value = this.ConvertValue(dataType, offsetBuffer, numberOfComponents);
            }

            exifValue = new ExifValue(tag, dataType, value, isArray: value != null && numberOfComponents != 1);

            return(true);
        }
Exemplo n.º 11
0
 private void AddInvalidTag(ExifTag tag)
 => (this.invalidTags ?? (this.invalidTags = new List <ExifTag>())).Add(tag);
Exemplo n.º 12
0
 /// <summary>
 /// Sets the value of the specified tag.
 /// </summary>
 /// <param name="tag">The tag of the exif value.</param>
 /// <param name="value">The value.</param>
 /// <typeparam name="TValueType">The data type of the tag.</typeparam>
 public void SetValue <TValueType>(ExifTag <TValueType> tag, TValueType value)
 => this.SetValueInternal(tag, value);
Exemplo n.º 13
0
        /// <summary>
        /// Returns the value with the specified tag.
        /// </summary>
        /// <param name="tag">The tag of the exif value.</param>
        /// <returns>The value with the specified tag.</returns>
        /// <typeparam name="TValueType">The data type of the tag.</typeparam>
        public IExifValue <TValueType> GetValue <TValueType>(ExifTag <TValueType> tag)
        {
            IExifValue value = this.GetValueInternal(tag);

            return(value is null ? null : (IExifValue <TValueType>)value);
        }
Exemplo n.º 14
0
 public ExifEncodedString(ExifTag <EncodedString> tag)
     : base(tag)
 {
 }
Exemplo n.º 15
0
 public ExifShort(ExifTag <ushort> tag)
     : base(tag)
 {
 }
Exemplo n.º 16
0
 public ExifNumberArray(ExifTag <Number[]> tag)
     : base(tag)
 {
 }
Exemplo n.º 17
0
 public ExifByte(ExifTag <byte> tag, ExifDataType dataType)
     : base(tag) => this.DataType = dataType;
Exemplo n.º 18
0
        private static IExifValue GetOffsetValue(List <IExifValue> ifdValues, List <IExifValue> values, ExifTag offset)
        {
            int index = -1;

            for (int i = 0; i < ifdValues.Count; i++)
            {
                if (ifdValues[i].Tag == offset)
                {
                    index = i;
                }
            }

            if (values.Count > 0)
            {
                if (index != -1)
                {
                    return(ifdValues[index]);
                }

                ExifValue result = ExifValues.Create(offset);
                ifdValues.Add(result);

                return(result);
            }
            else if (index != -1)
            {
                ifdValues.RemoveAt(index);
            }

            return(null);
        }
Exemplo n.º 19
0
 public ExifLong8(ExifTag <ulong> tag)
     : base(tag)
 {
 }
Exemplo n.º 20
0
 public ExifShortArray(ExifTag <ushort[]> tag)
     : base(tag)
 {
 }
Exemplo n.º 21
0
 public ExifDouble(ExifTag <double> tag)
     : base(tag)
 {
 }
Exemplo n.º 22
0
 public ExifRational(ExifTag <Rational> tag)
     : base(tag)
 {
 }