diff --git a/MetadataExtractor.Tests/Formats/Jpeg/JpegMetadataReaderTest.cs b/MetadataExtractor.Tests/Formats/Jpeg/JpegMetadataReaderTest.cs
index d22fc2e40..b5f0359eb 100644
--- a/MetadataExtractor.Tests/Formats/Jpeg/JpegMetadataReaderTest.cs
+++ b/MetadataExtractor.Tests/Formats/Jpeg/JpegMetadataReaderTest.cs
@@ -12,13 +12,11 @@ namespace MetadataExtractor.Tests.Formats.Jpeg
/// Drew Noakes https://drewnoakes.com
public sealed class JpegMetadataReaderTest
{
-#if !NETCOREAPP1_0
[Fact]
public void ExtractMetadataUsingPath()
{
Validate(JpegMetadataReader.ReadMetadata("Data/withExif.jpg"));
}
-#endif
[Fact]
public void ExtractMetadataUsingStream()
diff --git a/MetadataExtractor.Tests/RationalTest.cs b/MetadataExtractor.Tests/RationalTest.cs
index a0c7a03f6..4c9ce6a2d 100644
--- a/MetadataExtractor.Tests/RationalTest.cs
+++ b/MetadataExtractor.Tests/RationalTest.cs
@@ -1,9 +1,7 @@
// Copyright (c) Drew Noakes and contributors. All Rights Reserved. Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
using System;
-#if !NETCOREAPP1_0
using System.ComponentModel;
-#endif
using System.Diagnostics.CodeAnalysis;
using Xunit;
@@ -90,7 +88,6 @@ public void ZeroOverZero()
Assert.True(new Rational(0, 0).IsInteger);
}
-#if !NETCOREAPP1_0
[Fact]
public void TypeConverter()
{
@@ -112,7 +109,6 @@ public void TypeConverter()
Assert.Throws(() => converter.ConvertFrom(null));
}
-#endif
[Fact]
public void IConvertible()
diff --git a/MetadataExtractor.Tests/UseCultureAttribute.cs b/MetadataExtractor.Tests/UseCultureAttribute.cs
index fd5dfa33c..80dbd756c 100644
--- a/MetadataExtractor.Tests/UseCultureAttribute.cs
+++ b/MetadataExtractor.Tests/UseCultureAttribute.cs
@@ -70,13 +70,8 @@ public override void Before(MethodInfo methodUnderTest)
_originalCulture = CultureInfo.CurrentCulture;
_originalUiCulture = CultureInfo.CurrentUICulture;
-#if NETCOREAPP1_0
- CultureInfo.CurrentCulture = Culture;
- CultureInfo.CurrentUICulture = Culture;
-#else
System.Threading.Thread.CurrentThread.CurrentCulture = Culture;
System.Threading.Thread.CurrentThread.CurrentUICulture = Culture;
-#endif
}
///
@@ -86,13 +81,8 @@ public override void Before(MethodInfo methodUnderTest)
/// The method under test
public override void After(MethodInfo methodUnderTest)
{
-#if NETCOREAPP1_0
- CultureInfo.CurrentCulture = _originalCulture;
- CultureInfo.CurrentUICulture = _originalUiCulture;
-#else
System.Threading.Thread.CurrentThread.CurrentCulture = _originalCulture;
System.Threading.Thread.CurrentThread.CurrentUICulture = _originalUiCulture;
-#endif
}
}
}
diff --git a/MetadataExtractor.Tools.FileProcessor/Program.cs b/MetadataExtractor.Tools.FileProcessor/Program.cs
index b22e54276..ac7dfce84 100644
--- a/MetadataExtractor.Tools.FileProcessor/Program.cs
+++ b/MetadataExtractor.Tools.FileProcessor/Program.cs
@@ -26,17 +26,11 @@ internal static class Program
{
private static int Main(string[] args)
{
-#if NETFRAMEWORK
- System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
- System.Threading.Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;
-#else
CultureInfo.CurrentCulture = CultureInfo.InvariantCulture;
CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture;
-#endif
-#if !NET35
CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;
CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.InvariantCulture;
-#endif
+
return ProcessRecursively(args);
// return ProcessFileList(args);
}
diff --git a/MetadataExtractor.Tools.JpegSegmentExtractor/MetadataExtractor.Tools.JpegSegmentExtractor.csproj b/MetadataExtractor.Tools.JpegSegmentExtractor/MetadataExtractor.Tools.JpegSegmentExtractor.csproj
index dd5899fa8..cd21f58de 100644
--- a/MetadataExtractor.Tools.JpegSegmentExtractor/MetadataExtractor.Tools.JpegSegmentExtractor.csproj
+++ b/MetadataExtractor.Tools.JpegSegmentExtractor/MetadataExtractor.Tools.JpegSegmentExtractor.csproj
@@ -1,7 +1,7 @@
- net5.0
+ net5.0
Exe
@@ -9,13 +9,4 @@
-
-
-
-
-
-
-
-
-
diff --git a/MetadataExtractor/Directory.cs b/MetadataExtractor/Directory.cs
index 16adcfb1e..8c48abc57 100644
--- a/MetadataExtractor/Directory.cs
+++ b/MetadataExtractor/Directory.cs
@@ -4,14 +4,6 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
-#if NETSTANDARD1_3 || NETSTANDARD2_0
-using System.Text;
-#endif
-#if NET35
-using DirectoryList = System.Collections.Generic.IList;
-#else
-using DirectoryList = System.Collections.Generic.IReadOnlyList;
-#endif
namespace MetadataExtractor
{
@@ -25,7 +17,7 @@ public abstract class Directory
#if NETSTANDARD2_0
static Directory()
{
- Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
+ System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
}
#endif
@@ -81,13 +73,7 @@ protected virtual bool TryGetTagName(int tagType, [NotNullWhen(returnValue: true
/// Returns all objects that have been set in this .
/// The list of objects.
- public
-#if NET35
- IEnumerable
-#else
- IReadOnlyList
-#endif
- Tags => _definedTagList;
+ public IReadOnlyList Tags => _definedTagList;
/// Returns the number of tags set in this Directory.
/// the number of tags set in this Directory
@@ -113,13 +99,7 @@ protected void SetDescriptor(ITagDescriptor descriptor)
/// Used to iterate over any error messages contained in this directory.
/// The collection of error message strings.
- public
-#if NET35
- IEnumerable
-#else
- IReadOnlyList
-#endif
- Errors => _errorList;
+ public IReadOnlyList Errors => _errorList;
#endregion
diff --git a/MetadataExtractor/DirectoryExtensions.cs b/MetadataExtractor/DirectoryExtensions.cs
index e4428d047..d0a51d13f 100644
--- a/MetadataExtractor/DirectoryExtensions.cs
+++ b/MetadataExtractor/DirectoryExtensions.cs
@@ -945,20 +945,7 @@ public static bool TryGetRational(this Directory directory, int tagType, out Rat
}
if (o is IEnumerable strings)
- {
-#if NET35
- var sb = new StringBuilder();
- foreach (var s in strings)
- {
- if (sb.Length != 0)
- sb.Append(' ');
- sb.Append(s);
- }
- return sb.ToString();
-#else
return string.Join(" ", strings);
-#endif
- }
if (o is double d)
return d.ToString("0.###");
diff --git a/MetadataExtractor/ExifTags.cs b/MetadataExtractor/ExifTags.cs
index 1dc2c6be4..b3008e4df 100644
--- a/MetadataExtractor/ExifTags.cs
+++ b/MetadataExtractor/ExifTags.cs
@@ -9,7 +9,7 @@ namespace MetadataExtractor.NewApi
{
public static class ExifTags
{
- public static readonly TiffStringTag InteropIndex = new TiffStringTag(0x0001, "Interoperability Index", describer: (value, format) =>
+ public static readonly TiffStringTag InteropIndex = new TiffStringTag(0x0001, "Interoperability Index", describer: static (value, _) =>
{
return string.Equals("R98", value.Trim(), StringComparison.OrdinalIgnoreCase)
? "Recommended Exif Interoperability Rules (ExifR98)"
@@ -17,10 +17,10 @@ public static class ExifTags
});
// TODO the element type here is undefined -- may need coercion
- public static readonly TiffUInt16ArrayTag InteropVersion = new TiffUInt16ArrayTag(0x0002, "Interoperability Version", 4, (values, format) => DescribeVersion(values, 2));
+ public static readonly TiffUInt16ArrayTag InteropVersion = new(0x0002, "Interoperability Version", 4, static (values, _) => DescribeVersion(values, 2));
// TODO consider http://www.awaresystems.be/imaging/tiff/tifftags/newsubfiletype.html
- public static readonly TiffIndexedUInt16Tag NewSubfileType = new TiffIndexedUInt16Tag(0x00FE, "New Subfile Type", 1, new[]
+ public static readonly TiffIndexedUInt16Tag NewSubfileType = new(0x00FE, "New Subfile Type", 1, new[]
{
"Full-resolution image",
"Reduced-resolution image",
@@ -31,16 +31,16 @@ public static class ExifTags
"Transparency mask of reduced-resolution multi-page image"
});
- public static readonly TiffIndexedUInt16Tag SubfileType = new TiffIndexedUInt16Tag(0x00FF, "Subfile Type", 1, new[]
+ public static readonly TiffIndexedUInt16Tag SubfileType = new(0x00FF, "Subfile Type", 1, new[]
{
"Full-resolution image",
"Reduced-resolution image",
"Single page of multi-page image"
});
- public static readonly TiffUInt16Tag ImageWidth = new TiffUInt16Tag(0x0100, "Image Width", DescribePixels);
+ public static readonly TiffUInt16Tag ImageWidth = new(0x0100, "Image Width", DescribePixels);
- public static readonly TiffUInt16Tag ImageHeight = new TiffUInt16Tag(0x0101, "Image Height", DescribePixels);
+ public static readonly TiffUInt16Tag ImageHeight = new(0x0101, "Image Height", DescribePixels);
///
/// For uncompressed image data, this value shows the number of bits per component for each pixel.
@@ -48,9 +48,9 @@ public static class ExifTags
///
/// Usually this value is '8,8,8'.
///
- public static readonly TiffUInt16ArrayTag BitsPerSample = new TiffUInt16ArrayTag(0x0102, "Bits Per Sample", expectedCount: 3, describer: (ints, provider) => ints.Length == 3 ? $"{string.Join(",", ints)} bits/component/pixel" : null);
+ public static readonly TiffUInt16ArrayTag BitsPerSample = new(0x0102, "Bits Per Sample", expectedCount: 3, describer: static (ints, _) => ints.Length == 3 ? $"{string.Join(",", ints)} bits/component/pixel" : null);
- public static readonly TiffMappedUInt16Tag Compression = new TiffMappedUInt16Tag(0x0103, "Compression", new Dictionary
+ public static readonly TiffMappedUInt16Tag Compression = new(0x0103, "Compression", new Dictionary
{
{ 1, "Uncompressed" },
{ 2, "CCITT 1D" },
@@ -96,7 +96,7 @@ public static class ExifTags
});
/// Color space of the image data components.
- public static readonly TiffMappedUInt16Tag PhotometricInterpretation = new TiffMappedUInt16Tag(0x0106, "Photometric Interpretation", new Dictionary
+ public static readonly TiffMappedUInt16Tag PhotometricInterpretation = new(0x0106, "Photometric Interpretation", new Dictionary
{
{ 0, "WhiteIsZero" },
{ 1, "BlackIsZero" },
@@ -114,31 +114,31 @@ public static class ExifTags
{ 32892, "Linear Raw" }
});
- public static readonly TiffIndexedUInt16Tag Thresholding = new TiffIndexedUInt16Tag(0x0107, "Thresholding", 1, new[]
+ public static readonly TiffIndexedUInt16Tag Thresholding = new(0x0107, "Thresholding", 1, new[]
{
"No dithering or halftoning",
"Ordered dither or halftone",
"Randomized dither"
});
- public static readonly TiffIndexedUInt16Tag FillOrder = new TiffIndexedUInt16Tag(0x010A, "Fill Order", 1, new[]
+ public static readonly TiffIndexedUInt16Tag FillOrder = new(0x010A, "Fill Order", 1, new[]
{
"Normal",
"Reversed"
});
- public static readonly TiffStringTag DocumentName = new TiffStringTag(0x010D, "Document Name");
+ public static readonly TiffStringTag DocumentName = new(0x010D, "Document Name");
- public static readonly TiffStringTag ImageDescription = new TiffStringTag(0x010E, "Description");
+ public static readonly TiffStringTag ImageDescription = new(0x010E, "Description");
- public static readonly TiffStringTag Make = new TiffStringTag(0x010F, "Make");
+ public static readonly TiffStringTag Make = new(0x010F, "Make");
- public static readonly TiffStringTag Model = new TiffStringTag(0x0110, "Model");
+ public static readonly TiffStringTag Model = new(0x0110, "Model");
/// The position in the file of raster data.
- public static readonly TiffUInt16Tag StripOffsets = new TiffUInt16Tag(0x0111, "Strip Offsets");
+ public static readonly TiffUInt16Tag StripOffsets = new(0x0111, "Strip Offsets");
- public static readonly TiffIndexedUInt16Tag Orientation = new TiffIndexedUInt16Tag(0x0112, "Orientation", 1, new[]
+ public static readonly TiffIndexedUInt16Tag Orientation = new(0x0112, "Orientation", 1, new[]
{
"Top, left side (Horizontal / normal)",
"Top, right side (Mirror horizontal)",
@@ -150,88 +150,88 @@ public static class ExifTags
});
/// Each pixel is composed of this many samples.
- public static readonly TiffUInt16Tag SamplesPerPixel = new TiffUInt16Tag(0x0115, "Samples Per Pixel", (i, p) => string.Format(p, "{0} sample{1}/pixel", i, i == 1 ? "" : "s"));
+ public static readonly TiffUInt16Tag SamplesPerPixel = new(0x0115, "Samples Per Pixel", static (value, format) => string.Format(format, "{0} sample{1}/pixel", value, value == 1 ? "" : "s"));
/// The raster is codified by a single block of data holding this many rows.
- public static readonly TiffUInt16Tag RowsPerStrip = new TiffUInt16Tag(0x0116, "Rows Per Strip", (i, p) => string.Format(p, "{0} row{1}/strip", i, i == 1 ? "" : "s"));
+ public static readonly TiffUInt16Tag RowsPerStrip = new(0x0116, "Rows Per Strip", static (value, format) => string.Format(format, "{0} row{1}/strip", value, value == 1 ? "" : "s"));
/// The size of the raster data in bytes.
- public static readonly TiffUInt16Tag StripByteCounts = new TiffUInt16Tag(0x0117, "Strip Byte Counts", (i, p) => string.Format(p, "{0} byte{1}", i, i == 1 ? "" : "s"));
+ public static readonly TiffUInt16Tag StripByteCounts = new(0x0117, "Strip Byte Counts", static (value, format) => string.Format(format, "{0} byte{1}", value, value == 1 ? "" : "s"));
- public static readonly TiffUInt16Tag MinSampleValue = new TiffUInt16Tag(0x0118, "Minimum Sample Value");
+ public static readonly TiffUInt16Tag MinSampleValue = new(0x0118, "Minimum Sample Value");
- public static readonly TiffUInt16Tag MaxSampleValue = new TiffUInt16Tag(0x0119, "Maximum Sample Value");
+ public static readonly TiffUInt16Tag MaxSampleValue = new(0x0119, "Maximum Sample Value");
- // TODO the descriptor function for these two tags attempts to read ResolutionUnit from the directory, which is not yet available via this new API
- public static readonly TiffUInt16Tag XResolution = new TiffUInt16Tag(0x011A, "X Resolution");
- public static readonly TiffUInt16Tag YResolution = new TiffUInt16Tag(0x011B, "Y Resolution");
+ // TODO the descriptor function for these two tags attempts to read ResolutionUnit from the directory, which is not yet available via this new API -- would need to pass it a way to resolve questions about other values in the same directory, or potentially even in other directories
+ public static readonly TiffUInt16Tag XResolution = new(0x011A, "X Resolution");
+ public static readonly TiffUInt16Tag YResolution = new(0x011B, "Y Resolution");
///
/// When image is uncompressed YCbCr, this value shows byte aligns of YCbCr data.
///
- public static readonly TiffIndexedUInt16Tag PlanarConfiguration = new TiffIndexedUInt16Tag(0x011C, "Planar Configuration", 1, new[]
+ public static readonly TiffIndexedUInt16Tag PlanarConfiguration = new(0x011C, "Planar Configuration", 1, new[]
{
"Chunky (contiguous for each subsampling pixel)",
"Separate (Y-plane/Cb-plane/Cr-plane format)"
});
- public static readonly TiffStringTag PageName = new TiffStringTag(0x011D, "Page Name");
+ public static readonly TiffStringTag PageName = new(0x011D, "Page Name");
- public static readonly TiffIndexedUInt16Tag ResolutionUnit = new TiffIndexedUInt16Tag(0x0128, "Resolution Unit", 1, new[]
+ public static readonly TiffIndexedUInt16Tag ResolutionUnit = new(0x0128, "Resolution Unit", 1, new[]
{
"(No unit)",
"Inch",
"cm"
});
- public static readonly TiffUInt16Tag TransferFunction = new TiffUInt16Tag(0x012D, "Transfer Function");
+ public static readonly TiffUInt16Tag TransferFunction = new(0x012D, "Transfer Function");
- public static readonly TiffStringTag Software = new TiffStringTag(0x0131, "Software");
+ public static readonly TiffStringTag Software = new(0x0131, "Software");
- public static readonly TiffStringTag DateTime = new TiffStringTag(0x0132, "DateTime");
+ public static readonly TiffStringTag DateTime = new(0x0132, "DateTime");
- public static readonly TiffStringTag Artist = new TiffStringTag(0x013B, "Artist");
+ public static readonly TiffStringTag Artist = new(0x013B, "Artist");
- public static readonly TiffStringTag HostComputer = new TiffStringTag(0x013C, "Host Computer");
+ public static readonly TiffStringTag HostComputer = new(0x013C, "Host Computer");
- public static readonly TiffIndexedUInt16Tag Predictor = new TiffIndexedUInt16Tag(0x013D, "Predictor", 1, new []
+ public static readonly TiffIndexedUInt16Tag Predictor = new(0x013D, "Predictor", 1, new []
{
"No prediction scheme used before coding",
"Horizontal differencing",
"Floating point horizontal differencing"
});
- public static readonly TiffURationalArrayTag WhitePoint = new TiffURationalArrayTag(0x013E, "White Point", expectedCount: 2);
+ public static readonly TiffURationalArrayTag WhitePoint = new(0x013E, "White Point", expectedCount: 2);
- public static readonly TiffURationalArrayTag PrimaryChromaticities = new TiffURationalArrayTag(0x013F, "PrimaryChromaticities", expectedCount: 6);
+ public static readonly TiffURationalArrayTag PrimaryChromaticities = new(0x013F, "PrimaryChromaticities", expectedCount: 6);
- public static readonly TiffUInt16Tag TileWidth = new TiffUInt16Tag(0x0142, "Tile Width");
+ public static readonly TiffUInt16Tag TileWidth = new(0x0142, "Tile Width");
- public static readonly TiffUInt16Tag TileLength = new TiffUInt16Tag(0x0143, "Tile Width");
+ public static readonly TiffUInt16Tag TileLength = new(0x0143, "Tile Width");
// TODO is this an array?
- public static readonly TiffUInt16Tag TileOffsets = new TiffUInt16Tag(0x0144, "Tile Offsets");
+ public static readonly TiffUInt16Tag TileOffsets = new(0x0144, "Tile Offsets");
// TODO is this an array?
- public static readonly TiffUInt16Tag TileByteCounts = new TiffUInt16Tag(0x0145, "Tile Byte Counts");
+ public static readonly TiffUInt16Tag TileByteCounts = new(0x0145, "Tile Byte Counts");
// TODO should this be public?
- public static readonly TiffUInt16Tag SubIfdOffset = new TiffUInt16Tag(0x014a, "Sub IFD Offset");
+ public static readonly TiffUInt16Tag SubIfdOffset = new(0x014a, "Sub IFD Offset");
- public static readonly TiffUInt16Tag TransferRange = new TiffUInt16Tag(0x0156, "Transfer Range");
+ public static readonly TiffUInt16Tag TransferRange = new(0x0156, "Transfer Range");
- public static readonly TiffUInt16Tag JpegTables = new TiffUInt16Tag(0x015B, "JPEG Tables");
+ public static readonly TiffUInt16Tag JpegTables = new(0x015B, "JPEG Tables");
- public static readonly TiffMappedUInt16Tag JpegProc = new TiffMappedUInt16Tag(0x0200, "JPEG Proc", new Dictionary
+ public static readonly TiffMappedUInt16Tag JpegProc = new(0x0200, "JPEG Proc", new Dictionary
{
{ 1, "Baseline" },
{ 14, "Lossless" }
});
/// The matrix coefficients used for transformation from RGB to YCbCr image data.
- public static readonly TiffURationalArrayTag YCbCrCoefficients = new TiffURationalArrayTag(0x0211, "YCbCr Coefficients", 3);
+ public static readonly TiffURationalArrayTag YCbCrCoefficients = new(0x0211, "YCbCr Coefficients", 3);
- public static readonly TiffUInt16ArrayTag YCbCrSubsampling = new TiffUInt16ArrayTag(0x0212, "YCbCr Subsampling", 2, (ints, provider) =>
+ public static readonly TiffUInt16ArrayTag YCbCrSubsampling = new(0x0212, "YCbCr Subsampling", 2, (ints, provider) =>
{
if (ints.Length == 2)
{
@@ -243,50 +243,50 @@ public static class ExifTags
return null;
});
- public static readonly TiffIndexedUInt16Tag YCbCrPositioning = new TiffIndexedUInt16Tag(0x0213, "YCbCr Positioning", 1, new[]
+ public static readonly TiffIndexedUInt16Tag YCbCrPositioning = new(0x0213, "YCbCr Positioning", 1, new[]
{
"Center of pixel array",
"Datum point"
});
- public static readonly TiffURationalArrayTag ReferenceBlackWhite = new TiffURationalArrayTag(0x0214, "Reference Black White", 6,
+ public static readonly TiffURationalArrayTag ReferenceBlackWhite = new(0x0214, "Reference Black White", 6,
(values, provider) => values.Length == 6
? string.Format(provider, "[{0},{1},{2}] [{3},{4},{5}]", values[0], values[1], values[2], values[3], values[4], values[5])
: null);
- public static readonly TiffUInt16Tag RelatedImageFileFormat = new TiffUInt16Tag(0x1000, "Related Image File Format");
+ public static readonly TiffUInt16Tag RelatedImageFileFormat = new(0x1000, "Related Image File Format");
- public static readonly TiffUInt16Tag RelatedImageWidth = new TiffUInt16Tag(0x1001, "Related Image Width");
+ public static readonly TiffUInt16Tag RelatedImageWidth = new(0x1001, "Related Image Width");
- public static readonly TiffUInt16Tag RelatedImageHeight = new TiffUInt16Tag(0x1002, "Related Image Height");
+ public static readonly TiffUInt16Tag RelatedImageHeight = new(0x1002, "Related Image Height");
- public static readonly TiffUInt16Tag Rating = new TiffUInt16Tag(0x4746, "Rating");
+ public static readonly TiffUInt16Tag Rating = new(0x4746, "Rating");
- public static readonly TiffUInt16Tag CfaRepeatPatternDim = new TiffUInt16Tag(0x828D, "CFA Repeat Pattern Dim");
+ public static readonly TiffUInt16Tag CfaRepeatPatternDim = new(0x828D, "CFA Repeat Pattern Dim");
/// There are two definitions for CFA pattern, I don't know the difference...
// TODO interpreting this tag requires the value of CfaRepeatPatternDim too
- public static readonly TiffUInt16Tag CfaPattern2 = new TiffUInt16Tag(0x828E, "CFA Pattern 2");
+ public static readonly TiffUInt16Tag CfaPattern2 = new(0x828E, "CFA Pattern 2");
- public static readonly TiffUInt16Tag BatteryLevel = new TiffUInt16Tag(0x828F, "Battery Level");
+ public static readonly TiffUInt16Tag BatteryLevel = new(0x828F, "Battery Level");
- public static readonly TiffStringTag Copyright = new TiffStringTag(0x8298, "Copyright");
+ public static readonly TiffStringTag Copyright = new(0x8298, "Copyright");
/// Exposure time (reciprocal of shutter speed).
/// Unit is second.
- public static readonly TiffURationalTag ExposureTime = new TiffURationalTag(0x829A, "Exposure Time", (value, format) => $"{value.ToSimpleString()} sec");
+ public static readonly TiffURationalTag ExposureTime = new(0x829A, "Exposure Time", (value, format) => $"{value.ToSimpleString()} sec");
/// The actual F-number(F-stop) of lens when the image was taken.
- public static readonly TiffURationalTag FNumber = new TiffURationalTag(0x829D, "F-Number",
+ public static readonly TiffURationalTag FNumber = new(0x829D, "F-Number",
(value, format) => DescribeFStop(PhotographicConversions.ApertureToFStop(value.ToDouble()), format));
// TODO what type is this?
- public static readonly TiffUInt16Tag IptcNaa = new TiffUInt16Tag(0x83BB, "Iptc Naa");
+ public static readonly TiffUInt16Tag IptcNaa = new(0x83BB, "Iptc Naa");
// TODO what type is this?
- public static readonly TiffUInt16Tag InterColorProfile = new TiffUInt16Tag(0x8773, "Inter Color Profile");
+ public static readonly TiffUInt16Tag InterColorProfile = new(0x8773, "Inter Color Profile");
- public static readonly TiffIndexedUInt16Tag ExposureProgram = new TiffIndexedUInt16Tag(0x8822, "Exposure Program", 1, new[]
+ public static readonly TiffIndexedUInt16Tag ExposureProgram = new(0x8822, "Exposure Program", baseIndex: 1, new[]
{
"Manual control",
"Program normal",
@@ -299,10 +299,10 @@ public static class ExifTags
});
// TODO what type is this?
- public static readonly TiffUInt16Tag SpectralSensitivity = new TiffUInt16Tag(0x8824, "Spectral Sensitivity");
+ public static readonly TiffUInt16Tag SpectralSensitivity = new(0x8824, "Spectral Sensitivity");
// TODO what type is this?
- public static readonly TiffUInt16Tag IsoEquivalent = new TiffUInt16Tag(0x8827, "ISO Equivalent");
+ public static readonly TiffUInt16Tag IsoEquivalent = new(0x8827, "ISO Equivalent");
/// Indicates the Opto-Electric Conversion Function (OECF) specified in ISO 14524.
///
@@ -315,16 +315,16 @@ public static class ExifTags
/// - For each cell, an SRATIONAL value.
///
///
- public static readonly TiffUInt16Tag OptoElectricConversionFunction = new TiffUInt16Tag(0x8828, "Opto-Electric Conversion Function");
+ public static readonly TiffUInt16Tag OptoElectricConversionFunction = new(0x8828, "Opto-Electric Conversion Function");
- public static readonly TiffUInt16Tag Interlace = new TiffUInt16Tag(0x8829, "Interlace");
+ public static readonly TiffUInt16Tag Interlace = new(0x8829, "Interlace");
- public static readonly TiffUInt16Tag TimeZoneOffsetTiffEp = new TiffUInt16Tag(0x882A, "Time Zone Offset Tiff EP");
+ public static readonly TiffUInt16Tag TimeZoneOffsetTiffEp = new(0x882A, "Time Zone Offset Tiff EP");
- public static readonly TiffUInt16Tag SelfTimerModeTiffEp = new TiffUInt16Tag(0x882B, "Self Timer Mode Tiff Ep");
+ public static readonly TiffUInt16Tag SelfTimerModeTiffEp = new(0x882B, "Self Timer Mode Tiff Ep");
/// Applies to ISO tag.
- public static readonly TiffIndexedUInt16Tag SensitivityType = new TiffIndexedUInt16Tag(0x8830, "Sensitivity Type", 0, new[]
+ public static readonly TiffIndexedUInt16Tag SensitivityType = new(0x8830, "Sensitivity Type", baseIndex: 0, new[]
{
"Unknown",
"Standard Output Sensitivity",
@@ -336,31 +336,31 @@ public static class ExifTags
"Standard Output Sensitivity, Recommended Exposure Index and ISO Speed"
});
- public static readonly TiffUInt32Tag StandardOutputSensitivity = new TiffUInt32Tag(0x8831, "Standard Output Sensitivity");
+ public static readonly TiffUInt32Tag StandardOutputSensitivity = new(0x8831, "Standard Output Sensitivity");
- public static readonly TiffUInt32Tag RecommendedExposureIndex = new TiffUInt32Tag(0x8832, "Recommended Exposure Index");
+ public static readonly TiffUInt32Tag RecommendedExposureIndex = new(0x8832, "Recommended Exposure Index");
/// Non-standard, but in use.
- public static readonly TiffUInt16Tag TimeZoneOffset = new TiffUInt16Tag(0x882A, "Time Zone Offset");
+ public static readonly TiffUInt16Tag TimeZoneOffset = new(0x882A, "Time Zone Offset");
- public static readonly TiffUInt16Tag SelfTimerMode = new TiffUInt16Tag(0x882B, "Self Timer Mode");
+ public static readonly TiffUInt16Tag SelfTimerMode = new(0x882B, "Self Timer Mode");
// TODO need to convert this, and may need to coerce element values as they're of unspecified type in the spec
- public static readonly TiffUInt16ArrayTag ExifVersion = new TiffUInt16ArrayTag(0x9000, "Exif Version", 4, (value, format) => DescribeVersion(value, 2));
+ public static readonly TiffUInt16ArrayTag ExifVersion = new(0x9000, "Exif Version", 4, (value, _) => DescribeVersion(value, majorDigits: 2));
- public static readonly TiffStringTag DateTimeOriginal = new TiffStringTag(0x9003, "Date Time Original");
+ public static readonly TiffStringTag DateTimeOriginal = new(0x9003, "Date Time Original");
- public static readonly TiffStringTag DateTimeDigitized = new TiffStringTag(0x9004, "Date Time Digitized");
+ public static readonly TiffStringTag DateTimeDigitized = new(0x9004, "Date Time Digitized");
private static readonly string[] _componentsConfigurationElements = { string.Empty, "Y", "Cb", "Cr", "R", "G", "B" };
// TODO this has undefined type in the spec
- public static readonly TiffUInt16ArrayTag ComponentsConfiguration = new TiffUInt16ArrayTag(0x9101, "Components Configuration", 4, (ints, p) =>
+ public static readonly TiffUInt16ArrayTag ComponentsConfiguration = new(0x9101, "Components Configuration", 4, static (value, _) =>
{
var sb = new StringBuilder();
- for (var i = 0; i < Math.Min(4, ints.Length); i++)
+ for (var i = 0; i < Math.Min(4, value.Length); i++)
{
- var j = ints[i];
+ var j = value[i];
if (j > 0 && j < _componentsConfigurationElements.Length)
sb.Append(_componentsConfigurationElements[j]);
}
@@ -369,11 +369,11 @@ public static class ExifTags
// TODO is this URational
/// Average (rough estimate) compression level in JPEG bits per pixel.
- public static readonly TiffRationalTag CompressedAverageBitsPerPixel = new TiffRationalTag(0x9102, "Compressed Average Bits Per Pixel",
+ public static readonly TiffRationalTag CompressedAverageBitsPerPixel = new(0x9102, "Compressed Average Bits Per Pixel",
(r, p) => $"{r.ToSimpleString(provider: p)} bit{(r.IsInteger && r.ToInt32() == 1 ? "" : "s")}/pixel");
/// Shutter speed by APEX value.
- public static readonly TiffSingleTag ShutterSpeed = new TiffSingleTag(0x9201, "Shutter Speed", (apexValue, p) =>
+ public static readonly TiffSingleTag ShutterSpeed = new(0x9201, "Shutter Speed", (apexValue, p) =>
{
// I believe this method to now be stable, but am leaving some alternative snippets of
// code in here, to assist anyone who's looking into this (given that I don't have a public CVS).
@@ -400,22 +400,22 @@ public static class ExifTags
});
/// Lens aperture used in an image.
- public static readonly TiffURationalTag Aperture = new TiffURationalTag(0x9202, "Aperture",
+ public static readonly TiffURationalTag Aperture = new(0x9202, "Aperture",
(value, p) => DescribeFStop(PhotographicConversions.ApertureToFStop(value.ToDouble()), p));
- public static readonly TiffRationalTag BrightnessValue = new TiffRationalTag(0x9203, "Brightness");
+ public static readonly TiffRationalTag BrightnessValue = new(0x9203, "Brightness");
- public static readonly TiffRationalTag ExposureBias = new TiffRationalTag(0x9204, "Exposure Bias", (value, format) => string.Format(format, "{0} EV", value.ToSimpleString()));
+ public static readonly TiffRationalTag ExposureBias = new(0x9204, "Exposure Bias", (value, format) => string.Format(format, "{0} EV", value.ToSimpleString()));
/// Maximum aperture of lens.
- public static readonly TiffRationalTag MaxAperture = new TiffRationalTag(0x9205, "Max Aperture", (value, format) => DescribeFStop(PhotographicConversions.ApertureToFStop(value.ToDouble()), format));
+ public static readonly TiffRationalTag MaxAperture = new(0x9205, "Max Aperture", (value, format) => DescribeFStop(PhotographicConversions.ApertureToFStop(value.ToDouble()), format));
/// The distance autofocus focused to.
/// Tends to be less accurate as distance increases.
- public static readonly TiffRationalTag SubjectDistance = new TiffRationalTag(0x9206, "Subject Distance", (value, format) => $"{value.ToDouble():0.0##} metres");
+ public static readonly TiffRationalTag SubjectDistance = new(0x9206, "Subject Distance", (value, format) => $"{value.ToDouble():0.0##} metres");
/// Exposure metering method.
- public static readonly TiffMappedUInt16Tag MeteringMode = new TiffMappedUInt16Tag(0x9207, "Metering Mode", new Dictionary
+ public static readonly TiffMappedUInt16Tag MeteringMode = new(0x9207, "Metering Mode", new Dictionary
{
{ 0, "Unknown" },
{ 1, "Average" },
@@ -428,7 +428,7 @@ public static class ExifTags
});
/// White balance (aka light source).
- public static readonly TiffMappedUInt16Tag WhiteBalance = new TiffMappedUInt16Tag(0x9208, "White Balance", new Dictionary
+ public static readonly TiffMappedUInt16Tag WhiteBalance = new(0x9208, "White Balance", new Dictionary
{
{ 0, "Unknown" },
{ 1, "Daylight" },
@@ -454,7 +454,7 @@ public static class ExifTags
{ 255, "(Other)" }
});
- public static readonly TiffUInt16Tag Flash = new TiffUInt16Tag(0x9209, "Flash", (value, p) =>
+ public static readonly TiffUInt16Tag Flash = new(0x9209, "Flash", (value, p) =>
{
/*
* This is a bit mask.
@@ -483,40 +483,40 @@ public static class ExifTags
/// Unit is millimeter.
/// Nice digital cameras actually save the focal length as a function of how far they are zoomed in.
///
- public static readonly TiffURationalTag FocalLength = new TiffURationalTag(0x920A, "Focal Length", (rational, provider) => DescribeFocalLength(rational.ToDouble(), provider));
+ public static readonly TiffURationalTag FocalLength = new(0x920A, "Focal Length", (rational, provider) => DescribeFocalLength(rational.ToDouble(), provider));
// TODO what type is this?
- public static readonly TiffUInt16Tag FlashEnergyTiffEp = new TiffUInt16Tag(0x920B, "TIFF/EP Flash Energy");
+ public static readonly TiffUInt16Tag FlashEnergyTiffEp = new(0x920B, "TIFF/EP Flash Energy");
// TODO what type is this?
- public static readonly TiffUInt16Tag SpatialFreqResponseTiffEp = new TiffUInt16Tag(0x920C, "TIFF/EP Spatial Freq Response");
+ public static readonly TiffUInt16Tag SpatialFreqResponseTiffEp = new(0x920C, "TIFF/EP Spatial Freq Response");
// TODO what type is this?
- public static readonly TiffUInt16Tag Noise = new TiffUInt16Tag(0x920D, "Noise");
+ public static readonly TiffUInt16Tag Noise = new(0x920D, "Noise");
// TODO what type is this?
- public static readonly TiffUInt16Tag FocalPlaneXResolutionTiffEp = new TiffUInt16Tag(0x920E, "TIFF/EP Focal Plane X Resolution");
+ public static readonly TiffUInt16Tag FocalPlaneXResolutionTiffEp = new(0x920E, "TIFF/EP Focal Plane X Resolution");
// TODO what type is this?
- public static readonly TiffUInt16Tag FocalPlaneYResolutionTiffEp = new TiffUInt16Tag(0x920F, "TIFF/EP Focal Plane Y Resolution");
+ public static readonly TiffUInt16Tag FocalPlaneYResolutionTiffEp = new(0x920F, "TIFF/EP Focal Plane Y Resolution");
// TODO what type is this?
- public static readonly TiffUInt16Tag ImageNumber = new TiffUInt16Tag(0x9211, "Image Number");
+ public static readonly TiffUInt16Tag ImageNumber = new(0x9211, "Image Number");
// TODO what type is this?
- public static readonly TiffUInt16Tag SecurityClassification = new TiffUInt16Tag(0x9212, "Security Classification");
+ public static readonly TiffUInt16Tag SecurityClassification = new(0x9212, "Security Classification");
// TODO what type is this?
- public static readonly TiffUInt16Tag ImageHistory = new TiffUInt16Tag(0x9213, "Image History");
+ public static readonly TiffUInt16Tag ImageHistory = new(0x9213, "Image History");
// TODO what type is this?
- public static readonly TiffUInt16Tag SubjectLocationTiffEp = new TiffUInt16Tag(0x9214, "TIFF/EP Subject Location");
+ public static readonly TiffUInt16Tag SubjectLocationTiffEp = new(0x9214, "TIFF/EP Subject Location");
// TODO what type is this?
- public static readonly TiffUInt16Tag ExposureIndexTiffEp = new TiffUInt16Tag(0x9215, "TIFF/EP Exposure Index");
+ public static readonly TiffUInt16Tag ExposureIndexTiffEp = new(0x9215, "TIFF/EP Exposure Index");
// TODO what type is this?
- public static readonly TiffUInt16Tag StandardIdTiffEp = new TiffUInt16Tag(0x9216, "TIFF/EP Standard ID");
+ public static readonly TiffUInt16Tag StandardIdTiffEp = new(0x9216, "TIFF/EP Standard ID");
/// This tag holds the Exif Makernote.
///
@@ -529,30 +529,30 @@ public static class ExifTags
// TODO should this be public? probably shouldn't be storing the byte array for makernotes, unless it's unknown (in which case it's in a makernote directory)
public static readonly TiffByteArrayTag Makernote = new TiffByteArrayTag(0x927C, "Makernote");
- public static readonly TiffStringTag UserComment = new TiffStringTag(0x9286, "User Comment", DescribeUserComment);
+ public static readonly TiffStringTag UserComment = new(0x9286, "User Comment", DescribeUserComment);
- public static readonly TiffUInt16Tag SubsecondTime = new TiffUInt16Tag(0x9290, "Subsecond Time");
+ public static readonly TiffUInt16Tag SubsecondTime = new(0x9290, "Subsecond Time");
- public static readonly TiffUInt16Tag SubsecondTimeOriginal = new TiffUInt16Tag(0x9291, "Subsecond Time Original");
+ public static readonly TiffUInt16Tag SubsecondTimeOriginal = new(0x9291, "Subsecond Time Original");
- public static readonly TiffUInt16Tag SubsecondTimeDigitized = new TiffUInt16Tag(0x9292, "Subsecond Time Digitized");
+ public static readonly TiffUInt16Tag SubsecondTimeDigitized = new(0x9292, "Subsecond Time Digitized");
/// The image title, as used by Windows XP.
- public static readonly TiffStringTag WinTitle = new TiffStringTag(0x9C9B, "Windows XP Title", Encoding.Unicode);
+ public static readonly TiffStringTag WinTitle = new(0x9C9B, "Windows XP Title", Encoding.Unicode);
/// The image comment, as used by Windows XP.
- public static readonly TiffStringTag WinComment = new TiffStringTag(0x9C9C, "Windows XP Comment", Encoding.Unicode);
+ public static readonly TiffStringTag WinComment = new(0x9C9C, "Windows XP Comment", Encoding.Unicode);
/// The image author, as used by Windows XP (called Artist in the Windows shell).
- public static readonly TiffStringTag WinAuthor = new TiffStringTag(0x9C9D, "Windows XP Author", Encoding.Unicode);
+ public static readonly TiffStringTag WinAuthor = new(0x9C9D, "Windows XP Author", Encoding.Unicode);
/// The image keywords, as used by Windows XP.
- public static readonly TiffStringTag WinKeywords = new TiffStringTag(0x9C9E, "Windows XP Keywords", Encoding.Unicode);
+ public static readonly TiffStringTag WinKeywords = new(0x9C9E, "Windows XP Keywords", Encoding.Unicode);
/// The image subject, as used by Windows XP.
- public static readonly TiffStringTag WinSubject = new TiffStringTag(0x9C9F, "Windows XP Subject", Encoding.Unicode);
+ public static readonly TiffStringTag WinSubject = new(0x9C9F, "Windows XP Subject", Encoding.Unicode);
- public static readonly TiffUInt16ArrayTag FlashpixVersion = new TiffUInt16ArrayTag(0xA000, "Flashpix Version", expectedCount: 4, describer: (values, p) => DescribeVersion(values, 2));
+ public static readonly TiffUInt16ArrayTag FlashpixVersion = new(0xA000, "Flashpix Version", expectedCount: 4, describer: (values, p) => DescribeVersion(values, 2));
/// Defines Color Space.
///
@@ -560,25 +560,25 @@ public static class ExifTags
/// always '1'. If the picture uses the other color space, value is
/// '65535':Uncalibrated.
///
- public static readonly TiffMappedUInt16Tag ColorSpace = new TiffMappedUInt16Tag(0xA001, "Color Space", new Dictionary
+ public static readonly TiffMappedUInt16Tag ColorSpace = new(0xA001, "Color Space", new Dictionary
{
{ 1, "sRGB" },
{ 65535, "Undefined" }
});
- public static readonly TiffUInt16Tag ExifImageWidth = new TiffUInt16Tag(0xA002, "Exif Image Width", DescribePixels);
+ public static readonly TiffUInt16Tag ExifImageWidth = new(0xA002, "Exif Image Width", DescribePixels);
- public static readonly TiffUInt16Tag ExifImageHeight = new TiffUInt16Tag(0xA003, "Exif Image Height", DescribePixels);
+ public static readonly TiffUInt16Tag ExifImageHeight = new(0xA003, "Exif Image Height", DescribePixels);
- public static readonly TiffUInt16Tag RelatedSoundFile = new TiffUInt16Tag(0xA004, "Related Sound File");
+ public static readonly TiffUInt16Tag RelatedSoundFile = new(0xA004, "Related Sound File");
- public static readonly TiffURationalTag FlashEnergy = new TiffURationalTag(0xA20B, "Flash Energy");
+ public static readonly TiffURationalTag FlashEnergy = new(0xA20B, "Flash Energy");
- public static readonly TiffUInt16Tag SpatialFreqResponse = new TiffUInt16Tag(0xA20C, "Spatial Freq Response");
+ public static readonly TiffUInt16Tag SpatialFreqResponse = new(0xA20C, "Spatial Freq Response");
// TODO the descriptor function for these two tags attempts to read units from the directory, which is not yet available via this new API
- public static readonly TiffURationalTag FocalPlaneXResolution = new TiffURationalTag(0xA20E, "Focal Plane X Resolution");
- public static readonly TiffURationalTag FocalPlaneYResolution = new TiffURationalTag(0xA20F, "Focal Plane Y Resolution");
+ public static readonly TiffURationalTag FocalPlaneXResolution = new(0xA20E, "Focal Plane X Resolution");
+ public static readonly TiffURationalTag FocalPlaneYResolution = new(0xA20F, "Focal Plane Y Resolution");
/// Unit of and .
///
@@ -588,18 +588,18 @@ public static class ExifTags
/// '8.3mm?'(1/3in.?) to their ResolutionUnit. Fuji's BUG? Finepix4900Z has
/// been changed to use value '2' but it doesn't match to actual value also.
///
- public static readonly TiffIndexedUInt16Tag FocalPlaneResolutionUnit = new TiffIndexedUInt16Tag(0xA210, "Focal Plane Resolution Unit", 1, new []
+ public static readonly TiffIndexedUInt16Tag FocalPlaneResolutionUnit = new(0xA210, "Focal Plane Resolution Unit", 1, new []
{
"(No unit)",
"Inches",
"cm"
});
- public static readonly TiffUInt16ArrayTag SubjectLocation = new TiffUInt16ArrayTag(0xA214, "Subject Location", 2);
+ public static readonly TiffUInt16ArrayTag SubjectLocation = new(0xA214, "Subject Location", 2);
- public static readonly TiffURationalTag ExposureIndex = new TiffURationalTag(0xA215, "Exposure Index");
+ public static readonly TiffURationalTag ExposureIndex = new(0xA215, "Exposure Index");
- public static readonly TiffIndexedUInt16Tag SensingMethod = new TiffIndexedUInt16Tag(0xA217, "Sensing Method", 1, new[]
+ public static readonly TiffIndexedUInt16Tag SensingMethod = new(0xA217, "Sensing Method", 1, new[]
{
"(Not defined)",
"One-chip color area sensor",
@@ -611,17 +611,17 @@ public static class ExifTags
"Color sequential linear sensor"
});
- public static readonly TiffIndexedUInt16Tag FileSource = new TiffIndexedUInt16Tag(0xA300, "File Source", 1, new[]
+ public static readonly TiffIndexedUInt16Tag FileSource = new(0xA300, "File Source", 1, new[]
{
"Film Scanner",
"Reflection Print Scanner",
"Digital Still Camera (DSC)"
});
- public static readonly TiffIndexedUInt16Tag SceneType = new TiffIndexedUInt16Tag(0xA301, "Scene Type", 1, new [] { "Directly photographed image" });
+ public static readonly TiffIndexedUInt16Tag SceneType = new(0xA301, "Scene Type", 1, new [] { "Directly photographed image" });
// TODO this is undefined, with any number of components
- public static readonly TiffUInt16Tag CfaPattern = new TiffUInt16Tag(0xA302, "CFA Pattern");
+ public static readonly TiffUInt16Tag CfaPattern = new(0xA302, "CFA Pattern");
///
/// This tag indicates the use of special processing on image data, such as rendering
@@ -631,7 +631,7 @@ public static class ExifTags
/// When special processing is performed, the reader is expected to
/// disable or minimize any further processing.
///
- public static readonly TiffIndexedUInt16Tag CustomRendered = new TiffIndexedUInt16Tag(0xA401, "Custom Rendered", 0, new []
+ public static readonly TiffIndexedUInt16Tag CustomRendered = new(0xA401, "Custom Rendered", 0, new []
{
"Normal process",
"Custom process"
@@ -641,21 +641,21 @@ public static class ExifTags
/// In auto-bracketing mode, the camera shoots a series of frames of the
/// same scene at different exposure settings.
///
- public static readonly TiffIndexedUInt16Tag ExposureMode = new TiffIndexedUInt16Tag(0xA402, "Exposure Mode", 0, new []
+ public static readonly TiffIndexedUInt16Tag ExposureMode = new(0xA402, "Exposure Mode", 0, new []
{
"Auto exposure",
"Manual exposure",
"Auto bracket"
});
- public static readonly TiffIndexedUInt16Tag WhiteBalanceMode = new TiffIndexedUInt16Tag(0xA403, "White Balance Mode", 0, new []
+ public static readonly TiffIndexedUInt16Tag WhiteBalanceMode = new(0xA403, "White Balance Mode", 0, new []
{
"Auto white balance",
"Manual white balance"
});
/// The digital zoom ratio, or zero if digital zoom was not used.
- public static readonly TiffURationalTag DigitalZoomRatio = new TiffURationalTag(0xA404, "Digital Zoom Ratio",
+ public static readonly TiffURationalTag DigitalZoomRatio = new(0xA404, "Digital Zoom Ratio",
(ratio, format) => ratio.Numerator == 0 ? "Digital zoom not used" : ratio.ToSimpleString(provider: format));
///
@@ -663,12 +663,12 @@ public static class ExifTags
/// A value of zero means the focal length is unknown.
///
/// Note that this tag differs from .
- public static readonly TiffUInt16Tag Equivalent35MMFocalLength = new TiffUInt16Tag(0xA405, "35mm Equivalent Focal Length",
+ public static readonly TiffUInt16Tag Equivalent35MMFocalLength = new(0xA405, "35mm Equivalent Focal Length",
(value, format) => value == 0 ? "Unknown" : DescribeFocalLength(value, format));
/// The type of scene that was shot, or the mode in which the image was shot.
/// Note that this differs from .
- public static readonly TiffIndexedUInt16Tag SceneCaptureType = new TiffIndexedUInt16Tag(0xA406, "Scene Capture Type", 0, new []
+ public static readonly TiffIndexedUInt16Tag SceneCaptureType = new(0xA406, "Scene Capture Type", 0, new []
{
"Standard",
"Landscape",
@@ -677,7 +677,7 @@ public static class ExifTags
});
/// The degree of overall image gain adjustment.
- public static readonly TiffIndexedUInt16Tag GainControl = new TiffIndexedUInt16Tag(0xA407, "Gain Control", 0, new []
+ public static readonly TiffIndexedUInt16Tag GainControl = new(0xA407, "Gain Control", 0, new []
{
"None",
"Low gain up",
@@ -687,7 +687,7 @@ public static class ExifTags
});
/// The direction of contrast processing applied by the camera when the image was shot.
- public static readonly TiffIndexedUInt16Tag Contrast = new TiffIndexedUInt16Tag(0xA408, "Contrast", 0, new []
+ public static readonly TiffIndexedUInt16Tag Contrast = new(0xA408, "Contrast", 0, new []
{
"None",
"Soft",
@@ -695,7 +695,7 @@ public static class ExifTags
});
/// The direction of saturation processing applied by the camera when the image was shot.
- public static readonly TiffIndexedUInt16Tag Saturation = new TiffIndexedUInt16Tag(0xA409, "Saturation", 0, new []
+ public static readonly TiffIndexedUInt16Tag Saturation = new(0xA409, "Saturation", 0, new []
{
"None",
"Low saturation",
@@ -703,7 +703,7 @@ public static class ExifTags
});
/// The direction of sharpness processing applied by the camera when the image was shot.
- public static readonly TiffIndexedUInt16Tag Sharpness = new TiffIndexedUInt16Tag(0xA40A, "Sharpness", 0, new []
+ public static readonly TiffIndexedUInt16Tag Sharpness = new(0xA40A, "Sharpness", 0, new []
{
"None",
"Low",
@@ -734,9 +734,9 @@ public static class ExifTags
/// : : :
/// Any UNDEFINED Camera setting-n
///
- public static readonly TiffUInt16Tag DeviceSettingDescription = new TiffUInt16Tag(0xA40B, "Device Setting Description");
+ public static readonly TiffUInt16Tag DeviceSettingDescription = new(0xA40B, "Device Setting Description");
- public static readonly TiffIndexedUInt16Tag SubjectDistanceRange = new TiffIndexedUInt16Tag(0xA40C, "Subject Distance Range", 0, new []
+ public static readonly TiffIndexedUInt16Tag SubjectDistanceRange = new(0xA40C, "Subject Distance Range", 0, new []
{
"Unknown",
"Macro",
@@ -749,11 +749,11 @@ public static class ExifTags
/// It is recorded as an ASCII string equivalent to hexadecimal notation and 128-bit
/// fixed length.
///
- public static readonly TiffStringTag ImageUniqueId = new TiffStringTag(0xA420, "Image Unique ID");
+ public static readonly TiffStringTag ImageUniqueId = new(0xA420, "Image Unique ID");
- public static readonly TiffStringTag CameraOwnerName = new TiffStringTag(0xA430, "Camera Owner Name");
+ public static readonly TiffStringTag CameraOwnerName = new(0xA430, "Camera Owner Name");
- public static readonly TiffStringTag BodySerialNumber = new TiffStringTag(0xA431, "Body Serial Number");
+ public static readonly TiffStringTag BodySerialNumber = new(0xA431, "Body Serial Number");
/// Describes aperture and focal ranges of the lens.
///
@@ -765,7 +765,7 @@ public static class ExifTags
/// - Minimum f-number in the maximum focal length
///
///
- public static readonly TiffURationalArrayTag LensSpecification = new TiffURationalArrayTag(0xA432, "Lens Specification", 4, (values, format) =>
+ public static readonly TiffURationalArrayTag LensSpecification = new(0xA432, "Lens Specification", 4, (values, format) =>
{
if (values.Length != 4 || (values[0].IsZero && values[2].IsZero))
return null;
@@ -791,36 +791,36 @@ public static class ExifTags
return sb.ToString();
});
- public static readonly TiffStringTag LensMake = new TiffStringTag(0xA433, "Lens Make");
+ public static readonly TiffStringTag LensMake = new(0xA433, "Lens Make");
- public static readonly TiffStringTag LensModel = new TiffStringTag(0xA434, "Lens Model");
+ public static readonly TiffStringTag LensModel = new(0xA434, "Lens Model");
- public static readonly TiffStringTag LensSerialNumber = new TiffStringTag(0xA435, "Lens Serial Number");
+ public static readonly TiffStringTag LensSerialNumber = new(0xA435, "Lens Serial Number");
- public static readonly TiffURationalTag Gamma = new TiffURationalTag(0xA500, "Gamma");
+ public static readonly TiffURationalTag Gamma = new(0xA500, "Gamma");
// TODO what type is this?
- public static readonly TiffUInt16Tag PrintIm = new TiffUInt16Tag(0xC4A5, "Print IM");
+ public static readonly TiffUInt16Tag PrintIm = new(0xC4A5, "Print IM");
// TODO what type is this?
- public static readonly TiffUInt16Tag PanasonicTitle = new TiffUInt16Tag(0xC6D2, "Panasonic Title");
+ public static readonly TiffUInt16Tag PanasonicTitle = new(0xC6D2, "Panasonic Title");
// TODO what type is this?
- public static readonly TiffUInt16Tag PanasonicTitle2 = new TiffUInt16Tag(0xC6D3, "Panasonic Title 2");
+ public static readonly TiffUInt16Tag PanasonicTitle2 = new(0xC6D3, "Panasonic Title 2");
// TODO what type is this?
- public static readonly TiffUInt16Tag Padding = new TiffUInt16Tag(0xEA1C, "Padding");
+ public static readonly TiffUInt16Tag Padding = new(0xEA1C, "Padding");
// TODO what type is this?
- public static readonly TiffUInt16Tag Lens = new TiffUInt16Tag(0xFDEA, "Lens");
+ public static readonly TiffUInt16Tag Lens = new(0xFDEA, "Lens");
- private static string DescribeFStop(double fStop, IFormatProvider format) => string.Format(format, "f/{0:0.0}", fStop);
+ private static string DescribeFStop(double fStop, IFormatProvider? format) => string.Format(format, "f/{0:0.0}", fStop);
- private static string DescribeFocalLength(double mm, IFormatProvider format) => string.Format(format, "{0:0.#} mm", mm);
+ private static string DescribeFocalLength(double mm, IFormatProvider? format) => string.Format(format, "{0:0.#} mm", mm);
- private static string DescribePixels(int i, IFormatProvider format) => string.Format(format, "{0} pixel{1}", i, i == 1 ? "" : "s");
+ private static string DescribePixels(int i, IFormatProvider? format) => string.Format(format, "{0} pixel{1}", i, i == 1 ? "" : "s");
- private static string DescribeVersion(IReadOnlyList components, int majorDigits)
+ private static string? DescribeVersion(IReadOnlyList? components, int majorDigits)
{
if (components == null)
return null;
@@ -840,7 +840,7 @@ private static string DescribeVersion(IReadOnlyList components, int majorDi
return version.ToString();
}
- private static string DescribeUserComment(byte[] bytes, IFormatProvider provider)
+ private static string? DescribeUserComment(byte[] bytes)
{
if (bytes.Length == 0)
return string.Empty;
diff --git a/MetadataExtractor/Formats/Avi/AviMetadataReader.cs b/MetadataExtractor/Formats/Avi/AviMetadataReader.cs
index 096d476d8..17ee40302 100644
--- a/MetadataExtractor/Formats/Avi/AviMetadataReader.cs
+++ b/MetadataExtractor/Formats/Avi/AviMetadataReader.cs
@@ -6,12 +6,6 @@
using MetadataExtractor.Formats.Riff;
using MetadataExtractor.IO;
-#if NET35
-using DirectoryList = System.Collections.Generic.IList;
-#else
-using DirectoryList = System.Collections.Generic.IReadOnlyList;
-#endif
-
namespace MetadataExtractor.Formats.Avi
{
/// Obtains metadata from Avi files.
@@ -20,7 +14,7 @@ public static class AviMetadataReader
{
///
///
- public static DirectoryList ReadMetadata(string filePath)
+ public static IReadOnlyList ReadMetadata(string filePath)
{
var directories = new List();
@@ -34,7 +28,7 @@ public static DirectoryList ReadMetadata(string filePath)
///
///
- public static DirectoryList ReadMetadata(Stream stream)
+ public static IReadOnlyList ReadMetadata(Stream stream)
{
var directories = new List();
new RiffReader().ProcessRiff(new SequentialStreamReader(stream), new AviRiffHandler(directories));
diff --git a/MetadataExtractor/Formats/Bmp/BmpMetadataReader.cs b/MetadataExtractor/Formats/Bmp/BmpMetadataReader.cs
index e3fb06db9..4285dc245 100644
--- a/MetadataExtractor/Formats/Bmp/BmpMetadataReader.cs
+++ b/MetadataExtractor/Formats/Bmp/BmpMetadataReader.cs
@@ -6,12 +6,6 @@
using MetadataExtractor.Formats.FileSystem;
using MetadataExtractor.IO;
-#if NET35
-using DirectoryList = System.Collections.Generic.IList;
-#else
-using DirectoryList = System.Collections.Generic.IReadOnlyList;
-#endif
-
namespace MetadataExtractor.Formats.Bmp
{
/// Obtains metadata from BMP files.
@@ -20,7 +14,7 @@ namespace MetadataExtractor.Formats.Bmp
public static class BmpMetadataReader
{
///
- public static DirectoryList ReadMetadata(string filePath)
+ public static IReadOnlyList ReadMetadata(string filePath)
{
var directories = new List(2);
@@ -32,7 +26,7 @@ public static DirectoryList ReadMetadata(string filePath)
return directories;
}
- public static DirectoryList ReadMetadata(Stream stream)
+ public static IReadOnlyList ReadMetadata(Stream stream)
{
return new BmpReader().Extract(new SequentialStreamReader(stream)).ToList();
}
diff --git a/MetadataExtractor/Formats/Bmp/BmpReader.cs b/MetadataExtractor/Formats/Bmp/BmpReader.cs
index e72f7cb93..56ffab392 100644
--- a/MetadataExtractor/Formats/Bmp/BmpReader.cs
+++ b/MetadataExtractor/Formats/Bmp/BmpReader.cs
@@ -7,18 +7,12 @@
using MetadataExtractor.IO;
using MetadataExtractor.Formats.Icc;
-#if NET35
-using DirectoryList = System.Collections.Generic.IList;
-#else
-using DirectoryList = System.Collections.Generic.IReadOnlyList;
-#endif
-
namespace MetadataExtractor.Formats.Bmp
{
/// Drew Noakes https://drewnoakes.com
public sealed class BmpReader
{
- public DirectoryList Extract(SequentialReader reader)
+ public IReadOnlyList Extract(SequentialReader reader)
{
var directories = new List();
reader = reader.WithByteOrder(isMotorolaByteOrder: false);
diff --git a/MetadataExtractor/Formats/Eps/EpsMetadataReader.cs b/MetadataExtractor/Formats/Eps/EpsMetadataReader.cs
index 04611d78c..7ed717908 100644
--- a/MetadataExtractor/Formats/Eps/EpsMetadataReader.cs
+++ b/MetadataExtractor/Formats/Eps/EpsMetadataReader.cs
@@ -4,12 +4,6 @@
using System.IO;
using MetadataExtractor.Formats.FileSystem;
-#if NET35
-using DirectoryList = System.Collections.Generic.IList;
-#else
-using DirectoryList = System.Collections.Generic.IReadOnlyList;
-#endif
-
namespace MetadataExtractor.Formats.Eps
{
/// Obtains metadata from EPS files.
@@ -17,7 +11,7 @@ namespace MetadataExtractor.Formats.Eps
/// Kevin Mott https://github.com/kwhopper
public static class EpsMetadataReader
{
- public static DirectoryList ReadMetadata(string filePath)
+ public static IReadOnlyList ReadMetadata(string filePath)
{
var directories = new List();
@@ -29,7 +23,7 @@ public static DirectoryList ReadMetadata(string filePath)
return directories;
}
- public static DirectoryList ReadMetadata(Stream stream)
+ public static IReadOnlyList ReadMetadata(Stream stream)
{
return new EpsReader().Extract(stream);
}
diff --git a/MetadataExtractor/Formats/Eps/EpsReader.cs b/MetadataExtractor/Formats/Eps/EpsReader.cs
index dc2c63eee..244aea41b 100644
--- a/MetadataExtractor/Formats/Eps/EpsReader.cs
+++ b/MetadataExtractor/Formats/Eps/EpsReader.cs
@@ -10,12 +10,6 @@
using MetadataExtractor.Formats.Xmp;
using MetadataExtractor.IO;
-#if NET35
-using DirectoryList = System.Collections.Generic.IList;
-#else
-using DirectoryList = System.Collections.Generic.IReadOnlyList;
-#endif
-
namespace MetadataExtractor.Formats.Eps
{
/// Reads file passed in through SequentialReader and parses encountered data:
@@ -46,7 +40,7 @@ public sealed class EpsReader
{
private int _previousTag;
- public DirectoryList Extract(Stream inputStream)
+ public IReadOnlyList Extract(Stream inputStream)
{
IndexedReader reader = new IndexedSeekingReader(inputStream);
var directory = new EpsDirectory();
diff --git a/MetadataExtractor/Formats/Exif/ExifReader.cs b/MetadataExtractor/Formats/Exif/ExifReader.cs
index 9839ec089..52bb66cbc 100644
--- a/MetadataExtractor/Formats/Exif/ExifReader.cs
+++ b/MetadataExtractor/Formats/Exif/ExifReader.cs
@@ -7,11 +7,6 @@
using MetadataExtractor.Formats.Tiff;
using MetadataExtractor.IO;
using MetadataExtractor.Util;
-#if NET35
-using DirectoryList = System.Collections.Generic.IList;
-#else
-using DirectoryList = System.Collections.Generic.IReadOnlyList;
-#endif
namespace MetadataExtractor.Formats.Exif
{
@@ -44,7 +39,7 @@ protected override IEnumerable Extract(byte[] segmentBytes, int pream
///
/// Reads TIFF formatted Exif data a specified offset within a .
///
- public DirectoryList Extract(IndexedReader reader)
+ public IReadOnlyList Extract(IndexedReader reader)
{
var directories = new List();
var exifTiffHandler = new ExifTiffHandler(directories);
diff --git a/MetadataExtractor/Formats/Exif/makernotes/PanasonicMakernoteDescriptor.cs b/MetadataExtractor/Formats/Exif/makernotes/PanasonicMakernoteDescriptor.cs
index c0f9dfd6f..0853e02b4 100644
--- a/MetadataExtractor/Formats/Exif/makernotes/PanasonicMakernoteDescriptor.cs
+++ b/MetadataExtractor/Formats/Exif/makernotes/PanasonicMakernoteDescriptor.cs
@@ -540,11 +540,7 @@ public PanasonicMakernoteDescriptor(PanasonicMakernoteDirectory directory)
return null;
var description = string.Join(Environment.NewLine,
- faces.Select((f, i) => $"Face {i + 1}: {f}")
-#if NET35
- .ToArray()
-#endif
- );
+ faces.Select((f, i) => $"Face {i + 1}: {f}"));
return description.Length == 0 ? null : description;
}
diff --git a/MetadataExtractor/Formats/Gif/GifMetadataReader.cs b/MetadataExtractor/Formats/Gif/GifMetadataReader.cs
index 4e36a13c2..46443d814 100644
--- a/MetadataExtractor/Formats/Gif/GifMetadataReader.cs
+++ b/MetadataExtractor/Formats/Gif/GifMetadataReader.cs
@@ -6,12 +6,6 @@
using MetadataExtractor.Formats.FileSystem;
using MetadataExtractor.IO;
-#if NET35
-using DirectoryList = System.Collections.Generic.IList;
-#else
-using DirectoryList = System.Collections.Generic.IReadOnlyList;
-#endif
-
namespace MetadataExtractor.Formats.Gif
{
/// Obtains metadata from GIF files.
@@ -19,7 +13,7 @@ namespace MetadataExtractor.Formats.Gif
public static class GifMetadataReader
{
///
- public static DirectoryList ReadMetadata(string filePath)
+ public static IReadOnlyList ReadMetadata(string filePath)
{
var directories = new List(2);
@@ -31,7 +25,7 @@ public static DirectoryList ReadMetadata(string filePath)
return directories;
}
- public static DirectoryList ReadMetadata(Stream stream)
+ public static IReadOnlyList ReadMetadata(Stream stream)
{
return new GifReader().Extract(new SequentialStreamReader(stream)).ToList();
}
diff --git a/MetadataExtractor/Formats/Gif/GifReader.cs b/MetadataExtractor/Formats/Gif/GifReader.cs
index 427b248e8..1b30a4619 100644
--- a/MetadataExtractor/Formats/Gif/GifReader.cs
+++ b/MetadataExtractor/Formats/Gif/GifReader.cs
@@ -7,12 +7,6 @@
using MetadataExtractor.Formats.Xmp;
using MetadataExtractor.IO;
-#if NET35
-using DirectoryList = System.Collections.Generic.IList;
-#else
-using DirectoryList = System.Collections.Generic.IReadOnlyList;
-#endif
-
namespace MetadataExtractor.Formats.Gif
{
/// Reader of GIF encoded data.
@@ -31,7 +25,7 @@ public sealed class GifReader
private const string Gif87AVersionIdentifier = "87a";
private const string Gif89AVersionIdentifier = "89a";
- public DirectoryList Extract(SequentialReader reader)
+ public IReadOnlyList Extract(SequentialReader reader)
{
reader = reader.WithByteOrder(isMotorolaByteOrder: false);
diff --git a/MetadataExtractor/Formats/Heif/HeifMetadataReader.cs b/MetadataExtractor/Formats/Heif/HeifMetadataReader.cs
index d038c4268..5b9b3951b 100644
--- a/MetadataExtractor/Formats/Heif/HeifMetadataReader.cs
+++ b/MetadataExtractor/Formats/Heif/HeifMetadataReader.cs
@@ -10,11 +10,6 @@
using MetadataExtractor.Formats.QuickTime;
using MetadataExtractor.Formats.Xmp;
using MetadataExtractor.IO;
-#if NET35
-using DirectoryList = System.Collections.Generic.IList;
-#else
-using DirectoryList = System.Collections.Generic.IReadOnlyList;
-#endif
namespace MetadataExtractor.Formats.Heif
{
@@ -24,7 +19,7 @@ public static class HeifMetadataReader
private const int ExifTag = 0x45786966; // "Exif"
private const int MimeTag = 0x6D696D65; // "mime"
- public static DirectoryList ReadMetadata(Stream stream)
+ public static IReadOnlyList ReadMetadata(Stream stream)
{
var directories = new List();
diff --git a/MetadataExtractor/Formats/Icc/IccDescriptor.cs b/MetadataExtractor/Formats/Icc/IccDescriptor.cs
index 01c7b703f..68331a9e7 100644
--- a/MetadataExtractor/Formats/Icc/IccDescriptor.cs
+++ b/MetadataExtractor/Formats/Icc/IccDescriptor.cs
@@ -67,13 +67,11 @@ private enum IccTagType
{
case IccTagType.Text:
{
-#if !NETSTANDARD1_3
try
{
return Encoding.ASCII.GetString(bytes, 8, bytes.Length - 8 - 1);
}
catch
-#endif
{
return Encoding.UTF8.GetString(bytes, 8, bytes.Length - 8 - 1);
}
diff --git a/MetadataExtractor/Formats/Ico/IcoMetadataReader.cs b/MetadataExtractor/Formats/Ico/IcoMetadataReader.cs
index b7774791f..8b84995cd 100644
--- a/MetadataExtractor/Formats/Ico/IcoMetadataReader.cs
+++ b/MetadataExtractor/Formats/Ico/IcoMetadataReader.cs
@@ -5,12 +5,6 @@
using MetadataExtractor.Formats.FileSystem;
using MetadataExtractor.IO;
-#if NET35
-using DirectoryList = System.Collections.Generic.IList;
-#else
-using DirectoryList = System.Collections.Generic.IReadOnlyList;
-#endif
-
namespace MetadataExtractor.Formats.Ico
{
/// Obtains metadata from ICO (Windows Icon) files.
@@ -18,7 +12,7 @@ namespace MetadataExtractor.Formats.Ico
public static class IcoMetadataReader
{
///
- public static DirectoryList ReadMetadata(string filePath)
+ public static IReadOnlyList ReadMetadata(string filePath)
{
var directories = new List();
@@ -30,7 +24,7 @@ public static DirectoryList ReadMetadata(string filePath)
return directories;
}
- public static DirectoryList ReadMetadata(Stream stream)
+ public static IReadOnlyList ReadMetadata(Stream stream)
{
return new IcoReader().Extract(new SequentialStreamReader(stream));
}
diff --git a/MetadataExtractor/Formats/Ico/IcoReader.cs b/MetadataExtractor/Formats/Ico/IcoReader.cs
index d260728d4..4761264e5 100644
--- a/MetadataExtractor/Formats/Ico/IcoReader.cs
+++ b/MetadataExtractor/Formats/Ico/IcoReader.cs
@@ -4,12 +4,6 @@
using System.IO;
using MetadataExtractor.IO;
-#if NET35
-using DirectoryList = System.Collections.Generic.IList;
-#else
-using DirectoryList = System.Collections.Generic.IReadOnlyList;
-#endif
-
namespace MetadataExtractor.Formats.Ico
{
/// Reads ICO (Windows Icon) file metadata.
@@ -21,7 +15,7 @@ namespace MetadataExtractor.Formats.Ico
/// Drew Noakes https://drewnoakes.com
public sealed class IcoReader
{
- public DirectoryList Extract(SequentialReader reader)
+ public IReadOnlyList Extract(SequentialReader reader)
{
var directories = new List();
diff --git a/MetadataExtractor/Formats/Iptc/Iso2022Converter.cs b/MetadataExtractor/Formats/Iptc/Iso2022Converter.cs
index 837206371..4b0cef0ae 100644
--- a/MetadataExtractor/Formats/Iptc/Iso2022Converter.cs
+++ b/MetadataExtractor/Formats/Iptc/Iso2022Converter.cs
@@ -58,11 +58,7 @@ public static class Iso2022Converter
if (ascii)
{
-#if NETSTANDARD1_3
- return Encoding.UTF8;
-#else
return Encoding.ASCII;
-#endif
}
var utf8 = false;
diff --git a/MetadataExtractor/Formats/Iso14496/Box.cs b/MetadataExtractor/Formats/Iso14496/Box.cs
index 14cf33b7f..c4394c4ce 100644
--- a/MetadataExtractor/Formats/Iso14496/Box.cs
+++ b/MetadataExtractor/Formats/Iso14496/Box.cs
@@ -7,12 +7,6 @@ namespace MetadataExtractor.Formats.Iso14496
{
internal class Box
{
-#if NET35 || NET45
- private static readonly Box[] _emptyChildren = new Box[0];
-#else
- private static readonly Box[] _emptyChildren = System.Array.Empty();
-#endif
-
private readonly BoxLocation _location;
public uint Type => _location.Type;
@@ -25,7 +19,7 @@ protected byte[] ReadRemainingData(SequentialReader sr)
return sr.GetBytes((int)((long)NextPosition - sr.Position));
}
- public virtual IEnumerable Children() => _emptyChildren;
+ public virtual IEnumerable Children() => System.Array.Empty();
public override string ToString() => $"{TypeStringConverter.ToTypeString(Type)} @ {_location.NextPosition}";
}
diff --git a/MetadataExtractor/Formats/Iso14496/Boxes/ColorInformationBox.cs b/MetadataExtractor/Formats/Iso14496/Boxes/ColorInformationBox.cs
index 0e0c6f7c1..8ba921c11 100644
--- a/MetadataExtractor/Formats/Iso14496/Boxes/ColorInformationBox.cs
+++ b/MetadataExtractor/Formats/Iso14496/Boxes/ColorInformationBox.cs
@@ -6,12 +6,6 @@ namespace MetadataExtractor.Formats.Iso14496.Boxes
{
internal sealed class ColorInformationBox : Box
{
-#if NET35 || NET45
- private static readonly byte[] _emptyByteArray = new byte[0];
-#else
- private static readonly byte[] _emptyByteArray = System.Array.Empty();
-#endif
-
public const uint NclxTag = 0x6E636C78; // nclx
public const uint RICCTag = 0x72494343; // rICC
public const uint ProfTag = 0x70726F66; // prof
@@ -28,6 +22,7 @@ public ColorInformationBox(BoxLocation location, SequentialReader sr)
{
ColorType = sr.GetUInt32();
+ byte[] emptyByteArray = System.Array.Empty();
switch (ColorType)
{
case NclxTag:
@@ -36,7 +31,7 @@ public ColorInformationBox(BoxLocation location, SequentialReader sr)
TransferCharacteristics = sr.GetUInt16();
MatrixCharacteristics = sr.GetUInt16();
FullRangeFlag = (sr.GetByte() & 128) == 128;
- IccProfile = _emptyByteArray;
+ IccProfile = emptyByteArray;
break;
}
case RICCTag:
@@ -47,7 +42,7 @@ public ColorInformationBox(BoxLocation location, SequentialReader sr)
}
default:
{
- IccProfile = _emptyByteArray;
+ IccProfile = emptyByteArray;
break;
}
}
diff --git a/MetadataExtractor/Formats/Iso14496/Boxes/ItemReferenceBox.cs b/MetadataExtractor/Formats/Iso14496/Boxes/ItemReferenceBox.cs
index fe1413b37..40d1775ef 100644
--- a/MetadataExtractor/Formats/Iso14496/Boxes/ItemReferenceBox.cs
+++ b/MetadataExtractor/Formats/Iso14496/Boxes/ItemReferenceBox.cs
@@ -2,9 +2,6 @@
using System.Collections.Generic;
using MetadataExtractor.IO;
-#if NET35
-using System.Linq;
-#endif
namespace MetadataExtractor.Formats.Iso14496.Boxes
{
@@ -25,10 +22,6 @@ public ItemReferenceBox(BoxLocation location, SequentialReader reader)
Boxes = list;
}
-#if NET35
- public override IEnumerable Children() => Boxes.OfType();
-#else
public override IEnumerable Children() => Boxes;
-#endif
}
}
diff --git a/MetadataExtractor/Formats/Jpeg/JpegComponent.cs b/MetadataExtractor/Formats/Jpeg/JpegComponent.cs
index 796aa2355..64010514b 100644
--- a/MetadataExtractor/Formats/Jpeg/JpegComponent.cs
+++ b/MetadataExtractor/Formats/Jpeg/JpegComponent.cs
@@ -1,8 +1,6 @@
// Copyright (c) Drew Noakes and contributors. All Rights Reserved. Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
-#if !NETSTANDARD1_3
using System;
-#endif
namespace MetadataExtractor.Formats.Jpeg
{
@@ -11,9 +9,7 @@ namespace MetadataExtractor.Formats.Jpeg
/// quantization table number.
///
/// Drew Noakes https://drewnoakes.com
-#if !NETSTANDARD1_3
[Serializable]
-#endif
public sealed class JpegComponent
{
private readonly byte _samplingFactorByte;
diff --git a/MetadataExtractor/Formats/Jpeg/JpegMetadataReader.cs b/MetadataExtractor/Formats/Jpeg/JpegMetadataReader.cs
index ae3400b41..8d105e55f 100644
--- a/MetadataExtractor/Formats/Jpeg/JpegMetadataReader.cs
+++ b/MetadataExtractor/Formats/Jpeg/JpegMetadataReader.cs
@@ -15,12 +15,6 @@
using MetadataExtractor.Formats.Xmp;
using MetadataExtractor.IO;
-#if NET35
-using DirectoryList = System.Collections.Generic.IList;
-#else
-using DirectoryList = System.Collections.Generic.IReadOnlyList;
-#endif
-
namespace MetadataExtractor.Formats.Jpeg
{
/// Obtains all available metadata from JPEG formatted files.
@@ -52,14 +46,14 @@ public static IEnumerable AllReaders
///
///
- public static DirectoryList ReadMetadata(Stream stream, ICollection? readers = null)
+ public static IReadOnlyList ReadMetadata(Stream stream, ICollection? readers = null)
{
return Process(stream, readers);
}
///
///
- public static DirectoryList ReadMetadata(string filePath, ICollection? readers = null)
+ public static IReadOnlyList ReadMetadata(string filePath, ICollection? readers = null)
{
var directories = new List();
@@ -73,7 +67,7 @@ public static DirectoryList ReadMetadata(string filePath, ICollection
///
- public static DirectoryList Process(Stream stream, ICollection? readers = null)
+ public static IReadOnlyList Process(Stream stream, ICollection? readers = null)
{
readers ??= _allReaders;
@@ -87,7 +81,7 @@ public static DirectoryList Process(Stream stream, ICollection readers, ICollection segments)
+ public static IReadOnlyList ProcessJpegSegments(IEnumerable readers, ICollection segments)
{
var directories = new List();
diff --git a/MetadataExtractor/Formats/Jpeg/JpegProcessingException.cs b/MetadataExtractor/Formats/Jpeg/JpegProcessingException.cs
index d3111c2f3..d918364a3 100644
--- a/MetadataExtractor/Formats/Jpeg/JpegProcessingException.cs
+++ b/MetadataExtractor/Formats/Jpeg/JpegProcessingException.cs
@@ -1,17 +1,13 @@
// Copyright (c) Drew Noakes and contributors. All Rights Reserved. Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
using System;
-#if !NETSTANDARD1_3
using System.Runtime.Serialization;
-#endif
namespace MetadataExtractor.Formats.Jpeg
{
/// An exception class thrown upon unexpected and fatal conditions while processing a JPEG file.
/// Drew Noakes https://drewnoakes.com
-#if !NETSTANDARD1_3
[Serializable]
-#endif
public class JpegProcessingException : ImageProcessingException
{
public JpegProcessingException(string? message)
@@ -29,11 +25,9 @@ public JpegProcessingException(Exception? innerException)
{
}
-#if !NETSTANDARD1_3
protected JpegProcessingException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
-#endif
}
}
diff --git a/MetadataExtractor/Formats/Jpeg/JpegSegmentReader.cs b/MetadataExtractor/Formats/Jpeg/JpegSegmentReader.cs
index 1ef9214bc..502c338bc 100644
--- a/MetadataExtractor/Formats/Jpeg/JpegSegmentReader.cs
+++ b/MetadataExtractor/Formats/Jpeg/JpegSegmentReader.cs
@@ -6,12 +6,6 @@
using System.Linq;
using MetadataExtractor.IO;
-#if NET35
-using JpegSegmentList = System.Collections.Generic.IList;
-#else
-using JpegSegmentList = System.Collections.Generic.IReadOnlyList;
-#endif
-
namespace MetadataExtractor.Formats.Jpeg
{
/// Parses the structure of JPEG data, returning contained segments.
@@ -40,7 +34,7 @@ public static class JpegSegmentReader
/// the set of JPEG segments types that are to be returned. If this argument is then all found segment types are returned.
///
///
- public static JpegSegmentList ReadSegments(string filePath, ICollection? segmentTypes = null)
+ public static IReadOnlyList ReadSegments(string filePath, ICollection? segmentTypes = null)
{
using var stream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
return ReadSegments(new SequentialStreamReader(stream), segmentTypes).ToList();
diff --git a/MetadataExtractor/Formats/Jpeg/JpegSegmentType.cs b/MetadataExtractor/Formats/Jpeg/JpegSegmentType.cs
index 913c968bd..d9129420b 100644
--- a/MetadataExtractor/Formats/Jpeg/JpegSegmentType.cs
+++ b/MetadataExtractor/Formats/Jpeg/JpegSegmentType.cs
@@ -227,11 +227,7 @@ public static bool CanContainMetadata(this JpegSegmentType type)
}
/// Gets JPEG segment types that might contain metadata.
-#if NET35
- public static IEnumerable CanContainMetadataTypes { get; }
-#else
public static IReadOnlyList CanContainMetadataTypes { get; }
-#endif
= Enum.GetValues(typeof(JpegSegmentType)).Cast().Where(type => type.CanContainMetadata()).ToList();
/// Gets whether this JPEG segment type's marker is followed by a length indicator.
diff --git a/MetadataExtractor/Formats/Mpeg/Mp3MetadataReader.cs b/MetadataExtractor/Formats/Mpeg/Mp3MetadataReader.cs
index acc0fd06e..fae40720a 100644
--- a/MetadataExtractor/Formats/Mpeg/Mp3MetadataReader.cs
+++ b/MetadataExtractor/Formats/Mpeg/Mp3MetadataReader.cs
@@ -1,18 +1,14 @@
// Copyright (c) Drew Noakes and contributors. All Rights Reserved. Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
+using System.Collections.Generic;
using System.IO;
using MetadataExtractor.IO;
-#if NET35
-using DirectoryList = System.Collections.Generic.IList;
-#else
-using DirectoryList = System.Collections.Generic.IReadOnlyList;
-#endif
namespace MetadataExtractor.Formats.Mpeg
{
public static class Mp3MetadataReader
{
- public static DirectoryList ReadMetadata(Stream stream)
+ public static IReadOnlyList ReadMetadata(Stream stream)
{
return new[] { new Mp3Reader().Extract(new SequentialStreamReader(stream)) };
}
diff --git a/MetadataExtractor/Formats/Netpbm/NetpbmMetadataReader.cs b/MetadataExtractor/Formats/Netpbm/NetpbmMetadataReader.cs
index 58d014272..9a2ab1421 100644
--- a/MetadataExtractor/Formats/Netpbm/NetpbmMetadataReader.cs
+++ b/MetadataExtractor/Formats/Netpbm/NetpbmMetadataReader.cs
@@ -4,12 +4,6 @@
using System.Collections.Generic;
using MetadataExtractor.Formats.FileSystem;
-#if NET35
-using DirectoryList = System.Collections.Generic.IList;
-#else
-using DirectoryList = System.Collections.Generic.IReadOnlyList;
-#endif
-
namespace MetadataExtractor.Formats.Netpbm
{
/// Obtains metadata from BMP files.
@@ -17,7 +11,7 @@ namespace MetadataExtractor.Formats.Netpbm
public static class NetpbmMetadataReader
{
///
- public static DirectoryList ReadMetadata(string filePath)
+ public static IReadOnlyList ReadMetadata(string filePath)
{
var directories = new List(2);
diff --git a/MetadataExtractor/Formats/Pcx/PcxMetadataReader.cs b/MetadataExtractor/Formats/Pcx/PcxMetadataReader.cs
index a79e97dd4..e0002c0f0 100644
--- a/MetadataExtractor/Formats/Pcx/PcxMetadataReader.cs
+++ b/MetadataExtractor/Formats/Pcx/PcxMetadataReader.cs
@@ -5,12 +5,6 @@
using MetadataExtractor.Formats.FileSystem;
using MetadataExtractor.IO;
-#if NET35
-using DirectoryList = System.Collections.Generic.IList;
-#else
-using DirectoryList = System.Collections.Generic.IReadOnlyList;
-#endif
-
namespace MetadataExtractor.Formats.Pcx
{
/// Obtains metadata from PCX image files.
@@ -18,7 +12,7 @@ namespace MetadataExtractor.Formats.Pcx
public static class PcxMetadataReader
{
///
- public static DirectoryList ReadMetadata(string filePath)
+ public static IReadOnlyList ReadMetadata(string filePath)
{
var directories = new List();
diff --git a/MetadataExtractor/Formats/Pcx/PcxReader.cs b/MetadataExtractor/Formats/Pcx/PcxReader.cs
index 02ecb3847..d2af28fa5 100644
--- a/MetadataExtractor/Formats/Pcx/PcxReader.cs
+++ b/MetadataExtractor/Formats/Pcx/PcxReader.cs
@@ -24,14 +24,14 @@ public PcxDirectory Extract(SequentialReader reader)
try
{
- var identifier = reader.GetSByte();
+ var identifier = reader.GetByte();
if (identifier != 0x0A)
throw new ImageProcessingException("Invalid PCX identifier byte");
directory.Set(PcxDirectory.TagVersion, reader.GetSByte());
- var encoding = reader.GetSByte();
+ var encoding = reader.GetByte();
if (encoding != 0x01)
throw new ImageProcessingException("Invalid PCX encoding byte");
diff --git a/MetadataExtractor/Formats/Photoshop/PhotoshopReader.cs b/MetadataExtractor/Formats/Photoshop/PhotoshopReader.cs
index 1d5ad34a4..812f0a354 100644
--- a/MetadataExtractor/Formats/Photoshop/PhotoshopReader.cs
+++ b/MetadataExtractor/Formats/Photoshop/PhotoshopReader.cs
@@ -11,12 +11,6 @@
using MetadataExtractor.Formats.Xmp;
using MetadataExtractor.IO;
-#if NET35
-using DirectoryList = System.Collections.Generic.IList;
-#else
-using DirectoryList = System.Collections.Generic.IReadOnlyList;
-#endif
-
namespace MetadataExtractor.Formats.Photoshop
{
/// Reads metadata created by Photoshop and stored in the APPD segment of JPEG files.
@@ -47,7 +41,7 @@ protected override IEnumerable Extract(byte[] segmentBytes, int pream
return Enumerable.Empty();
}
- public DirectoryList Extract(SequentialReader reader, int length)
+ public IReadOnlyList Extract(SequentialReader reader, int length)
{
var directory = new PhotoshopDirectory();
diff --git a/MetadataExtractor/Formats/Photoshop/PsdMetadataReader.cs b/MetadataExtractor/Formats/Photoshop/PsdMetadataReader.cs
index ef0f5603f..ef772fdeb 100644
--- a/MetadataExtractor/Formats/Photoshop/PsdMetadataReader.cs
+++ b/MetadataExtractor/Formats/Photoshop/PsdMetadataReader.cs
@@ -5,12 +5,6 @@
using MetadataExtractor.Formats.FileSystem;
using MetadataExtractor.IO;
-#if NET35
-using DirectoryList = System.Collections.Generic.IList;
-#else
-using DirectoryList = System.Collections.Generic.IReadOnlyList;
-#endif
-
namespace MetadataExtractor.Formats.Photoshop
{
/// Obtains metadata from Photoshop's PSD files.
@@ -18,7 +12,7 @@ namespace MetadataExtractor.Formats.Photoshop
public static class PsdMetadataReader
{
///
- public static DirectoryList ReadMetadata(string filePath)
+ public static IReadOnlyList ReadMetadata(string filePath)
{
var directories = new List();
@@ -30,7 +24,7 @@ public static DirectoryList ReadMetadata(string filePath)
return directories;
}
- public static DirectoryList ReadMetadata(Stream stream)
+ public static IReadOnlyList ReadMetadata(Stream stream)
{
return new PsdReader().Extract(new SequentialStreamReader(stream));
}
diff --git a/MetadataExtractor/Formats/Photoshop/PsdReader.cs b/MetadataExtractor/Formats/Photoshop/PsdReader.cs
index 12f6d4116..088bb299f 100644
--- a/MetadataExtractor/Formats/Photoshop/PsdReader.cs
+++ b/MetadataExtractor/Formats/Photoshop/PsdReader.cs
@@ -3,11 +3,6 @@
using System.Collections.Generic;
using System.IO;
using MetadataExtractor.IO;
-#if NET35
-using DirectoryList = System.Collections.Generic.IList;
-#else
-using DirectoryList = System.Collections.Generic.IReadOnlyList;
-#endif
namespace MetadataExtractor.Formats.Photoshop
{
@@ -15,7 +10,7 @@ namespace MetadataExtractor.Formats.Photoshop
/// Drew Noakes https://drewnoakes.com
public sealed class PsdReader
{
- public DirectoryList Extract(SequentialReader reader)
+ public IReadOnlyList Extract(SequentialReader reader)
{
var directory = new PsdHeaderDirectory();
diff --git a/MetadataExtractor/Formats/Png/PngColorType.cs b/MetadataExtractor/Formats/Png/PngColorType.cs
index 9d3709efe..2e4d526d3 100644
--- a/MetadataExtractor/Formats/Png/PngColorType.cs
+++ b/MetadataExtractor/Formats/Png/PngColorType.cs
@@ -1,16 +1,12 @@
// Copyright (c) Drew Noakes and contributors. All Rights Reserved. Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
-#if !NETSTANDARD1_3
using System;
-#endif
using System.Linq;
namespace MetadataExtractor.Formats.Png
{
/// Drew Noakes https://drewnoakes.com
-#if !NETSTANDARD1_3
[Serializable]
-#endif
public sealed class PngColorType
{
/// Each pixel is a greyscale sample.
diff --git a/MetadataExtractor/Formats/Png/PngDescriptor.cs b/MetadataExtractor/Formats/Png/PngDescriptor.cs
index ab679e4d9..0964d24da 100644
--- a/MetadataExtractor/Formats/Png/PngDescriptor.cs
+++ b/MetadataExtractor/Formats/Png/PngDescriptor.cs
@@ -87,11 +87,7 @@ public PngDescriptor(PngDirectory directory)
? null
: string.Join(
"\n",
- pairs.Select(kv => $"{kv.Key}: {kv.Value}")
-#if NET35
- .ToArray()
-#endif
- );
+ pairs.Select(kv => $"{kv.Key}: {kv.Value}"));
}
public string? GetBackgroundColorDescription()
diff --git a/MetadataExtractor/Formats/Png/PngMetadataReader.cs b/MetadataExtractor/Formats/Png/PngMetadataReader.cs
index 90fcfed0c..8adc10ada 100644
--- a/MetadataExtractor/Formats/Png/PngMetadataReader.cs
+++ b/MetadataExtractor/Formats/Png/PngMetadataReader.cs
@@ -17,12 +17,6 @@
using MetadataExtractor.IO;
using MetadataExtractor.Util;
-#if NET35
-using DirectoryList = System.Collections.Generic.IList;
-#else
-using DirectoryList = System.Collections.Generic.IReadOnlyList;
-#endif
-
namespace MetadataExtractor.Formats.Png
{
/// Drew Noakes https://drewnoakes.com
@@ -49,7 +43,7 @@ public static class PngMetadataReader
///
///
- public static DirectoryList ReadMetadata(string filePath)
+ public static IReadOnlyList ReadMetadata(string filePath)
{
var directories = new List();
@@ -63,7 +57,7 @@ public static DirectoryList ReadMetadata(string filePath)
///
///
- public static DirectoryList ReadMetadata(Stream stream)
+ public static IReadOnlyList ReadMetadata(Stream stream)
{
List? directories = null;
@@ -83,7 +77,7 @@ public static DirectoryList ReadMetadata(Stream stream)
}
}
- return directories ?? (DirectoryList)Array.Empty();
+ return directories ?? (IReadOnlyList)Array.Empty();
}
///
@@ -588,16 +582,7 @@ private static bool TryDeflate(
try
{
var ms = new MemoryStream();
-
-#if !NET35
inflaterStream.CopyTo(ms);
-#else
- var buffer = new byte[1024];
- int count;
- while ((count = inflaterStream.Read(buffer, 0, 256)) > 0)
- ms.Write(buffer, 0, count);
-#endif
-
textBytes = ms.ToArray();
}
catch (Exception ex)
diff --git a/MetadataExtractor/Formats/Png/PngProcessingException.cs b/MetadataExtractor/Formats/Png/PngProcessingException.cs
index 8e3e158ed..34efcf045 100644
--- a/MetadataExtractor/Formats/Png/PngProcessingException.cs
+++ b/MetadataExtractor/Formats/Png/PngProcessingException.cs
@@ -1,17 +1,13 @@
// Copyright (c) Drew Noakes and contributors. All Rights Reserved. Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
using System;
-#if !NETSTANDARD1_3
using System.Runtime.Serialization;
-#endif
namespace MetadataExtractor.Formats.Png
{
/// An exception class thrown upon unexpected and fatal conditions while processing a JPEG file.
/// Drew Noakes https://drewnoakes.com
-#if !NETSTANDARD1_3
[Serializable]
-#endif
public class PngProcessingException : ImageProcessingException
{
public PngProcessingException(string? message)
@@ -29,11 +25,9 @@ public PngProcessingException(Exception? innerException)
{
}
-#if !NETSTANDARD1_3
protected PngProcessingException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
-#endif
}
}
diff --git a/MetadataExtractor/Formats/QuickTime/QuickTimeMetadataReader.cs b/MetadataExtractor/Formats/QuickTime/QuickTimeMetadataReader.cs
index 036645292..e0350f45b 100644
--- a/MetadataExtractor/Formats/QuickTime/QuickTimeMetadataReader.cs
+++ b/MetadataExtractor/Formats/QuickTime/QuickTimeMetadataReader.cs
@@ -11,11 +11,6 @@
using MetadataExtractor.Formats.Xmp;
using MetadataExtractor.IO;
using MetadataExtractor.Util;
-#if NET35
-using DirectoryList = System.Collections.Generic.IList;
-#else
-using DirectoryList = System.Collections.Generic.IReadOnlyList;
-#endif
#pragma warning disable CS8602 // Dereference of a possibly null reference
#pragma warning disable CS8604 // Dereference of a possibly null reference
@@ -27,7 +22,7 @@ public static class QuickTimeMetadataReader
private static readonly DateTime _epoch = new(1904, 1, 1);
private static readonly int[] _supportedAtomValueTypes = { 1, 13, 14, 23, 27 };
- public static DirectoryList ReadMetadata(Stream stream)
+ public static IReadOnlyList ReadMetadata(Stream stream)
{
var directories = new List();
var metaDataKeys = new List();
diff --git a/MetadataExtractor/Formats/QuickTime/QuickTimeReader.cs b/MetadataExtractor/Formats/QuickTime/QuickTimeReader.cs
index 4603a7791..d3870781c 100644
--- a/MetadataExtractor/Formats/QuickTime/QuickTimeReader.cs
+++ b/MetadataExtractor/Formats/QuickTime/QuickTimeReader.cs
@@ -61,13 +61,10 @@ public string TypeString
{
get
{
+ // TODO do this with fewer allocations (cache value?)
var bytes = BitConverter.GetBytes(Type);
Array.Reverse(bytes);
-#if NETSTANDARD1_3
- return Encoding.UTF8.GetString(bytes, 0, bytes.Length);
-#else
return Encoding.ASCII.GetString(bytes);
-#endif
}
}
diff --git a/MetadataExtractor/Formats/Raf/RafMetadataReader.cs b/MetadataExtractor/Formats/Raf/RafMetadataReader.cs
index fad8dea4a..8f3db6620 100644
--- a/MetadataExtractor/Formats/Raf/RafMetadataReader.cs
+++ b/MetadataExtractor/Formats/Raf/RafMetadataReader.cs
@@ -1,15 +1,10 @@
// Copyright (c) Drew Noakes and contributors. All Rights Reserved. Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
using System;
+using System.Collections.Generic;
using System.IO;
using MetadataExtractor.Formats.Jpeg;
-#if NET35
-using DirectoryList = System.Collections.Generic.IList;
-#else
-using DirectoryList = System.Collections.Generic.IReadOnlyList;
-#endif
-
namespace MetadataExtractor.Formats.Raf
{
/// Obtains metadata from RAF (Fujifilm camera raw) image files.
@@ -17,7 +12,7 @@ namespace MetadataExtractor.Formats.Raf
/// Drew Noakes https://drewnoakes.com
public static class RafMetadataReader
{
- public static DirectoryList ReadMetadata(Stream stream)
+ public static IReadOnlyList ReadMetadata(Stream stream)
{
if (!stream.CanSeek)
throw new ArgumentException("Must support seek", nameof(stream));
diff --git a/MetadataExtractor/Formats/Riff/RiffProcessingException.cs b/MetadataExtractor/Formats/Riff/RiffProcessingException.cs
index 350815578..281c9c983 100644
--- a/MetadataExtractor/Formats/Riff/RiffProcessingException.cs
+++ b/MetadataExtractor/Formats/Riff/RiffProcessingException.cs
@@ -1,17 +1,13 @@
// Copyright (c) Drew Noakes and contributors. All Rights Reserved. Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
using System;
-#if !NETSTANDARD1_3
using System.Runtime.Serialization;
-#endif
namespace MetadataExtractor.Formats.Riff
{
/// An exception class thrown upon unexpected and fatal conditions while processing a RIFF file.
/// Drew Noakes https://drewnoakes.com
-#if !NETSTANDARD1_3
[Serializable]
-#endif
public class RiffProcessingException : ImageProcessingException
{
public RiffProcessingException(string? message)
@@ -29,11 +25,9 @@ public RiffProcessingException(Exception? innerException)
{
}
-#if !NETSTANDARD1_3
protected RiffProcessingException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
-#endif
}
}
diff --git a/MetadataExtractor/Formats/Tga/TgaMetadataReader.cs b/MetadataExtractor/Formats/Tga/TgaMetadataReader.cs
index 594cb7490..e8d7eee06 100644
--- a/MetadataExtractor/Formats/Tga/TgaMetadataReader.cs
+++ b/MetadataExtractor/Formats/Tga/TgaMetadataReader.cs
@@ -5,12 +5,6 @@
using System.IO;
using MetadataExtractor.Formats.FileSystem;
-#if NET35
-using DirectoryList = System.Collections.Generic.IList;
-#else
-using DirectoryList = System.Collections.Generic.IReadOnlyList;
-#endif
-
namespace MetadataExtractor.Formats.Tga
{
/// Obtains metadata from TGA (Truevision) files.
@@ -19,7 +13,7 @@ public static class TgaMetadataReader
{
///
///
- public static DirectoryList ReadMetadata(string filePath)
+ public static IReadOnlyList ReadMetadata(string filePath)
{
var directories = new List();
@@ -33,7 +27,7 @@ public static DirectoryList ReadMetadata(string filePath)
///
///
- public static DirectoryList ReadMetadata(Stream stream)
+ public static IReadOnlyList ReadMetadata(Stream stream)
{
if (!stream.CanSeek)
throw new ArgumentException("Must support seek", nameof(stream));
diff --git a/MetadataExtractor/Formats/Tiff/TiffMetadataReader.cs b/MetadataExtractor/Formats/Tiff/TiffMetadataReader.cs
index ae45f02cd..0efd53c54 100644
--- a/MetadataExtractor/Formats/Tiff/TiffMetadataReader.cs
+++ b/MetadataExtractor/Formats/Tiff/TiffMetadataReader.cs
@@ -6,12 +6,6 @@
using MetadataExtractor.Formats.FileSystem;
using MetadataExtractor.IO;
-#if NET35
-using DirectoryList = System.Collections.Generic.IList;
-#else
-using DirectoryList = System.Collections.Generic.IReadOnlyList;
-#endif
-
namespace MetadataExtractor.Formats.Tiff
{
/// Obtains all available metadata from TIFF formatted files.
@@ -25,7 +19,7 @@ public static class TiffMetadataReader
{
///
///
- public static DirectoryList ReadMetadata(string filePath)
+ public static IReadOnlyList ReadMetadata(string filePath)
{
var directories = new List();
@@ -42,7 +36,7 @@ public static DirectoryList ReadMetadata(string filePath)
///
///
- public static DirectoryList ReadMetadata(Stream stream)
+ public static IReadOnlyList ReadMetadata(Stream stream)
{
// TIFF processing requires random access, as directories can be scattered throughout the byte sequence.
// Stream does not support seeking backwards, so we wrap it with IndexedCapturingReader, which
diff --git a/MetadataExtractor/Formats/Tiff/TiffProcessingException.cs b/MetadataExtractor/Formats/Tiff/TiffProcessingException.cs
index 3b65e0ac6..bd1a6c909 100644
--- a/MetadataExtractor/Formats/Tiff/TiffProcessingException.cs
+++ b/MetadataExtractor/Formats/Tiff/TiffProcessingException.cs
@@ -1,18 +1,14 @@
// Copyright (c) Drew Noakes and contributors. All Rights Reserved. Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
using System;
-#if !NETSTANDARD1_3
using System.Runtime.Serialization;
-#endif
namespace MetadataExtractor.Formats.Tiff
{
/// An exception class thrown upon unexpected and fatal conditions while processing a TIFF file.
/// Drew Noakes https://drewnoakes.com
/// Darren Salomons
-#if !NETSTANDARD1_3
[Serializable]
-#endif
public class TiffProcessingException : ImageProcessingException
{
public TiffProcessingException(string? message)
@@ -30,11 +26,9 @@ public TiffProcessingException(Exception? innerException)
{
}
-#if !NETSTANDARD1_3
protected TiffProcessingException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
-#endif
}
}
diff --git a/MetadataExtractor/Formats/Wav/WavFormatDescriptor.cs b/MetadataExtractor/Formats/Wav/WavFormatDescriptor.cs
index 85eb0eecc..b1cfb3ce6 100644
--- a/MetadataExtractor/Formats/Wav/WavFormatDescriptor.cs
+++ b/MetadataExtractor/Formats/Wav/WavFormatDescriptor.cs
@@ -11,12 +11,6 @@ namespace MetadataExtractor.Formats.Wav
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
public sealed class WavFormatDescriptor : TagDescriptor
{
-#if NET35 || NET45
- private static readonly byte[] _emptyByteArray = new byte[0];
-#else
- private static readonly byte[] _emptyByteArray = Array.Empty();
-#endif
-
public WavFormatDescriptor(WavFormatDirectory directory)
: base(directory)
{
@@ -29,7 +23,7 @@ public WavFormatDescriptor(WavFormatDirectory directory)
TagFormat => GetFormatDescription(),
TagSamplesPerSec => Directory.GetUInt32(tag).ToString("0 bps"),
TagBytesPerSec => Directory.GetUInt32(tag).ToString("0 bps"),
- TagSubformat => BitConverter.ToString(Directory.GetByteArray(tag) ?? _emptyByteArray).Replace("-", ""),
+ TagSubformat => BitConverter.ToString(Directory.GetByteArray(tag) ?? Array.Empty()).Replace("-", ""),
_ => base.GetDescription(tag),
};
}
diff --git a/MetadataExtractor/Formats/Wav/WavMetadataReader.cs b/MetadataExtractor/Formats/Wav/WavMetadataReader.cs
index 760f18451..3f57bdf1b 100644
--- a/MetadataExtractor/Formats/Wav/WavMetadataReader.cs
+++ b/MetadataExtractor/Formats/Wav/WavMetadataReader.cs
@@ -6,12 +6,6 @@
using MetadataExtractor.Formats.Riff;
using MetadataExtractor.IO;
-#if NET35
-using DirectoryList = System.Collections.Generic.IList;
-#else
-using DirectoryList = System.Collections.Generic.IReadOnlyList;
-#endif
-
namespace MetadataExtractor.Formats.Wav
{
/// Obtains metadata from WAV files.
@@ -20,7 +14,7 @@ public static class WavMetadataReader
{
///
///
- public static DirectoryList ReadMetadata(string filePath)
+ public static IReadOnlyList ReadMetadata(string filePath)
{
var directories = new List();
@@ -34,7 +28,7 @@ public static DirectoryList ReadMetadata(string filePath)
///
///
- public static DirectoryList ReadMetadata(Stream stream)
+ public static IReadOnlyList ReadMetadata(Stream stream)
{
var directories = new List();
new RiffReader().ProcessRiff(new SequentialStreamReader(stream), new WavRiffHandler(directories));
diff --git a/MetadataExtractor/Formats/WebP/WebPMetadataReader.cs b/MetadataExtractor/Formats/WebP/WebPMetadataReader.cs
index 9379cee04..bafa7b8c0 100644
--- a/MetadataExtractor/Formats/WebP/WebPMetadataReader.cs
+++ b/MetadataExtractor/Formats/WebP/WebPMetadataReader.cs
@@ -6,12 +6,6 @@
using MetadataExtractor.Formats.Riff;
using MetadataExtractor.IO;
-#if NET35
-using DirectoryList = System.Collections.Generic.IList;
-#else
-using DirectoryList = System.Collections.Generic.IReadOnlyList;
-#endif
-
namespace MetadataExtractor.Formats.WebP
{
/// Obtains metadata from WebP files.
@@ -20,7 +14,7 @@ public static class WebPMetadataReader
{
///
///
- public static DirectoryList ReadMetadata(string filePath)
+ public static IReadOnlyList ReadMetadata(string filePath)
{
var directories = new List();
@@ -34,7 +28,7 @@ public static DirectoryList ReadMetadata(string filePath)
///
///
- public static DirectoryList ReadMetadata(Stream stream)
+ public static IReadOnlyList ReadMetadata(Stream stream)
{
var directories = new List();
new RiffReader().ProcessRiff(new SequentialStreamReader(stream), new WebPRiffHandler(directories));
diff --git a/MetadataExtractor/IO/BufferBoundsException.cs b/MetadataExtractor/IO/BufferBoundsException.cs
index 0e0087e8d..247281312 100644
--- a/MetadataExtractor/IO/BufferBoundsException.cs
+++ b/MetadataExtractor/IO/BufferBoundsException.cs
@@ -1,10 +1,8 @@
// Copyright (c) Drew Noakes and contributors. All Rights Reserved. Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
using System.IO;
-#if !NETSTANDARD1_3
using System;
using System.Runtime.Serialization;
-#endif
namespace MetadataExtractor.IO
{
@@ -12,9 +10,7 @@ namespace MetadataExtractor.IO
/// Thrown when the index provided to an is invalid.
///
/// Drew Noakes https://drewnoakes.com
-#if !NETSTANDARD1_3
[Serializable]
-#endif
public class BufferBoundsException : IOException
{
public BufferBoundsException(int index, int bytesRequested, long bufferLength)
@@ -45,11 +41,9 @@ private static string GetMessage(int index, int bytesRequested, long bufferLengt
return $"Attempt to read from beyond end of underlying data source (requested index: {index}, requested count: {bytesRequested}, max index: {bufferLength - 1})";
}
-#if !NETSTANDARD1_3
protected BufferBoundsException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
-#endif
}
}
diff --git a/MetadataExtractor/ImageMetadataReader.cs b/MetadataExtractor/ImageMetadataReader.cs
index 05aad879c..a051cb273 100644
--- a/MetadataExtractor/ImageMetadataReader.cs
+++ b/MetadataExtractor/ImageMetadataReader.cs
@@ -25,12 +25,6 @@
using MetadataExtractor.Formats.WebP;
using MetadataExtractor.Util;
-#if NET35
-using DirectoryList = System.Collections.Generic.IList;
-#else
-using DirectoryList = System.Collections.Generic.IReadOnlyList;
-#endif
-
// ReSharper disable RedundantCaseLabel
namespace MetadataExtractor
@@ -70,7 +64,7 @@ public static class ImageMetadataReader
/// A list of instances containing the various types of metadata found within the file's data.
/// The file type is unknown, or processing errors occurred.
///
- public static DirectoryList ReadMetadata(Stream stream)
+ public static IReadOnlyList ReadMetadata(Stream stream)
{
var fileType = FileTypeDetector.DetectFileType(stream);
@@ -123,7 +117,7 @@ public static DirectoryList ReadMetadata(Stream stream)
/// A list of instances containing the various types of metadata found within the file's data.
/// The file type is unknown, or processing errors occurred.
///
- public static DirectoryList ReadMetadata(string filePath)
+ public static IReadOnlyList ReadMetadata(string filePath)
{
var directories = new List();
diff --git a/MetadataExtractor/ImageProcessingException.cs b/MetadataExtractor/ImageProcessingException.cs
index 5b175b45a..5b2be01d9 100644
--- a/MetadataExtractor/ImageProcessingException.cs
+++ b/MetadataExtractor/ImageProcessingException.cs
@@ -1,17 +1,13 @@
// Copyright (c) Drew Noakes and contributors. All Rights Reserved. Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
using System;
-#if !NETSTANDARD1_3
using System.Runtime.Serialization;
-#endif
namespace MetadataExtractor
{
/// An exception class thrown upon an unexpected condition that was fatal for the processing of an image.
/// Drew Noakes https://drewnoakes.com
-#if !NETSTANDARD1_3
[Serializable]
-#endif
public class ImageProcessingException : Exception
{
public ImageProcessingException(string? message)
@@ -29,11 +25,9 @@ public ImageProcessingException(Exception? innerException)
{
}
-#if !NETSTANDARD1_3
protected ImageProcessingException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
-#endif
}
}
diff --git a/MetadataExtractor/MetadataException.cs b/MetadataExtractor/MetadataException.cs
index 9e90dee09..957b7a823 100644
--- a/MetadataExtractor/MetadataException.cs
+++ b/MetadataExtractor/MetadataException.cs
@@ -1,17 +1,13 @@
// Copyright (c) Drew Noakes and contributors. All Rights Reserved. Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
using System;
-#if !NETSTANDARD1_3
using System.Runtime.Serialization;
-#endif
namespace MetadataExtractor
{
/// Base class for all metadata specific exceptions.
/// Drew Noakes https://drewnoakes.com
-#if !NETSTANDARD1_3
[Serializable]
-#endif
public class MetadataException : Exception
{
public MetadataException(string? msg)
@@ -29,11 +25,9 @@ public MetadataException(string? msg, Exception? innerException)
{
}
-#if !NETSTANDARD1_3
protected MetadataException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
-#endif
}
}
diff --git a/MetadataExtractor/MetadataExtractor.csproj b/MetadataExtractor/MetadataExtractor.csproj
index 07b11f855..0d6fb2321 100644
--- a/MetadataExtractor/MetadataExtractor.csproj
+++ b/MetadataExtractor/MetadataExtractor.csproj
@@ -30,19 +30,10 @@ Camera manufacturer specific support exists for Agfa, Canon, Casio, DJI, Epson,
-
+
-
-
-
-
-
-
-
-
-
true
diff --git a/MetadataExtractor/NewApi.cs b/MetadataExtractor/NewApi.cs
index 18354fabf..a997fcc36 100644
--- a/MetadataExtractor/NewApi.cs
+++ b/MetadataExtractor/NewApi.cs
@@ -1,12 +1,9 @@
// Copyright (c) Drew Noakes and contributors. All Rights Reserved. Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
-#nullable enable
-
-// TODO remove this
-// ReSharper disable CheckNamespace
using System;
using System.Collections;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
@@ -25,58 +22,22 @@ public interface IDirectory : IReadOnlyCollection
IEnumerable SubDirectories { get; }
}
-// ///
-// /// Base class for directories whose contents are stored by index.
-// ///
-// ///
-// public abstract class Directory : IDirectory, IEnumerable where TEntry : IEntry
-// {
-// // TODO need to maintain order of values if we are to write data again
-//
-// private readonly List _entries = new List();
-//
-// public abstract string Name { get; }
-//
-// public int Count => _entries.Count;
-//
-// // TODO can we store IDirectory as IEntry too? A directory may have different entry metadata based upon how it's embedded in outer data. something like ILinkedDirectoryEntry?
-// public IEnumerable SubDirectories => _entries.Select(entry => entry.Value).OfType();
-//
-// public bool TryGetValue(int index, out TEntry entry)
-// {
-// if (index >= 0 && index < _entries.Count)
-// {
-// entry = _entries[index];
-// return true;
-// }
-//
-// entry = default;
-// return false;
-// }
-//
-// #region IEnumerable
-//
-// IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
-//
-// IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
-//
-// public IEnumerator GetEnumerator() => _entries.GetEnumerator();
-//
-// #endregion
-// }
-
///
- /// Based class for directories whose contents are stored by key.
+ /// Base class for directories whose contents are stored by key.
///
- ///
+ /// The identifier for this
///
- public abstract class Directory : IDirectory, IEnumerable where TEntry : IEntry
+ public abstract class Directory
+ : IDirectory,
+ IEnumerable
+ where TEntry : IEntry
+ where TKey : notnull
{
// TODO need to maintain order of values if we are to write data again
private readonly Dictionary _entryByKey;
- protected Directory(IEqualityComparer comparator = null)
+ protected Directory(IEqualityComparer? comparator = null)
{
_entryByKey = new Dictionary(comparator);
}
@@ -88,7 +49,7 @@ protected Directory(IEqualityComparer comparator = null)
// TODO can we store IDirectory as IEntry too? A directory may have different entry metadata based upon how it's embedded in outer data. something like ILinkedDirectoryEntry?
public IEnumerable SubDirectories => _entryByKey.Select(entry => entry.Value.Value).OfType();
- public bool TryGetValue(TKey key, out TEntry entry)
+ public bool TryGetValue(TKey key, [NotNullWhen(returnValue: true)] out TEntry? entry)
{
return _entryByKey.TryGetValue(key, out entry);
}
@@ -108,7 +69,7 @@ public virtual TEntry this[TKey key]
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
- IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
+ IEnumerator IEnumerable.GetEnumerator() => _entryByKey.Values.Cast().GetEnumerator();
public IEnumerator GetEnumerator() => ((IEnumerable)_entryByKey.Values).GetEnumerator();
@@ -123,7 +84,7 @@ public interface IEntry
}
[StructLayout(LayoutKind.Auto)]
- public readonly struct TiffValue : IEntry
+ public class TiffValue : IEntry
{
public TiffDataFormat Format { get; }
public int ComponentCount { get; }
@@ -142,31 +103,32 @@ private TiffValue(TiffDataFormat format, int componentCount, object value, TiffT
string? IEntry.Description => Tag.Describe(this);
- public static TiffValue CreateInt8U (byte value, TiffTag tag) => new TiffValue(TiffDataFormat.Int8U, 1, value, tag);
- public static TiffValue CreateInt16U (ushort value, TiffTag tag) => new TiffValue(TiffDataFormat.Int16U, 1, value, tag);
- public static TiffValue CreateInt32U (uint value, TiffTag tag) => new TiffValue(TiffDataFormat.Int32U, 1, value, tag);
- public static TiffValue CreateRationalU(URational value, TiffTag tag) => new TiffValue(TiffDataFormat.RationalU, 1, value, tag);
- public static TiffValue CreateInt8S (sbyte value, TiffTag tag) => new TiffValue(TiffDataFormat.Int8S, 1, value, tag);
- public static TiffValue CreateInt16S (short value, TiffTag tag) => new TiffValue(TiffDataFormat.Int16S, 1, value, tag);
- public static TiffValue CreateInt32S (int value, TiffTag tag) => new TiffValue(TiffDataFormat.Int32S, 1, value, tag);
- public static TiffValue CreateRationalS(Rational value, TiffTag tag) => new TiffValue(TiffDataFormat.RationalS, 1, value, tag);
- public static TiffValue CreateSingle (float value, TiffTag tag) => new TiffValue(TiffDataFormat.Single, 1, value, tag);
- public static TiffValue CreateDouble (double value, TiffTag tag) => new TiffValue(TiffDataFormat.Double, 1, value, tag);
-
- public static TiffValue CreateString (byte[] value, TiffTag tag) => new TiffValue(TiffDataFormat.String, value.Length, value, tag);
- public static TiffValue CreateUndefined(byte[] value, TiffTag tag) => new TiffValue(TiffDataFormat.Undefined, value.Length, value, tag);
-
- public static TiffValue CreateInt8UArray (byte[] value, TiffTag tag) => new TiffValue(TiffDataFormat.Int8U, value.Length, value, tag);
- public static TiffValue CreateInt16UArray (ushort[] value, TiffTag tag) => new TiffValue(TiffDataFormat.Int16U, value.Length, value, tag);
- public static TiffValue CreateInt32UArray (uint[] value, TiffTag tag) => new TiffValue(TiffDataFormat.Int32U, value.Length, value, tag);
- public static TiffValue CreateRationalUArray(URational[] value, TiffTag tag) => new TiffValue(TiffDataFormat.RationalU, value.Length, value, tag);
- public static TiffValue CreateInt8SArray (sbyte[] value, TiffTag tag) => new TiffValue(TiffDataFormat.Int8S, value.Length, value, tag);
- public static TiffValue CreateUndefinedArray(byte[][] value, TiffTag tag) => new TiffValue(TiffDataFormat.Undefined, value.Length, value, tag);
- public static TiffValue CreateInt16SArray (short[] value, TiffTag tag) => new TiffValue(TiffDataFormat.Int16S, value.Length, value, tag);
- public static TiffValue CreateInt32SArray (int[] value, TiffTag tag) => new TiffValue(TiffDataFormat.Int32S, value.Length, value, tag);
- public static TiffValue CreateRationalSArray(Rational[] value, TiffTag tag) => new TiffValue(TiffDataFormat.RationalS, value.Length, value, tag);
- public static TiffValue CreateSingleArray (float[] value, TiffTag tag) => new TiffValue(TiffDataFormat.Single, value.Length, value, tag);
- public static TiffValue CreateDoubleArray (double[] value, TiffTag tag) => new TiffValue(TiffDataFormat.Double, value.Length, value, tag);
+ public static TiffValue CreateInt8U (byte value, TiffTag tag) => new(TiffDataFormat.Int8U, 1, value, tag);
+ public static TiffValue CreateInt16U (ushort value, TiffTag tag) => new(TiffDataFormat.Int16U, 1, value, tag);
+ public static TiffValue CreateInt32U (uint value, TiffTag tag) => new(TiffDataFormat.Int32U, 1, value, tag);
+ public static TiffValue CreateRationalU (URational value, TiffTag tag) => new(TiffDataFormat.RationalU, 1, value, tag);
+ public static TiffValue CreateInt8S (sbyte value, TiffTag tag) => new(TiffDataFormat.Int8S, 1, value, tag);
+ public static TiffValue CreateInt16S (short value, TiffTag tag) => new(TiffDataFormat.Int16S, 1, value, tag);
+ public static TiffValue CreateInt32S (int value, TiffTag tag) => new(TiffDataFormat.Int32S, 1, value, tag);
+ public static TiffValue CreateRationalS (Rational value, TiffTag tag) => new(TiffDataFormat.RationalS, 1, value, tag);
+ public static TiffValue CreateSingle (float value, TiffTag tag) => new(TiffDataFormat.Single, 1, value, tag);
+ public static TiffValue CreateDouble (double value, TiffTag tag) => new(TiffDataFormat.Double, 1, value, tag);
+
+ public static TiffValue CreateString (byte[] value, TiffTag tag) => new(TiffDataFormat.String, value.Length, value, tag);
+ public static TiffValue CreateUndefined (byte[] value, TiffTag tag) => new(TiffDataFormat.Undefined, value.Length, value, tag);
+
+ public static TiffValue CreateInt8UArray (byte[] value, TiffTag tag) => new(TiffDataFormat.Int8U, value.Length, value, tag);
+ public static TiffValue CreateInt16UArray (ushort[] value, TiffTag tag) => new(TiffDataFormat.Int16U, value.Length, value, tag);
+ public static TiffValue CreateInt32UArray (uint[] value, TiffTag tag) => new(TiffDataFormat.Int32U, value.Length, value, tag);
+ public static TiffValue CreateRationalUArray(URational[] value, TiffTag tag) => new(TiffDataFormat.RationalU, value.Length, value, tag);
+ public static TiffValue CreateInt8SArray (sbyte[] value, TiffTag tag) => new(TiffDataFormat.Int8S, value.Length, value, tag);
+ public static TiffValue CreateInt16SArray (short[] value, TiffTag tag) => new(TiffDataFormat.Int16S, value.Length, value, tag);
+ public static TiffValue CreateInt32SArray (int[] value, TiffTag tag) => new(TiffDataFormat.Int32S, value.Length, value, tag);
+ public static TiffValue CreateRationalSArray(Rational[] value, TiffTag tag) => new(TiffDataFormat.RationalS, value.Length, value, tag);
+ public static TiffValue CreateSingleArray (float[] value, TiffTag tag) => new(TiffDataFormat.Single, value.Length, value, tag);
+ public static TiffValue CreateDoubleArray (double[] value, TiffTag tag) => new(TiffDataFormat.Double, value.Length, value, tag);
+
+ public static TiffValue CreateUndefinedArray(byte[][] value, TiffTag tag) => new(TiffDataFormat.Undefined, value.Length, value, tag);
public bool TryGetByte(out byte b)
{
@@ -185,7 +147,7 @@ public bool TryGetByte(out byte b)
return true;
}
- if (value is short int16 && int16 >= byte.MinValue && int16 <= byte.MaxValue)
+ if (value is short int16 and >= byte.MinValue and <= byte.MaxValue)
{
b = (byte) int16;
return true;
@@ -197,41 +159,36 @@ public bool TryGetByte(out byte b)
return false;
}
- public bool TryGetInt32(out int value)
- {
- }
-
- public bool TryGetInt32Array(out int[] ints)
- {
- }
-
- public bool TryGetSingle(out float f)
- {
- }
-
- public bool TryGetString(out string s)
- {
- }
-
- public bool TryGetRational(out Rational rational)
- {
- }
-
- public bool TryGetURational(out URational uRational)
- {
- }
-
- public bool TryGetByteArray(out byte[] bytes)
- {
- }
-
- public bool TryGetURationalArray(out URational[] uRationals)
- {
- }
-
- public override string ToString() => ToString(provider: null);
+ // TODO implement all these
- public string ToString(IFormatProvider? provider) => Tag.Describe(this, provider);
+ public bool TryGetUInt16(out ushort value) => false;
+ public bool TryGetUInt32(out uint value) => false;
+ public bool TryGetURational(out URational value) => false;
+ public bool TryGetSByte(out byte value) => false;
+ public bool TryGetInt16(out short value) => false;
+ public bool TryGetInt32(out int value) => false;
+ public bool TryGetRational(out Rational value) => false;
+ public bool TryGetSingle(out float value) => false;
+ public bool TryGetDouble(out double value) => false;
+ public bool TryGetString(out string value) => false;
+ public bool TryGetUndefined(out byte[] value) => false;
+
+ public bool TryGetByteArray(out byte[] b) => false;
+ public bool TryGetUInt16Array(out ushort[] value) => false;
+ public bool TryGetUInt32Array(out uint[] value) => false;
+ public bool TryGetURationalArray(out URational[] value) => false;
+ public bool TryGetSByteArray(out byte[] value) => false;
+ public bool TryGetInt16Array(out short[] value) => false;
+ public bool TryGetInt32Array(out int[] value) => false;
+ public bool TryGetRationalArray(out Rational[] value) => false;
+ public bool TryGetSingleArray(out float[] value) => false;
+ public bool TryGetDoubleArray(out double[] value) => false;
+ public bool TryGetStringArray(out string[] value) => false;
+ public bool TryGetUndefinedArray(out byte[] value) => false;
+
+ public override string? ToString() => ToString(provider: null);
+
+ public string? ToString(IFormatProvider? provider) => Tag.Describe(this, provider);
}
///
@@ -247,14 +204,14 @@ public abstract class TiffTag
protected TiffTag(int id) => Id = id;
- public abstract string? Describe(TiffValue value, IFormatProvider? provider = null);
+ public abstract string? Describe(TiffValue value, IFormatProvider? format = null);
}
public sealed class TiffTagIdComparator : IEqualityComparer
{
- public static TiffTagIdComparator Instance { get; } = new TiffTagIdComparator();
+ public static TiffTagIdComparator Instance { get; } = new();
- public bool Equals(TiffTag x, TiffTag y) => x?.Id == y?.Id;
+ public bool Equals(TiffTag? x, TiffTag? y) => x?.Id == y?.Id;
public int GetHashCode(TiffTag obj) => obj.Id;
}
@@ -293,120 +250,138 @@ protected KnownTiffTag(int id, string name, int expectedCount = 1)
public class TiffUInt8Tag : KnownTiffTag
{
- private Func Describer { get; }
+ private readonly Func? _describer;
public TiffUInt8Tag(int id, string name, Func? describer = null)
: base(id, name)
{
- // TODO store describer delegate in base class if all subclasses end up using it
- Describer = (value, format) => value.TryGetByte(out byte b)
- ? describer?.Invoke(b, format) ?? b.ToString(format)
- : null;
+ _describer = describer;
}
- public override string? Describe(TiffValue value, IFormatProvider? provider = null)
- => Describer(value, provider);
+ public override string? Describe(TiffValue value, IFormatProvider? format = null)
+ {
+ if (value.TryGetByte(out byte b))
+ {
+ return _describer?.Invoke(b, format) ?? b.ToString(format);
+ }
+
+ return null;
+ }
public override TiffDataFormat ExpectedFormat => TiffDataFormat.Int8U;
}
public class TiffUInt16Tag : KnownTiffTag
{
- private Func Describer { get; }
+ private readonly Func? _describer;
- public TiffUInt16Tag(int id, string name, Func? describer = null)
+ public TiffUInt16Tag(int id, string name, Func? describer = null)
: base(id, name)
{
- // TODO store describer delegate in base class if all subclasses end up using it
- Describer = (value, format) => value.TryGetInt32(out var i)
- ? describer?.Invoke(i, format) ?? i.ToString(format)
- : null;
+ _describer = describer;
}
- public override string? Describe(TiffValue value, IFormatProvider? provider = null)
- => Describer(value, provider);
+ public override string? Describe(TiffValue value, IFormatProvider? format = null)
+ {
+ if (value.TryGetUInt16(out ushort i))
+ {
+ return _describer?.Invoke(i, format) ?? i.ToString(format);
+ }
+
+ return null;
+ }
public override TiffDataFormat ExpectedFormat => TiffDataFormat.Int16U;
}
public class TiffUInt32Tag : KnownTiffTag
{
- private Func Describer { get; }
+ private readonly Func? _describer;
public TiffUInt32Tag(int id, string name, Func? describer = null)
: base(id, name)
{
- // TODO store describer delegate in base class if all subclasses end up using it
- Describer = (value, format) => value.TryGetInt32(out var i)
- ? describer?.Invoke(i, format) ?? i.ToString(format)
- : null;
+ _describer = describer;
}
- public override string? Describe(TiffValue value, IFormatProvider? provider = null)
- => Describer(value, provider);
+ public override string? Describe(TiffValue value, IFormatProvider? format = null)
+ {
+ if (value.TryGetInt32(out int i))
+ {
+ return _describer?.Invoke(i, format) ?? i.ToString(format);
+ }
+
+ return null;
+ }
public override TiffDataFormat ExpectedFormat => TiffDataFormat.Int32U;
}
public class TiffSingleTag : KnownTiffTag
{
- private Func Describer { get; }
+ private readonly Func? _describer;
public TiffSingleTag(int id, string name, Func? describer = null)
: base(id, name)
{
- // TODO store describer delegate in base class if all subclasses end up using it
- Describer = (value, format) => value.TryGetSingle(out float f)
- ? describer?.Invoke(f, format) ?? f.ToString(format)
- : null;
+ _describer = describer;
}
- public override string? Describe(TiffValue value, IFormatProvider? provider = null)
- => Describer(value, provider);
+ public override string? Describe(TiffValue value, IFormatProvider? format = null)
+ {
+ if (value.TryGetInt32(out int i))
+ {
+ return _describer?.Invoke(i, format) ?? i.ToString(format);
+ }
+
+ return null;
+ }
public override TiffDataFormat ExpectedFormat => TiffDataFormat.Single;
}
public class TiffRationalTag : KnownTiffTag
{
- private Func Describer { get; }
+ private readonly Func? _describer;
public TiffRationalTag(int id, string name, Func? describer = null)
: base(id, name)
{
- // TODO store describer delegate in base class if all subclasses end up using it
- Describer = (value, format) =>
- {
- return value.TryGetRational(out Rational r)
- ? describer?.Invoke(r, format) ?? r.ToString(format)
- : null;
- };
+ _describer = describer;
}
- public override string? Describe(TiffValue value, IFormatProvider? provider = null)
- => Describer(value, provider);
+ public override string? Describe(TiffValue value, IFormatProvider? format = null)
+ {
+ if (value.TryGetRational(out Rational i))
+ {
+ return _describer?.Invoke(i, format) ?? i.ToString(format);
+ }
+
+ return null;
+ }
public override TiffDataFormat ExpectedFormat => TiffDataFormat.RationalS;
}
public class TiffURationalTag : KnownTiffTag
{
- private Func Describer { get; }
+ private readonly Func? _describer;
public TiffURationalTag(int id, string name, Func? describer = null)
: base(id, name)
{
- // TODO store describer delegate in base class if all subclasses end up using it
- Describer = (value, format) =>
- {
- return value.TryGetURational(out URational r)
- ? describer?.Invoke(r, format) ?? r.ToString(format)
- : null;
- };
+ _describer = describer;
}
- public override string? Describe(TiffValue value, IFormatProvider? provider = null)
- => Describer(value, provider);
+ public override string? Describe(TiffValue value, IFormatProvider? format = null)
+ {
+ if (value.TryGetURational(out URational i))
+ {
+ return _describer?.Invoke(i, format) ?? i.ToString(format);
+ }
+
+ return null;
+ }
public override TiffDataFormat ExpectedFormat => TiffDataFormat.RationalU;
}
@@ -430,7 +405,7 @@ public TiffStringTag(int id, string name, Func
ExpectedEncoding = Encoding.UTF8;
}
- public override string? Describe(TiffValue value, IFormatProvider? provider = null)
+ public override string? Describe(TiffValue value, IFormatProvider? format = null)
{
if (!value.TryGetByteArray(out byte[] bytes))
return null;
@@ -444,7 +419,7 @@ public TiffStringTag(int id, string name, Func
return ExpectedEncoding.GetString(bytes, 0, bytes.Length).TrimEnd('\0');
}
- return _describer(bytes, provider);
+ return _describer(bytes, format);
}
catch
{
@@ -457,11 +432,11 @@ public TiffStringTag(int id, string name, Func
public class TiffIndexedUInt16Tag : TiffUInt16Tag
{
- public TiffIndexedUInt16Tag(int id, string name, int baseIndex, string[] descriptions)
- : base(id, name, (i, provider) => DecodeIndex(baseIndex, descriptions, i))
+ public TiffIndexedUInt16Tag(int id, string name, int baseIndex, string?[] descriptions)
+ : base(id, name, (i, _) => DecodeIndex(baseIndex, descriptions, i))
{}
- private static string DecodeIndex(int baseIndex, string[] descriptions, int index)
+ private static string? DecodeIndex(int baseIndex, string?[] descriptions, int index)
{
int arrayIndex = index - baseIndex;
@@ -474,50 +449,67 @@ private static string DecodeIndex(int baseIndex, string[] descriptions, int inde
public class TiffMappedUInt16Tag : TiffUInt16Tag
{
+ private readonly IReadOnlyDictionary _descriptions;
+
public TiffMappedUInt16Tag(int id, string name, IReadOnlyDictionary descriptions)
- : base(id, name, (i, provider) => DecodeIndex(descriptions, i))
- {}
+ : base(id, name)
+ {
+ _descriptions = descriptions;
+ }
- private static string? DecodeIndex(IReadOnlyDictionary readOnlyDictionary, int value)
+ public override string? Describe(TiffValue value, IFormatProvider? format = null)
{
- return !readOnlyDictionary.TryGetValue(value, out var description) ? null : description;
+ if (value.TryGetInt32(out int i))
+ {
+ return _descriptions.TryGetValue(i, out string? description) ? description : i.ToString(format);
+ }
+
+ return null;
}
}
public class TiffUInt16ArrayTag : KnownTiffTag
{
- private Func Describer { get; }
+ private readonly Func? _describer;
public TiffUInt16ArrayTag(int id, string name, int expectedCount, Func? describer = null)
: base(id, name, expectedCount)
{
- // TODO store describer delegate in base class if all subclasses end up using it
- Describer = (value, format) => value.TryGetInt32Array(out var i) // TODO int16[] here?
- ? describer?.Invoke(i, format) ?? i.ToString()
- : null;
+ _describer = describer;
}
- public override string? Describe(TiffValue value, IFormatProvider? provider = null)
- => Describer(value, provider);
+ public override string? Describe(TiffValue value, IFormatProvider? format = null)
+ {
+ if (value.TryGetInt32Array(out int[] i))
+ {
+ return _describer?.Invoke(i, format) ?? i.ToString(format); // TODO write central array formatting code and reuse
+ }
+
+ return null;
+ }
public override TiffDataFormat ExpectedFormat => TiffDataFormat.Int16U;
}
public class TiffURationalArrayTag : KnownTiffTag
{
- private Func Describer { get; }
+ private readonly Func? _describer;
public TiffURationalArrayTag(int id, string name, int expectedCount, Func? describer = null)
: base(id, name, expectedCount)
{
- // TODO store describer delegate in base class if all subclasses end up using it
- Describer = (value, format) => value.TryGetURationalArray(out URational[] i)
- ? describer?.Invoke(i, format) ?? i.ToString()
- : null;
+ _describer = describer;
}
- public override string? Describe(TiffValue value, IFormatProvider? provider = null)
- => Describer(value, provider);
+ public override string? Describe(TiffValue value, IFormatProvider? format = null)
+ {
+ if (value.TryGetURationalArray(out URational[] i))
+ {
+ return _describer?.Invoke(i, format) ?? i.ToString(format); // TODO write central array formatting code and reuse
+ }
+
+ return null;
+ }
public override TiffDataFormat ExpectedFormat => TiffDataFormat.RationalU;
}
@@ -532,9 +524,9 @@ public UnknownTiffTag(int id) : base(id)
{
}
- public override string? Describe(TiffValue value, IFormatProvider? provider = null)
+ public override string? Describe(TiffValue value, IFormatProvider? format = null)
{
- return value.ToString(provider);
+ return value.ToString(format);
}
}
@@ -546,7 +538,7 @@ protected TiffDirectory() : base(TiffTagIdComparator.Instance)
public bool TryGetInt32(TiffTag tag, out int value) // TODO should this be an override of the base?
{
- if (TryGetValue(tag, out TiffValue tiffValue) &&
+ if (TryGetValue(tag, out TiffValue? tiffValue) &&
tiffValue.TryGetInt32(out value))
{
return true;
@@ -565,6 +557,10 @@ public sealed class ExifIfd0Directory : TiffDirectory
public int? Height => TryGetInt32(ExifTags.ImageHeight, out int value) ? value : default;
}
+ /////////////////////////////////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////////////////////////////////
+
public readonly struct XmpName : IEquatable
{
public string Namespace { get; }
@@ -580,7 +576,7 @@ public XmpName(string @namespace, string name)
public bool Equals(XmpName other) => Namespace == other.Namespace && Name == other.Name;
- public override bool Equals(object obj) => obj is XmpName other && Equals(other);
+ public override bool Equals(object? obj) => obj is XmpName other && Equals(other);
public override int GetHashCode() => Namespace == null ? 0 : unchecked((Namespace.GetHashCode() * 397) ^ Name.GetHashCode());
}
@@ -631,7 +627,15 @@ public XmpDirectory(XmpMeta xmpMeta)
catch (XmpException) { } // ignored
}
}
+
+ /////////////////////////////////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////////////////////////////////
+ // An example of a directory whose data is a fixed sequence of consecutive values, representable as a byte array.
+ // Entry objects are constructed lazily when requested. Individual values may be read/written via properties
+ // that update backing memory directly.
+
public enum PcxProperty
{
Version,
@@ -641,6 +645,7 @@ public sealed class PcxDirectory : IDirectory
{
public const int HeaderSizeBytes = 74;
+ // Little-endian backing data
private readonly byte[] _bytes;
// NOTE this directory must be strict about the values it can receive for properties.
@@ -657,7 +662,7 @@ public sealed class PcxDirectory : IDirectory
// directory instance. This would also help with Exif tags that need to read multiple values
// as part of their description, but will make the API uglier I think.
- private static readonly IndexedTable _pcxVersionTable = new IndexedTable(new[]
+ private static readonly IndexedTable _pcxVersionTable = new(new[]
{
"2.5 with fixed EGA palette information",
null,
@@ -667,9 +672,10 @@ public sealed class PcxDirectory : IDirectory
"3.0 or better"
});
- private static readonly IndexedTable _pcxColorPlanesTable = new IndexedTable(new[] { "24-bit color", "16 colors" }, baseIndex: 3);
- private static readonly IndexedTable _pcxPaletteTypeTable = new IndexedTable(new[] { "Color or B&W", "Grayscale" }, baseIndex: 1);
+ private static readonly IndexedTable _pcxColorPlanesTable = new(new[] { "24-bit color", "16 colors" }, baseIndex: 3);
+ private static readonly IndexedTable _pcxPaletteTypeTable = new(new[] { "Color or B&W", "Grayscale" }, baseIndex: 1);
+ // TODO use Memory instead?
public PcxDirectory(byte[] bytes)
{
if (bytes == null)
@@ -678,6 +684,8 @@ public PcxDirectory(byte[] bytes)
throw new ArgumentException($"Must contain {HeaderSizeBytes} bytes", nameof(bytes));
_bytes = bytes;
}
+
+ // Bytes 0 and 2 have fixed values, validated during read time
public byte Version
{
@@ -690,13 +698,85 @@ public byte BitsPerPixel
get => _bytes[3];
set => _bytes[3] = value;
}
-
- // TODO additional properties
+
+ public ushort XMin
+ {
+ get => MemoryMarshal.Read(_bytes.AsSpan()[4..5]);
+ set => MemoryMarshal.Write(_bytes.AsSpan()[4..5], ref value);
+ }
+
+ public ushort YMin
+ {
+ get => MemoryMarshal.Read(_bytes.AsSpan()[6..7]);
+ set => MemoryMarshal.Write(_bytes.AsSpan()[6..7], ref value);
+ }
+
+ public ushort XMax
+ {
+ get => MemoryMarshal.Read(_bytes.AsSpan()[8..9]);
+ set => MemoryMarshal.Write(_bytes.AsSpan()[8..9], ref value);
+ }
+
+ public ushort YMax
+ {
+ get => MemoryMarshal.Read(_bytes.AsSpan()[10..11]);
+ set => MemoryMarshal.Write(_bytes.AsSpan()[10..11], ref value);
+ }
+
+ public ushort HorizontalDpi
+ {
+ get => MemoryMarshal.Read(_bytes.AsSpan()[12..13]);
+ set => MemoryMarshal.Write(_bytes.AsSpan()[12..13], ref value);
+ }
+
+ public ushort VerticalDpi
+ {
+ get => MemoryMarshal.Read(_bytes.AsSpan()[14..15]);
+ set => MemoryMarshal.Write(_bytes.AsSpan()[14..15], ref value);
+ }
+
+ public byte[] Palette
+ {
+ get => _bytes[16..63];
+ set => Array.Copy(value, sourceIndex: 0, _bytes, destinationIndex: 16, value.Length);
+ }
+
+ public byte ColorPlanes
+ {
+ get => _bytes[65];
+ set => _bytes[65] = value;
+ }
+
+ public ushort BytesPerLine
+ {
+ get => MemoryMarshal.Read(_bytes.AsSpan()[66..67]);
+ set => MemoryMarshal.Write(_bytes.AsSpan()[66..67], ref value);
+ }
+
+ public ushort PaletteType
+ {
+ get => MemoryMarshal.Read(_bytes.AsSpan()[68..69]);
+ set => MemoryMarshal.Write(_bytes.AsSpan()[68..69], ref value);
+ }
+
+ public ushort HScrSize
+ {
+ get => MemoryMarshal.Read(_bytes.AsSpan()[70..71]);
+ set => MemoryMarshal.Write(_bytes.AsSpan()[70..71], ref value);
+ }
+
+ public ushort VScrSize
+ {
+ get => MemoryMarshal.Read(_bytes.AsSpan()[72..73]);
+ set => MemoryMarshal.Write(_bytes.AsSpan()[72..73], ref value);
+ }
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
public IEnumerator GetEnumerator()
{
+ // Spike of a simpler API
+
yield return new Entry("Version", Version, index => _pcxVersionTable.LookUp(index));
yield return new Entry("Bits Per Pixel", BitsPerPixel);
yield return new Entry("X Min", XMin);
@@ -706,9 +786,10 @@ public IEnumerator GetEnumerator()
yield return new Entry("Horizontal DPI", HorizontalDpi);
yield return new Entry("Vertical DPI", VerticalDpi);
yield return new Entry("Palette", Palette);
- yield return new Entry("Color Planes", ColorPlanes, index => _pcxColorPlanesTable.LookUp(index));
+ // TODO the old code would only return these if they were non-zero
+ yield return new Entry("Color Planes", ColorPlanes, static index => _pcxColorPlanesTable.LookUp(index));
yield return new Entry("Bytes Per Line", BytesPerLine);
- yield return new Entry("Palette Type", PalleteType, index => _pcxPaletteTypeTable.LookUp(index));
+ yield return new Entry("Palette Type", PaletteType, static index => _pcxPaletteTypeTable.LookUp(index));
}
public int Count => 14;
@@ -730,11 +811,11 @@ public IndexedTable(string?[] strings, int baseIndex = 0)
}
}
- public class Entry : IEntry
+ public class Entry : IEntry where T : notnull
{
- private readonly Func _descriptor;
+ private readonly Func? _descriptor;
- public Entry(string name, T value, Func? descriptor = null)
+ public Entry(string name, T value, Func? descriptor = null)
{
_descriptor = descriptor;
Name = name;
@@ -744,7 +825,7 @@ public Entry(string name, T value, Func? descriptor = null)
private T Value { get; }
object IEntry.Value => Value;
public string Name { get; }
- public string Description => _descriptor == null ? Value.ToString() : _descriptor(Value);
+ public string? Description => _descriptor == null ? Value.ToString() : _descriptor(Value);
}
public sealed class PcxReader
@@ -777,52 +858,56 @@ static PcxDirectory WithError(string errorMessage)
return directory;
}
- try
- {
- var identifier = reader.GetSByte();
-
- if (identifier != 0x0A)
- throw new ImageProcessingException("Invalid PCX identifier byte");
-
- directory.Set(PcxDirectory.TagVersion, reader.GetSByte());
-
- var encoding = reader.GetSByte();
- if (encoding != 0x01)
- throw new ImageProcessingException("Invalid PCX encoding byte");
-
- directory.Set(PcxDirectory.TagBitsPerPixel, reader.GetByte());
- directory.Set(PcxDirectory.TagXMin, reader.GetUInt16());
- directory.Set(PcxDirectory.TagYMin, reader.GetUInt16());
- directory.Set(PcxDirectory.TagXMax, reader.GetUInt16());
- directory.Set(PcxDirectory.TagYMax, reader.GetUInt16());
- directory.Set(PcxDirectory.TagHorizontalDpi, reader.GetUInt16());
- directory.Set(PcxDirectory.TagVerticalDpi, reader.GetUInt16());
- directory.Set(PcxDirectory.TagPalette, reader.GetBytes(48));
- reader.Skip(1);
- directory.Set(PcxDirectory.TagColorPlanes, reader.GetByte());
- directory.Set(PcxDirectory.TagBytesPerLine, reader.GetUInt16());
-
- var paletteType = reader.GetUInt16();
- if (paletteType != 0)
- directory.Set(PcxDirectory.TagPaletteType, paletteType);
-
- var hScrSize = reader.GetUInt16();
- if (hScrSize != 0)
- directory.Set(PcxDirectory.TagHScrSize, hScrSize);
-
- var vScrSize = reader.GetUInt16();
- if (vScrSize != 0)
- directory.Set(PcxDirectory.TagVScrSize, vScrSize);
- }
- catch (Exception ex)
- {
- directory.AddError("Exception reading PCX file metadata: " + ex.Message);
- }
-
- return directory;
+ // try
+ // {
+ // var identifier = reader.GetSByte();
+ //
+ // if (identifier != 0x0A)
+ // throw new ImageProcessingException("Invalid PCX identifier byte");
+ //
+ // directory.Set(PcxDirectory.TagVersion, reader.GetSByte());
+ //
+ // var encoding = reader.GetSByte();
+ // if (encoding != 0x01)
+ // throw new ImageProcessingException("Invalid PCX encoding byte");
+ //
+ // directory.Set(PcxDirectory.TagBitsPerPixel, reader.GetByte());
+ // directory.Set(PcxDirectory.TagXMin, reader.GetUInt16());
+ // directory.Set(PcxDirectory.TagYMin, reader.GetUInt16());
+ // directory.Set(PcxDirectory.TagXMax, reader.GetUInt16());
+ // directory.Set(PcxDirectory.TagYMax, reader.GetUInt16());
+ // directory.Set(PcxDirectory.TagHorizontalDpi, reader.GetUInt16());
+ // directory.Set(PcxDirectory.TagVerticalDpi, reader.GetUInt16());
+ // directory.Set(PcxDirectory.TagPalette, reader.GetBytes(48));
+ // reader.Skip(1);
+ // directory.Set(PcxDirectory.TagColorPlanes, reader.GetByte());
+ // directory.Set(PcxDirectory.TagBytesPerLine, reader.GetUInt16());
+ //
+ // var paletteType = reader.GetUInt16();
+ // if (paletteType != 0)
+ // directory.Set(PcxDirectory.TagPaletteType, paletteType);
+ //
+ // var hScrSize = reader.GetUInt16();
+ // if (hScrSize != 0)
+ // directory.Set(PcxDirectory.TagHScrSize, hScrSize);
+ //
+ // var vScrSize = reader.GetUInt16();
+ // if (vScrSize != 0)
+ // directory.Set(PcxDirectory.TagVScrSize, vScrSize);
+ // }
+ // catch (Exception ex)
+ // {
+ // directory.AddError("Exception reading PCX file metadata: " + ex.Message);
+ // }
+ //
+ // return directory;
}
}
+ /////////////////////////////////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////////////////////////////////
+
public static class MetadataReader
{
public static IReadOnlyList Read(string path)
@@ -835,10 +920,10 @@ internal static class Program
{
private static void Main(string[] args)
{
- var directories = MetadataReader.Read(args[0]);
+ IReadOnlyList directories = MetadataReader.Read(args[0]);
- foreach (var directory in directories)
- foreach (var entry in directory)
+ foreach (IDirectory directory in directories)
+ foreach (IEntry entry in directory)
Console.Out.WriteLine($"{directory.Name} - {entry.Name} = {entry.Description}");
var ifd0 = directories.OfType().SingleOrDefault();
@@ -857,7 +942,7 @@ private static void Main(string[] args)
// TODO recurring through sub-directories, vs flat-structure (IsTopLevel flag on IDirectory?)
}
- // TODO some directories are flexible (eg. TIFF _can_ store unexpected types of values for tags) and some aren't (eg. PCX version _must_ be a byte) which becomes important if we want to write metadata
+ // TODO some directories are flexible with types of values (eg. TIFF _can_ store unexpected types of values for tags) and some aren't (eg. PCX version _must_ be a byte) which becomes important if we want to write metadata
// TODO sketch out an index-based directory type (eg. fixed offsets and all fields present)
// TODO sketch out an enum-based directory type (simple key)
diff --git a/MetadataExtractor/PublicAPI/net35/PublicAPI.Shipped.txt b/MetadataExtractor/PublicAPI/net35/PublicAPI.Shipped.txt
deleted file mode 100644
index 2ff73e235..000000000
--- a/MetadataExtractor/PublicAPI/net35/PublicAPI.Shipped.txt
+++ /dev/null
@@ -1,4047 +0,0 @@
-#nullable enable
-MetadataExtractor.Age
-MetadataExtractor.Age.Age(int years, int months, int days, int hours, int minutes, int seconds) -> void
-MetadataExtractor.Age.Days.get -> int
-MetadataExtractor.Age.Hours.get -> int
-MetadataExtractor.Age.Minutes.get -> int
-MetadataExtractor.Age.Months.get -> int
-MetadataExtractor.Age.Seconds.get -> int
-MetadataExtractor.Age.ToFriendlyString() -> string!
-MetadataExtractor.Age.Years.get -> int
-MetadataExtractor.Directory
-MetadataExtractor.Directory.AddError(string! message) -> void
-MetadataExtractor.Directory.ContainsTag(int tagType) -> bool
-MetadataExtractor.Directory.Errors.get -> System.Collections.Generic.IEnumerable!
-MetadataExtractor.Directory.GetDescription(int tagType) -> string?
-MetadataExtractor.Directory.GetObject(int tagType) -> object?
-MetadataExtractor.Directory.GetTagName(int tagType) -> string!
-MetadataExtractor.Directory.HasError.get -> bool
-MetadataExtractor.Directory.HasTagName(int tagType) -> bool
-MetadataExtractor.Directory.IsEmpty.get -> bool
-MetadataExtractor.Directory.Parent.get -> MetadataExtractor.Directory?
-MetadataExtractor.Directory.SetDescriptor(MetadataExtractor.ITagDescriptor! descriptor) -> void
-MetadataExtractor.Directory.TagCount.get -> int
-MetadataExtractor.Directory.Tags.get -> System.Collections.Generic.IEnumerable!
-MetadataExtractor.DirectoryExtensions
-MetadataExtractor.ErrorDirectory
-MetadataExtractor.ErrorDirectory.ErrorDirectory() -> void
-MetadataExtractor.ErrorDirectory.ErrorDirectory(string! error) -> void
-MetadataExtractor.Face
-MetadataExtractor.Face.Age.get -> MetadataExtractor.Age?
-MetadataExtractor.Face.Face(int x, int y, int width, int height, string? name = null, MetadataExtractor.Age? age = null) -> void
-MetadataExtractor.Face.Height.get -> int
-MetadataExtractor.Face.Name.get -> string?
-MetadataExtractor.Face.Width.get -> int
-MetadataExtractor.Face.X.get -> int
-MetadataExtractor.Face.Y.get -> int
-MetadataExtractor.Formats.Adobe.AdobeJpegDescriptor
-MetadataExtractor.Formats.Adobe.AdobeJpegDescriptor.AdobeJpegDescriptor(MetadataExtractor.Formats.Adobe.AdobeJpegDirectory! directory) -> void
-MetadataExtractor.Formats.Adobe.AdobeJpegDescriptor.GetColorTransformDescription() -> string?
-MetadataExtractor.Formats.Adobe.AdobeJpegDescriptor.GetDctEncodeVersionDescription() -> string?
-MetadataExtractor.Formats.Adobe.AdobeJpegDirectory
-MetadataExtractor.Formats.Adobe.AdobeJpegDirectory.AdobeJpegDirectory() -> void
-MetadataExtractor.Formats.Adobe.AdobeJpegReader
-MetadataExtractor.Formats.Adobe.AdobeJpegReader.AdobeJpegReader() -> void
-MetadataExtractor.Formats.Adobe.AdobeJpegReader.Extract(MetadataExtractor.IO.SequentialReader! reader) -> MetadataExtractor.Formats.Adobe.AdobeJpegDirectory!
-MetadataExtractor.Formats.Adobe.AdobeJpegReader.ReadJpegSegments(System.Collections.Generic.IEnumerable! segments) -> System.Collections.Generic.IEnumerable!
-MetadataExtractor.Formats.Avi.AviDescriptor
-MetadataExtractor.Formats.Avi.AviDescriptor.AviDescriptor(MetadataExtractor.Formats.Avi.AviDirectory! directory) -> void
-MetadataExtractor.Formats.Avi.AviDirectory
-MetadataExtractor.Formats.Avi.AviDirectory.AviDirectory() -> void
-MetadataExtractor.Formats.Avi.AviMetadataReader
-MetadataExtractor.Formats.Avi.AviRiffHandler
-MetadataExtractor.Formats.Avi.AviRiffHandler.AviRiffHandler(System.Collections.Generic.List! directories) -> void
-MetadataExtractor.Formats.Avi.AviRiffHandler.ProcessChunk(string! fourCc, byte[]! payload) -> void
-MetadataExtractor.Formats.Avi.AviRiffHandler.ShouldAcceptChunk(string! fourCc) -> bool
-MetadataExtractor.Formats.Avi.AviRiffHandler.ShouldAcceptList(string! fourCc) -> bool
-MetadataExtractor.Formats.Avi.AviRiffHandler.ShouldAcceptRiffIdentifier(string! identifier) -> bool
-MetadataExtractor.Formats.Bmp.BmpHeaderDescriptor
-MetadataExtractor.Formats.Bmp.BmpHeaderDescriptor.BmpHeaderDescriptor(MetadataExtractor.Formats.Bmp.BmpHeaderDirectory! directory) -> void
-MetadataExtractor.Formats.Bmp.BmpHeaderDescriptor.GetBitmapTypeDescription() -> string?
-MetadataExtractor.Formats.Bmp.BmpHeaderDescriptor.GetColorEncodingDescription() -> string?
-MetadataExtractor.Formats.Bmp.BmpHeaderDescriptor.GetColorSpaceTypeDescription() -> string?
-MetadataExtractor.Formats.Bmp.BmpHeaderDescriptor.GetCompressionDescription() -> string?
-MetadataExtractor.Formats.Bmp.BmpHeaderDescriptor.GetRenderingDescription() -> string?
-MetadataExtractor.Formats.Bmp.BmpHeaderDescriptor.GetRenderingIntentDescription() -> string?
-MetadataExtractor.Formats.Bmp.BmpHeaderDirectory
-MetadataExtractor.Formats.Bmp.BmpHeaderDirectory.BitmapType
-MetadataExtractor.Formats.Bmp.BmpHeaderDirectory.BmpHeaderDirectory() -> void
-MetadataExtractor.Formats.Bmp.BmpHeaderDirectory.ColorEncoding
-MetadataExtractor.Formats.Bmp.BmpHeaderDirectory.ColorSpaceType
-MetadataExtractor.Formats.Bmp.BmpHeaderDirectory.Compression
-MetadataExtractor.Formats.Bmp.BmpHeaderDirectory.RenderingHalftoningAlgorithm
-MetadataExtractor.Formats.Bmp.BmpHeaderDirectory.RenderingIntent
-MetadataExtractor.Formats.Bmp.BmpMetadataReader
-MetadataExtractor.Formats.Bmp.BmpReader
-MetadataExtractor.Formats.Bmp.BmpReader.BmpReader() -> void
-MetadataExtractor.Formats.Bmp.BmpReader.Extract(MetadataExtractor.IO.SequentialReader! reader) -> System.Collections.Generic.IList!
-MetadataExtractor.Formats.Eps.EpsDescriptor
-MetadataExtractor.Formats.Eps.EpsDescriptor.EpsDescriptor(MetadataExtractor.Formats.Eps.EpsDirectory! directory) -> void
-MetadataExtractor.Formats.Eps.EpsDescriptor.GetByteSizeDescription(int tagType) -> string!
-MetadataExtractor.Formats.Eps.EpsDescriptor.GetColorTypeDescription() -> string?
-MetadataExtractor.Formats.Eps.EpsDescriptor.GetPixelDescription(int tagType) -> string!
-MetadataExtractor.Formats.Eps.EpsDirectory
-MetadataExtractor.Formats.Eps.EpsDirectory.EpsDirectory() -> void
-MetadataExtractor.Formats.Eps.EpsMetadataReader
-MetadataExtractor.Formats.Eps.EpsReader
-MetadataExtractor.Formats.Eps.EpsReader.EpsReader() -> void
-MetadataExtractor.Formats.Eps.EpsReader.Extract(System.IO.Stream! inputStream) -> System.Collections.Generic.IList!
-MetadataExtractor.Formats.Exif.ExifDescriptorBase
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.ExifDescriptorBase(T! directory) -> void
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.Get35MMFilmEquivFocalLengthDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetApertureValueDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetBitsPerSampleDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetBrightnessValueDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetCfaPattern2Description() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetCfaPatternDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetColorSpaceDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetComponentConfigurationDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetCompressedAverageBitsPerPixelDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetCompressionDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetContrastDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetCustomRenderedDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetDigitalZoomRatioDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetExifImageHeightDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetExifImageWidthDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetExifVersionDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetExposureBiasDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetExposureModeDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetExposureProgramDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetExposureTimeDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetFNumberDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetFileSourceDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetFillOrderDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetFlashDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetFlashPixVersionDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetFocalLengthDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetFocalPlaneResolutionUnitDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetFocalPlaneXResolutionDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetFocalPlaneYResolutionDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetGainControlDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetImageHeightDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetImageWidthDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetInteropIndexDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetInteropVersionDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetIsoEquivalentDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetJpegProcDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetLensSpecificationDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetMaxApertureValueDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetMeteringModeDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetNewSubfileTypeDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetOrientationDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetPhotometricInterpretationDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetPlanarConfigurationDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetReferenceBlackWhiteDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetResolutionDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetRowsPerStripDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetSamplesPerPixelDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetSaturationDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetSceneCaptureTypeDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetSceneTypeDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetSensingMethodDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetSensitivityTypeDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetSharpnessDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetShutterSpeedDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetStripByteCountsDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetSubfileTypeDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetSubjectDistanceDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetSubjectDistanceRangeDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetThresholdingDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetUserCommentDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetWhiteBalanceDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetWhiteBalanceModeDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetWindowsAuthorDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetWindowsCommentDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetWindowsKeywordsDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetWindowsSubjectDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetWindowsTitleDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetXResolutionDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetYCbCrPositioningDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase.GetYCbCrSubsamplingDescription() -> string?
-MetadataExtractor.Formats.Exif.ExifDescriptorBase