From 9373a5c0459f5f47164ea4e9f2dc78005bbf605d Mon Sep 17 00:00:00 2001 From: James South Date: Mon, 26 May 2014 21:42:48 +0100 Subject: [PATCH] Adding basic EXIF property item manipulation Former-commit-id: 499d99a0048d840c7434726d0776035d258faa4b --- README.md | 2 +- src/ImageProcessor/ImageFactory.cs | 65 +- src/ImageProcessor/ImageProcessor.csproj | 2 + src/ImageProcessor/Imaging/ExifPropertyTag.cs | 1107 +++++++++++++++++ .../Imaging/ExifPropertyTagType.cs | 58 + src/ImageProcessor/Imaging/ImageUtils.cs | 18 + src/ImageProcessor/Settings.StyleCop | 4 + 7 files changed, 1253 insertions(+), 3 deletions(-) create mode 100644 src/ImageProcessor/Imaging/ExifPropertyTag.cs create mode 100644 src/ImageProcessor/Imaging/ExifPropertyTagType.cs diff --git a/README.md b/README.md index a682ace93..d4d302c40 100644 --- a/README.md +++ b/README.md @@ -5,4 +5,4 @@ Imageprocessor is a lightweight library written in C# that allows you to manipul It's fast, extensible, easy to use, comes bundled with some great features and is fully open source. -For full documentation please see [http://jimbobsquarepants.github.io/ImageProcessor/](http://jimbobsquarepants.github.io/ImageProcessor/) +For full documentation please see [http://imageprocessor.org/](http://imageprocessor.org/) \ No newline at end of file diff --git a/src/ImageProcessor/ImageFactory.cs b/src/ImageProcessor/ImageFactory.cs index dcfae8000..4262c1449 100644 --- a/src/ImageProcessor/ImageFactory.cs +++ b/src/ImageProcessor/ImageFactory.cs @@ -12,6 +12,7 @@ namespace ImageProcessor { #region Using using System; + using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Drawing; @@ -19,7 +20,6 @@ namespace ImageProcessor using System.IO; using System.Linq; using System.Threading; - using ImageProcessor.Extensions; using ImageProcessor.Imaging; using ImageProcessor.Imaging.Filters; @@ -37,6 +37,11 @@ namespace ImageProcessor /// private const int DefaultJpegQuality = 90; + /// + /// Whether to preserve exif metadata + /// + private readonly bool preserveExifData; + /// /// The backup image format. /// @@ -66,6 +71,20 @@ namespace ImageProcessor private bool isDisposed; #endregion + #region Constructors + /// + /// Initializes a new instance of the class. + /// + /// + /// Whether to preserve exif metadata. Defaults to false. + /// + public ImageFactory(bool preserveExifData = true) + { + this.preserveExifData = preserveExifData; + this.ExifPropertyItems = new ConcurrentDictionary(); + } + #endregion + #region Destructors /// /// Finalizes an instance of the ImageFactory class. @@ -123,6 +142,11 @@ namespace ImageProcessor } } + /// + /// Gets or sets the exif property items. + /// + public ConcurrentDictionary ExifPropertyItems { get; set; } + /// /// Gets or sets the original extension. /// @@ -157,6 +181,15 @@ namespace ImageProcessor this.ImageFormat = this.Image.RawFormat; this.backupImageFormat = this.ImageFormat; this.isIndexed = ImageUtils.IsIndexed(this.Image); + + if (this.preserveExifData) + { + foreach (PropertyItem propertyItem in this.Image.PropertyItems) + { + this.ExifPropertyItems[propertyItem.Id] = propertyItem; + } + } + this.ShouldProcess = true; return this; @@ -210,6 +243,15 @@ namespace ImageProcessor this.OriginalExtension = Path.GetExtension(this.ImagePath); this.ImageFormat = imageFormat; this.isIndexed = ImageUtils.IsIndexed(this.Image); + + if (this.preserveExifData) + { + foreach (PropertyItem propertyItem in this.Image.PropertyItems) + { + this.ExifPropertyItems[propertyItem.Id] = propertyItem; + } + } + this.ShouldProcess = true; } } @@ -419,7 +461,7 @@ namespace ImageProcessor return this; } - + /// /// Applies a filter to the current image. /// @@ -1032,6 +1074,25 @@ namespace ImageProcessor { this.Image = processor.Invoke(this); } + + // Set the property item information from any Exif metadata. + // We do this here so that they can be changed between processor methods. + if (this.preserveExifData) + { + foreach (KeyValuePair propertItem in this.ExifPropertyItems) + { + try + { + this.Image.SetPropertyItem(propertItem.Value); + } + // ReSharper disable once EmptyGeneralCatchClause + catch + { + // Do nothing. The image format does not handle EXIF data. + // TODO: empty catch is fierce code smell. + } + } + } } #endregion } diff --git a/src/ImageProcessor/ImageProcessor.csproj b/src/ImageProcessor/ImageProcessor.csproj index cf27f6c1d..fdd16c8d9 100644 --- a/src/ImageProcessor/ImageProcessor.csproj +++ b/src/ImageProcessor/ImageProcessor.csproj @@ -67,9 +67,11 @@ + + diff --git a/src/ImageProcessor/Imaging/ExifPropertyTag.cs b/src/ImageProcessor/Imaging/ExifPropertyTag.cs new file mode 100644 index 000000000..581e5572b --- /dev/null +++ b/src/ImageProcessor/Imaging/ExifPropertyTag.cs @@ -0,0 +1,1107 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// The following enum gives descriptions of the property items supported by Windows GDI+. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.Imaging +{ + /// + /// The following enum gives descriptions of the property items supported by Windows GDI+. + /// + /// TODO: Add more XML descriptions. + /// + public enum ExifPropertyTag + { + /// + /// Null-terminated character string that specifies the name of the person who created the image. + /// + Artist = 0x013B, + + /// + /// Number of bits per color component. See also + /// + BitsPerSample = 0x0102, + + /// + /// Height of the dithering or halftoning matrix. + /// + CellHeight = 0x0109, + + /// + /// Width of the dithering or halftoning matrix. + /// + CellWidth = 0x0108, + + /// + /// Chrominance table. The luminance table and the chrominance table are used to control JPEG quality. + /// A valid luminance or chrominance table has 64 entries. + /// If an image has either a luminance table or a chrominance table, then it must have both tables. + /// + ChrominanceTable = 0x5091, + + /// + /// Color palette (lookup table) for a palette-indexed image. + /// + ColorMap = 0x0140, + + /// + /// The color transfer function. + /// + ColorTransferFunction = 0x501A, + + /// + /// The compression. + /// + Compression = 0x0103, + + /// + /// The copyright. + /// + Copyright = 0x8298, + + /// + /// The date time. + /// + DateTime = 0x0132, + + /// + /// The document name. + /// + DocumentName = 0x010D, + + /// + /// The dot range. + /// + DotRange = 0x0150, + + /// + /// The equip make. + /// + EquipMake = 0x010F, + + /// + /// The equip model. + /// + EquipModel = 0x0110, + + /// + /// The exif aperture. + /// + ExifAperture = 0x9202, + + /// + /// The exif brightness. + /// + ExifBrightness = 0x9203, + + /// + /// The exif cfa pattern. + /// + ExifCfaPattern = 0xA302, + + /// + /// The exif color space. + /// + ExifColorSpace = 0xA001, + + /// + /// The exif comp bpp. + /// + ExifCompBPP = 0x9102, + + /// + /// The exif comp config. + /// + ExifCompConfig = 0x9101, + + /// + /// The exif dt digitized. + /// + ExifDTDigitized = 0x9004, + + /// + /// The exif dt dig ss. + /// + ExifDTDigSS = 0x9292, + + /// + /// The exif dt orig. + /// + ExifDTOrig = 0x9003, + + /// + /// The exif dt orig ss. + /// + ExifDTOrigSS = 0x9291, + + /// + /// The exif dt subsec. + /// + ExifDTSubsec = 0x9290, + + /// + /// The exif exposure bias. + /// + ExifExposureBias = 0x9204, + + /// + /// The exif exposure index. + /// + ExifExposureIndex = 0xA215, + + /// + /// The exif exposure prog. + /// + ExifExposureProg = 0x8822, + + /// + /// The exif exposure time. + /// + ExifExposureTime = 0x829A, + + /// + /// The exif file source. + /// + ExifFileSource = 0xA300, + + /// + /// The exif flash. + /// + ExifFlash = 0x9209, + + /// + /// The exif flash energy. + /// + ExifFlashEnergy = 0xA20B, + + /// + /// The exif f number. + /// + ExifFNumber = 0x829D, + + /// + /// The exif focal length. + /// + ExifFocalLength = 0x920A, + + /// + /// The exif focal res unit. + /// + ExifFocalResUnit = 0xA210, + + /// + /// The exif focal x res. + /// + ExifFocalXRes = 0xA20E, + + /// + /// The exif focal y res. + /// + ExifFocalYRes = 0xA20F, + + /// + /// The exif fpx ver. + /// + ExifFPXVer = 0xA000, + + /// + /// The exif ifd. + /// + ExifIFD = 0x8769, + + /// + /// The exif interop. + /// + ExifInterop = 0xA005, + + /// + /// The exif iso speed. + /// + ExifISOSpeed = 0x8827, + + /// + /// The exif light source. + /// + ExifLightSource = 0x9208, + + /// + /// The exif maker note. + /// + ExifMakerNote = 0x927C, + + /// + /// The exif max aperture. + /// + ExifMaxAperture = 0x9205, + + /// + /// The exif metering mode. + /// + ExifMeteringMode = 0x9207, + + /// + /// The exif oecf. + /// + ExifOECF = 0x8828, + + /// + /// The exif pix x dim. + /// + ExifPixXDim = 0xA002, + + /// + /// The exif pix y dim. + /// + ExifPixYDim = 0xA003, + + /// + /// The exif related wav. + /// + ExifRelatedWav = 0xA004, + + /// + /// The exif scene type. + /// + ExifSceneType = 0xA301, + + /// + /// The exif sensing method. + /// + ExifSensingMethod = 0xA217, + + /// + /// The exif shutter speed. + /// + ExifShutterSpeed = 0x9201, + + /// + /// The exif spatial fr. + /// + ExifSpatialFR = 0xA20C, + + /// + /// The exif spectral sense. + /// + ExifSpectralSense = 0x8824, + + /// + /// The exif subject dist. + /// + ExifSubjectDist = 0x9206, + + /// + /// The exif subject loc. + /// + ExifSubjectLoc = 0xA214, + + /// + /// The exif user comment. + /// + ExifUserComment = 0x9286, + + /// + /// The exif ver. + /// + ExifVer = 0x9000, + + /// + /// The extra samples. + /// + ExtraSamples = 0x0152, + + /// + /// The fill order. + /// + FillOrder = 0x010A, + + /// + /// The frame delay. + /// + FrameDelay = 0x5100, + + /// + /// The free byte counts. + /// + FreeByteCounts = 0x0121, + + /// + /// The free offset. + /// + FreeOffset = 0x0120, + + /// + /// The gamma. + /// + Gamma = 0x0301, + + /// + /// The global palette. + /// + GlobalPalette = 0x5102, + + /// + /// The gps altitude. + /// + GpsAltitude = 0x0006, + + /// + /// The gps altitude ref. + /// + GpsAltitudeRef = 0x0005, + + /// + /// The gps dest bear. + /// + GpsDestBear = 0x0018, + + /// + /// The gps dest bear ref. + /// + GpsDestBearRef = 0x0017, + + /// + /// The gps dest dist. + /// + GpsDestDist = 0x001A, + + /// + /// The gps dest dist ref. + /// + GpsDestDistRef = 0x0019, + + /// + /// The gps dest lat. + /// + GpsDestLat = 0x0014, + + /// + /// The gps dest lat ref. + /// + GpsDestLatRef = 0x0013, + + /// + /// The gps dest long. + /// + GpsDestLong = 0x0016, + + /// + /// The gps dest long ref. + /// + GpsDestLongRef = 0x0015, + + /// + /// The gps gps dop. + /// + GpsGpsDop = 0x000B, + + /// + /// The gps gps measure mode. + /// + GpsGpsMeasureMode = 0x000A, + + /// + /// The gps gps satellites. + /// + GpsGpsSatellites = 0x0008, + + /// + /// The gps gps status. + /// + GpsGpsStatus = 0x0009, + + /// + /// The gps gps time. + /// + GpsGpsTime = 0x0007, + + /// + /// The gps ifd. + /// + GpsIFD = 0x8825, + + /// + /// The gps img dir. + /// + GpsImgDir = 0x0011, + + /// + /// The gps img dir ref. + /// + GpsImgDirRef = 0x0010, + + /// + /// The gps latitude. + /// + GpsLatitude = 0x0002, + + /// + /// The gps latitude ref. + /// + GpsLatitudeRef = 0x0001, + + /// + /// The gps longitude. + /// + GpsLongitude = 0x0004, + + /// + /// The gps longitude ref. + /// + GpsLongitudeRef = 0x0003, + + /// + /// The gps map datum. + /// + GpsMapDatum = 0x0012, + + /// + /// The gps speed. + /// + GpsSpeed = 0x000D, + + /// + /// The gps speed ref. + /// + GpsSpeedRef = 0x000C, + + /// + /// The gps track. + /// + GpsTrack = 0x000F, + + /// + /// The gps track ref. + /// + GpsTrackRef = 0x000E, + + /// + /// The gps ver. + /// + GpsVer = 0x0000, + + /// + /// The gray response curve. + /// + GrayResponseCurve = 0x0123, + + /// + /// The gray response unit. + /// + GrayResponseUnit = 0x0122, + + /// + /// The grid size. + /// + GridSize = 0x5011, + + /// + /// The halftone degree. + /// + HalftoneDegree = 0x500C, + + /// + /// The halftone hints. + /// + HalftoneHints = 0x0141, + + /// + /// The halftone lpi. + /// + HalftoneLPI = 0x500A, + + /// + /// The halftone lpi unit. + /// + HalftoneLPIUnit = 0x500B, + + /// + /// The halftone misc. + /// + HalftoneMisc = 0x500E, + + /// + /// The halftone screen. + /// + HalftoneScreen = 0x500F, + + /// + /// The halftone shape. + /// + HalftoneShape = 0x500D, + + /// + /// The host computer. + /// + HostComputer = 0x013C, + + /// + /// The icc profile. + /// + ICCProfile = 0x8773, + + /// + /// The icc profile descriptor. + /// + ICCProfileDescriptor = 0x0302, + + /// + /// The image description. + /// + ImageDescription = 0x010E, + + /// + /// The image height. + /// + ImageHeight = 0x0101, + + /// + /// The image title. + /// + ImageTitle = 0x0320, + + /// + /// The image width. + /// + ImageWidth = 0x0100, + + /// + /// The index background. + /// + IndexBackground = 0x5103, + + /// + /// The index transparent. + /// + IndexTransparent = 0x5104, + + /// + /// The ink names. + /// + InkNames = 0x014D, + + /// + /// The ink set. + /// + InkSet = 0x014C, + + /// + /// The jpegac tables. + /// + JPEGACTables = 0x0209, + + /// + /// The jpegdc tables. + /// + JPEGDCTables = 0x0208, + + /// + /// The jpeg inter format. + /// + JPEGInterFormat = 0x0201, + + /// + /// The jpeg inter length. + /// + JPEGInterLength = 0x0202, + + /// + /// The jpeg lossless predictors. + /// + JPEGLosslessPredictors = 0x0205, + + /// + /// The jpeg point transforms. + /// + JPEGPointTransforms = 0x0206, + + /// + /// The jpeg proc. + /// + JPEGProc = 0x0200, + + /// + /// The jpegq tables. + /// + JPEGQTables = 0x0207, + + /// + /// The jpeg quality. + /// + JPEGQuality = 0x5010, + + /// + /// The jpeg restart interval. + /// + JPEGRestartInterval = 0x0203, + + /// + /// The loop count. + /// + LoopCount = 0x5101, + + /// + /// The luminance table. + /// + LuminanceTable = 0x5090, + + /// + /// The max sample value. + /// + MaxSampleValue = 0x0119, + + /// + /// The min sample value. + /// + MinSampleValue = 0x0118, + + /// + /// The new subfile type. + /// + NewSubfileType = 0x00FE, + + /// + /// The number of inks. + /// + NumberOfInks = 0x014E, + + /// + /// The orientation. + /// + Orientation = 0x0112, + + /// + /// The page name. + /// + PageName = 0x011D, + + /// + /// The page number. + /// + PageNumber = 0x0129, + + /// + /// The palette histogram. + /// + PaletteHistogram = 0x5113, + + /// + /// The photometric interp. + /// + PhotometricInterp = 0x0106, + + /// + /// The pixel per unit x. + /// + PixelPerUnitX = 0x5111, + + /// + /// The pixel per unit y. + /// + PixelPerUnitY = 0x5112, + + /// + /// The pixel unit. + /// + PixelUnit = 0x5110, + + /// + /// The planar config. + /// + PlanarConfig = 0x011C, + + /// + /// The predictor. + /// + Predictor = 0x013D, + + /// + /// The primary chromaticities. + /// + PrimaryChromaticities = 0x013F, + + /// + /// The print flags. + /// + PrintFlags = 0x5005, + + /// + /// The print flags bleed width. + /// + PrintFlagsBleedWidth = 0x5008, + + /// + /// The print flags bleed width scale. + /// + PrintFlagsBleedWidthScale = 0x5009, + + /// + /// The print flags crop. + /// + PrintFlagsCrop = 0x5007, + + /// + /// The print flags version. + /// + PrintFlagsVersion = 0x5006, + + /// + /// The ref black white. + /// + REFBlackWhite = 0x0214, + + /// + /// The resolution unit. + /// + ResolutionUnit = 0x0128, + + /// + /// The resolution x length unit. + /// + ResolutionXLengthUnit = 0x5003, + + /// + /// The resolution x unit. + /// + ResolutionXUnit = 0x5001, + + /// + /// The resolution y length unit. + /// + ResolutionYLengthUnit = 0x5004, + + /// + /// The resolution y unit. + /// + ResolutionYUnit = 0x5002, + + /// + /// The rows per strip. + /// + RowsPerStrip = 0x0116, + + /// + /// The sample format. + /// + SampleFormat = 0x0153, + + /// + /// The samples per pixel. + /// + SamplesPerPixel = 0x0115, + + /// + /// The s max sample value. + /// + SMaxSampleValue = 0x0155, + + /// + /// The s min sample value. + /// + SMinSampleValue = 0x0154, + + /// + /// The software used. + /// + SoftwareUsed = 0x0131, + + /// + /// The srgb rendering intent. + /// + SRGBRenderingIntent = 0x0303, + + /// + /// The strip bytes count. + /// + StripBytesCount = 0x0117, + + /// + /// The strip offsets. + /// + StripOffsets = 0x0111, + + /// + /// The subfile type. + /// + SubfileType = 0x00FF, + + /// + /// The t 4 option. + /// + T4Option = 0x0124, + + /// + /// The t 6 option. + /// + T6Option = 0x0125, + + /// + /// The target printer. + /// + TargetPrinter = 0x0151, + + /// + /// The thresh holding. + /// + ThreshHolding = 0x0107, + + /// + /// The thumbnail artist. + /// + ThumbnailArtist = 0x5034, + + /// + /// The thumbnail bits per sample. + /// + ThumbnailBitsPerSample = 0x5022, + + /// + /// The thumbnail color depth. + /// + ThumbnailColorDepth = 0x5015, + + /// + /// The thumbnail compressed size. + /// + ThumbnailCompressedSize = 0x5019, + + /// + /// The thumbnail compression. + /// + ThumbnailCompression = 0x5023, + + /// + /// The thumbnail copy right. + /// + ThumbnailCopyRight = 0x503B, + + /// + /// The thumbnail data. + /// + ThumbnailData = 0x501B, + + /// + /// The thumbnail date time. + /// + ThumbnailDateTime = 0x5033, + + /// + /// The thumbnail equip make. + /// + ThumbnailEquipMake = 0x5026, + + /// + /// The thumbnail equip model. + /// + ThumbnailEquipModel = 0x5027, + + /// + /// The thumbnail format. + /// + ThumbnailFormat = 0x5012, + + /// + /// The thumbnail height. + /// + ThumbnailHeight = 0x5014, + + /// + /// The thumbnail image description. + /// + ThumbnailImageDescription = 0x5025, + + /// + /// The thumbnail image height. + /// + ThumbnailImageHeight = 0x5021, + + /// + /// The thumbnail image width. + /// + ThumbnailImageWidth = 0x5020, + + /// + /// The thumbnail orientation. + /// + ThumbnailOrientation = 0x5029, + + /// + /// The thumbnail photometric interp. + /// + ThumbnailPhotometricInterp = 0x5024, + + /// + /// The thumbnail planar config. + /// + ThumbnailPlanarConfig = 0x502F, + + /// + /// The thumbnail planes. + /// + ThumbnailPlanes = 0x5016, + + /// + /// The thumbnail primary chromaticities. + /// + ThumbnailPrimaryChromaticities = 0x5036, + + /// + /// The thumbnail raw bytes. + /// + ThumbnailRawBytes = 0x5017, + + /// + /// The thumbnail ref black white. + /// + ThumbnailRefBlackWhite = 0x503A, + + /// + /// The thumbnail resolution unit. + /// + ThumbnailResolutionUnit = 0x5030, + + /// + /// The thumbnail resolution x. + /// + ThumbnailResolutionX = 0x502D, + + /// + /// The thumbnail resolution y. + /// + ThumbnailResolutionY = 0x502E, + + /// + /// The thumbnail rows per strip. + /// + ThumbnailRowsPerStrip = 0x502B, + + /// + /// The thumbnail samples per pixel. + /// + ThumbnailSamplesPerPixel = 0x502A, + + /// + /// The thumbnail size. + /// + ThumbnailSize = 0x5018, + + /// + /// The thumbnail software used. + /// + ThumbnailSoftwareUsed = 0x5032, + + /// + /// The thumbnail strip bytes count. + /// + ThumbnailStripBytesCount = 0x502C, + + /// + /// The thumbnail strip offsets. + /// + ThumbnailStripOffsets = 0x5028, + + /// + /// The thumbnail transfer function. + /// + ThumbnailTransferFunction = 0x5031, + + /// + /// The thumbnail white point. + /// + ThumbnailWhitePoint = 0x5035, + + /// + /// The thumbnail width. + /// + ThumbnailWidth = 0x5013, + + /// + /// The thumbnail y cb cr coefficients. + /// + ThumbnailYCbCrCoefficients = 0x5037, + + /// + /// The thumbnail y cb cr positioning. + /// + ThumbnailYCbCrPositioning = 0x5039, + + /// + /// The thumbnail y cb cr subsampling. + /// + ThumbnailYCbCrSubsampling = 0x5038, + + /// + /// The tile byte counts. + /// + TileByteCounts = 0x0145, + + /// + /// The tile length. + /// + TileLength = 0x0143, + + /// + /// The tile offset. + /// + TileOffset = 0x0144, + + /// + /// The tile width. + /// + TileWidth = 0x0142, + + /// + /// The transfer function. + /// + TransferFunction = 0x012D, + + /// + /// The transfer range. + /// + TransferRange = 0x0156, + + /// + /// The white point. + /// + WhitePoint = 0x013E, + + /// + /// The x position. + /// + XPosition = 0x011E, + + /// + /// The x resolution. + /// + XResolution = 0x011A, + + /// + /// The y cb cr coefficients. + /// + YCbCrCoefficients = 0x0211, + + /// + /// The y cb cr positioning. + /// + YCbCrPositioning = 0x0213, + + /// + /// The y cb cr subsampling. + /// + YCbCrSubsampling = 0x0212, + + /// + /// The y position. + /// + YPosition = 0x011F, + + /// + /// The y resolution. + /// + YResolution = 0x011B + } +} \ No newline at end of file diff --git a/src/ImageProcessor/Imaging/ExifPropertyTagType.cs b/src/ImageProcessor/Imaging/ExifPropertyTagType.cs new file mode 100644 index 000000000..2c3a1b352 --- /dev/null +++ b/src/ImageProcessor/Imaging/ExifPropertyTagType.cs @@ -0,0 +1,58 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) James South. +// Licensed under the Apache License, Version 2.0. +// +// +// Specifies the data type of the values stored in the value data member of that same PropertyItem object. +// +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace ImageProcessor.Imaging +{ + /// + /// Specifies the data type of the values stored in the value data member of that same PropertyItem object. + /// + /// + public enum ExifPropertyTagType : short + { + /// Specifies that the value data member is an array of bytes. + Byte = 1, + + /// + /// Specifies that the value data member is a null-terminated ASCII string. If you set the type data member of a + /// PropertyItem object to ExifPropertyTagTypeASCII, you should set the length data member to the length of the string + /// including the NULL terminator. For example, the string HELLO would have a length of 6. + /// + ASCII = 2, + + /// Specifies that the value data member is an array of unsigned short (16-bit) integers. + Int16 = 3, + + /// Specifies that the value data member is an array of unsigned long (32-bit) integers. + Int32 = 4, + + /// + /// Specifies that the value data member is an array of pairs of unsigned long integers. Each pair represents a + /// fraction; the first integer is the numerator and the second integer is the denominator. + /// + Rational = 5, + + /// + /// Specifies that the value data member is an array of bytes that can hold values of any data type. + /// + Undefined = 7, + + /// + /// Specifies that the value data member is an array of signed long (32-bit) integers. + /// + SLONG = 9, + + /// + /// Specifies that the value data member is an array of pairs of signed long integers. Each pair represents a + /// fraction; the first integer is the numerator and the second integer is the denominator. + /// + SRational = 10 + } +} \ No newline at end of file diff --git a/src/ImageProcessor/Imaging/ImageUtils.cs b/src/ImageProcessor/Imaging/ImageUtils.cs index 3aed64790..7c338a79e 100644 --- a/src/ImageProcessor/Imaging/ImageUtils.cs +++ b/src/ImageProcessor/Imaging/ImageUtils.cs @@ -11,8 +11,12 @@ namespace ImageProcessor.Imaging { #region Using + + using System; using System.Drawing; using System.Drawing.Imaging; + using System.Reflection; + #endregion /// @@ -56,5 +60,19 @@ namespace ImageProcessor.Imaging // ReSharper disable once BitwiseOperatorOnEnumWithoutFlags return (image.PixelFormat & PixelFormat.Indexed) != 0; } + + /// + /// Uses reflection to allow the creation of an instance of . + /// + /// + /// The . + /// + public static PropertyItem CreatePropertyItem() + { + Type type = typeof(PropertyItem); + ConstructorInfo constructor = type.GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public, null, new Type[] { }, null); + + return (PropertyItem)constructor.Invoke(null); + } } } diff --git a/src/ImageProcessor/Settings.StyleCop b/src/ImageProcessor/Settings.StyleCop index 29724f842..ceca99cde 100644 --- a/src/ImageProcessor/Settings.StyleCop +++ b/src/ImageProcessor/Settings.StyleCop @@ -2,7 +2,11 @@ behaviour + chrominance colour + enum + exif + halftoning lomograph octree quantizer