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); 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]; if (frame.Size() != root.Size())
this.Dimensions = root.Size();
foreach (ImageFrame<TPixel> frame in frames)
{ {
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 new Image<TPixel>(this.Configuration, metadata, frames);
return image;
} }
/// <inheritdoc/> /// <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) public static ImageMetadata Create<TPixel>(List<ImageFrame<TPixel>> frames, List<TiffFrameMetadata> framesMetaData, bool ignoreMetadata, ByteOrder byteOrder)
where TPixel : unmanaged, IPixel<TPixel> 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) 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) if (imageMetaData.IccProfile == null)
@ -146,8 +143,6 @@ namespace SixLabors.ImageSharp.Formats.Tiff
return true; return true;
} }
return false;
} }
return false; return false;

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

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

2
src/ImageSharp/Metadata/ImageFrameMetadata.cs

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

Loading…
Cancel
Save