Struct ExifFraction
A rational EXIF value, such as an exposure time of 1/250 or an aperture of 28/10.
public readonly record struct ExifFraction : IEquatable<ExifFraction>
- Implements
- Inherited Members
Examples
using Raster photo = Raster.Load("sideways.jpg");
ExifData exif = photo.Metadata.Exif ?? new ExifData();
// Typed values go in with their EXIF type; fractions are exact numerator / denominator pairs.
exif.Set(ExifKey.ExposureTime, new ExifFraction(1, 250));
exif.Set(ExifKey.Artist, "A. Photographer");
if (exif.TryGet(ExifKey.ExposureTime, out ExifEntry? entry) && entry.Type == ExifType.Rational)
{
Console.WriteLine($"Exposure {entry.AsFraction()} s = {entry.AsFraction().ToDouble()} s, in the {entry.Key.Ifd} IFD");
}
if (exif.Location is GeoPosition where)
{
Console.WriteLine($"Taken at {where.Latitude:F5}, {where.Longitude:F5}");
}
Constructors
ExifFraction(long, long)
A rational EXIF value, such as an exposure time of 1/250 or an aperture of 28/10.
public ExifFraction(long Numerator, long Denominator)
Parameters
Examples
using Raster photo = Raster.Load("sideways.jpg");
ExifData exif = photo.Metadata.Exif ?? new ExifData();
// Typed values go in with their EXIF type; fractions are exact numerator / denominator pairs.
exif.Set(ExifKey.ExposureTime, new ExifFraction(1, 250));
exif.Set(ExifKey.Artist, "A. Photographer");
if (exif.TryGet(ExifKey.ExposureTime, out ExifEntry? entry) && entry.Type == ExifType.Rational)
{
Console.WriteLine($"Exposure {entry.AsFraction()} s = {entry.AsFraction().ToDouble()} s, in the {entry.Key.Ifd} IFD");
}
if (exif.Location is GeoPosition where)
{
Console.WriteLine($"Taken at {where.Latitude:F5}, {where.Longitude:F5}");
}
Properties
Denominator
The denominator; 0 in damaged or "unknown" values.
public long Denominator { get; init; }
Property Value
Numerator
The numerator.
public long Numerator { get; init; }
Property Value
Methods
ToDouble()
Returns the value as a number, or NaN when the denominator is 0.
public double ToDouble()
Returns
- double
The quotient.
ToString()
Returns the fully qualified type name of this instance.
public override string ToString()
Returns
- string
The fully qualified type name.