Browse Source

Make XMP internal, minor cleanup

pull/1553/head
James Jackson-South 5 years ago
parent
commit
fab1f3a5a0
  1. 18
      src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs
  2. 11
      src/ImageSharp/Formats/Tiff/TiffDecoderMetadataCreator.cs
  3. 23
      src/ImageSharp/Formats/Tiff/TiffFrameMetadata.cs
  4. 2
      src/ImageSharp/Metadata/ImageFrameMetadata.cs

18
src/ImageSharp/Formats/Tiff/TiffDecoderCore.cs

@ -120,22 +120,18 @@ namespace SixLabors.ImageSharp.Formats.Tiff
ImageMetadata metadata = TiffDecoderMetadataCreator.Create(frames, tiffFramesMataData, this.ignoreMetadata, reader.ByteOrder);
// todo: tiff frames can have different sizes
// TODO: Tiff frames can have different sizes
ImageFrame<TPixel> root = frames[0];
this.Dimensions = root.Size();
foreach (ImageFrame<TPixel> frame in frames)
{
ImageFrame<TPixel> root = frames[0];
this.Dimensions = root.Size();
foreach (ImageFrame<TPixel> frame in frames)
if (frame.Size() != root.Size())
{
if (frame.Size() != root.Size())
{
TiffThrowHelper.ThrowNotSupported("Images with different sizes are not supported");
}
TiffThrowHelper.ThrowNotSupported("Images with different sizes are not supported");
}
}
var image = new Image<TPixel>(this.Configuration, metadata, frames);
return image;
return new Image<TPixel>(this.Configuration, metadata, frames);
}
/// <inheritdoc/>

11
src/ImageSharp/Formats/Tiff/TiffDecoderMetadataCreator.cs

@ -20,7 +20,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff
public static ImageMetadata Create<TPixel>(List<ImageFrame<TPixel>> frames, List<TiffFrameMetadata> framesMetaData, bool ignoreMetadata, ByteOrder byteOrder)
where TPixel : unmanaged, IPixel<TPixel>
{
DebugGuard.IsTrue(frames.Count() == framesMetaData.Count, nameof(frames), "Image frames and frames metdadata should be the same size.");
DebugGuard.IsTrue(frames.Count == framesMetaData.Count, nameof(frames), "Image frames and frames metadata should be the same size.");
if (framesMetaData.Count < 1)
{
@ -50,12 +50,9 @@ namespace SixLabors.ImageSharp.Formats.Tiff
}
}
if (imageMetaData.IptcProfile == null)
if (imageMetaData.IptcProfile == null && TryGetIptc(frameMetaData.ExifProfile.Values, out byte[] iptcBytes))
{
if (TryGetIptc(frameMetaData.ExifProfile.Values, out byte[] iptcBytes))
{
imageMetaData.IptcProfile = new IptcProfile(iptcBytes);
}
imageMetaData.IptcProfile = new IptcProfile(iptcBytes);
}
if (imageMetaData.IccProfile == null)
@ -146,8 +143,6 @@ namespace SixLabors.ImageSharp.Formats.Tiff
return true;
}
return false;
}
return false;

23
src/ImageSharp/Formats/Tiff/TiffFrameMetadata.cs

@ -217,17 +217,18 @@ namespace SixLabors.ImageSharp.Formats.Tiff
/// <inheritdoc/>
public IDeepCloneable DeepClone()
{
var clone = new TiffFrameMetadata();
clone.FillOrder = this.FillOrder;
clone.Compression = this.Compression;
clone.FaxCompressionOptions = this.FaxCompressionOptions;
clone.SubfileType = this.SubfileType ?? TiffNewSubfileType.FullImage;
clone.OldSubfileType = this.OldSubfileType ?? TiffSubfileType.FullImage;
clone.HorizontalResolution = this.HorizontalResolution ?? ImageMetadata.DefaultHorizontalResolution;
clone.VerticalResolution = this.VerticalResolution ?? ImageMetadata.DefaultVerticalResolution;
clone.ResolutionUnit = this.ResolutionUnit;
clone.PlanarConfiguration = this.PlanarConfiguration;
var clone = new TiffFrameMetadata
{
FillOrder = this.FillOrder,
Compression = this.Compression,
FaxCompressionOptions = this.FaxCompressionOptions,
SubfileType = this.SubfileType ?? TiffNewSubfileType.FullImage,
OldSubfileType = this.OldSubfileType ?? TiffSubfileType.FullImage,
HorizontalResolution = this.HorizontalResolution ?? ImageMetadata.DefaultHorizontalResolution,
VerticalResolution = this.VerticalResolution ?? ImageMetadata.DefaultVerticalResolution,
ResolutionUnit = this.ResolutionUnit,
PlanarConfiguration = this.PlanarConfiguration
};
if (this.ColorMap != null)
{

2
src/ImageSharp/Metadata/ImageFrameMetadata.cs

@ -51,7 +51,7 @@ namespace SixLabors.ImageSharp.Metadata
/// <summary>
/// Gets or sets the XMP profile.
/// </summary>
public byte[] XmpProfile { get; set; }
internal byte[] XmpProfile { get; set; }
/// <inheritdoc/>
public ImageFrameMetadata DeepClone() => new ImageFrameMetadata(this);

Loading…
Cancel
Save