Browse Source

Merge branch 'master' into js/png-decode-to-type

pull/1861/head
James Jackson-South 4 years ago
parent
commit
a63bf58e6a
  1. 3
      .github/ISSUE_TEMPLATE/config.yml
  2. 2
      .github/ISSUE_TEMPLATE/oss-bug-report.md
  3. 2
      README.md
  4. 9
      src/ImageSharp/Common/Helpers/Guard.cs
  5. 7
      src/ImageSharp/Formats/Tiff/Compression/Compressors/DeflateCompressor.cs
  6. 12
      src/ImageSharp/Formats/Tiff/Ifd/DirectoryReader.cs
  7. 2
      src/ImageSharp/Formats/Tiff/Ifd/EntryReader.cs
  8. 6
      src/ImageSharp/ImageSharp.csproj
  9. 12
      tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs
  10. 1
      tests/ImageSharp.Tests/TestImages.cs
  11. 3
      tests/Images/Input/Tiff/Issues/Issue1891.tiff

3
.github/ISSUE_TEMPLATE/config.yml

@ -1,8 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: Ask a Question
url: https://github.com/SixLabors/ImageSharp/discussions?discussions_q=category%3AQ%26A
about: Ask a question about this project.
- name: Feature Request
url: https://github.com/SixLabors/ImageSharp/discussions?discussions_q=category%3AIdeas
about: Share ideas for new features for this project.

2
.github/ISSUE_TEMPLATE/oss-bug-report.md

@ -1,6 +1,6 @@
---
name: "OSS : Bug Report"
about: Create a report to help us improve the project.
about: Create a report to help us improve the project. OSS Issues are not guaranteed to be triaged.
labels: needs triage
---

2
README.md

@ -20,7 +20,7 @@ ImageSharp is a new, fully featured, fully managed, cross-platform, 2D graphics
ImageSharp is designed from the ground up to be flexible and extensible. The library provides API endpoints for common image processing operations and the building blocks to allow for the development of additional operations.
Built against [.NET Standard 1.3](https://docs.microsoft.com/en-us/dotnet/standard/net-standard), ImageSharp can be used in device, cloud, and embedded/IoT scenarios.
Built against [.NET Standard 2.0](https://docs.microsoft.com/en-us/dotnet/standard/net-standard), ImageSharp can be used in device, cloud, and embedded/IoT scenarios.
## License

9
src/ImageSharp/Common/Helpers/Guard.cs

@ -2,9 +2,6 @@
// Licensed under the Apache License, Version 2.0.
using System;
#if NETSTANDARD1_3
using System.Reflection;
#endif
using System.Runtime.CompilerServices;
using SixLabors.ImageSharp;
@ -22,11 +19,7 @@ namespace SixLabors
[MethodImpl(InliningOptions.ShortMethod)]
public static void MustBeValueType<TValue>(TValue value, string parameterName)
{
if (value.GetType()
#if NETSTANDARD1_3
.GetTypeInfo()
#endif
.IsValueType)
if (value.GetType().IsValueType)
{
return;
}

7
src/ImageSharp/Formats/Tiff/Compression/Compressors/DeflateCompressor.cs

@ -43,15 +43,8 @@ namespace SixLabors.ImageSharp.Formats.Tiff.Compression.Compressors
}
int size = (int)this.memoryStream.Position;
#if !NETSTANDARD1_3
byte[] buffer = this.memoryStream.GetBuffer();
this.Output.Write(buffer, 0, size);
#else
this.memoryStream.SetLength(size);
this.memoryStream.Position = 0;
this.memoryStream.CopyTo(this.Output);
#endif
}
/// <inheritdoc/>

12
src/ImageSharp/Formats/Tiff/Ifd/DirectoryReader.cs

@ -18,9 +18,11 @@ namespace SixLabors.ImageSharp.Formats.Tiff
private uint nextIfdOffset;
private const int DirectoryMax = 65534;
// used for sequential read big values (actual for multiframe big files)
// todo: different tags can link to the same data (stream offset) - investigate
private readonly SortedList<uint, Action> lazyLoaders = new SortedList<uint, Action>(new DuplicateKeyComparer<uint>());
private readonly SortedList<uint, Action> lazyLoaders = new(new DuplicateKeyComparer<uint>());
public DirectoryReader(Stream stream) => this.stream = stream;
@ -48,7 +50,8 @@ namespace SixLabors.ImageSharp.Formats.Tiff
{
return ByteOrder.LittleEndian;
}
else if (headerBytes[0] == TiffConstants.ByteOrderBigEndian && headerBytes[1] == TiffConstants.ByteOrderBigEndian)
if (headerBytes[0] == TiffConstants.ByteOrderBigEndian && headerBytes[1] == TiffConstants.ByteOrderBigEndian)
{
return ByteOrder.BigEndian;
}
@ -67,6 +70,11 @@ namespace SixLabors.ImageSharp.Formats.Tiff
this.nextIfdOffset = reader.NextIfdOffset;
readers.Add(reader);
if (readers.Count >= DirectoryMax)
{
TiffThrowHelper.ThrowImageFormatException("TIFF image contains too many directories");
}
}
// Sequential reading big values.

2
src/ImageSharp/Formats/Tiff/Ifd/EntryReader.cs

@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff
this.lazyLoaders = lazyLoaders;
}
public List<IExifValue> Values { get; } = new List<IExifValue>();
public List<IExifValue> Values { get; } = new();
public uint NextIfdOffset { get; private set; }

6
src/ImageSharp/ImageSharp.csproj

@ -23,12 +23,12 @@
<Choose>
<When Condition="$(SIXLABORS_TESTING_PREVIEW) == true">
<PropertyGroup>
<TargetFrameworks>net6.0;net5.0;netcoreapp3.1;netcoreapp2.1;netstandard2.1;netstandard2.0;netstandard1.3;net472</TargetFrameworks>
<TargetFrameworks>net6.0;net5.0;netcoreapp3.1;netcoreapp2.1;netstandard2.1;netstandard2.0;net472</TargetFrameworks>
</PropertyGroup>
</When>
<When Condition="$(SIXLABORS_TESTING) == true">
<PropertyGroup>
<TargetFrameworks>net5.0;netcoreapp3.1;netcoreapp2.1;netstandard2.1;netstandard2.0;netstandard1.3;net472</TargetFrameworks>
<TargetFrameworks>net5.0;netcoreapp3.1;netcoreapp2.1;netstandard2.1;netstandard2.0;net472</TargetFrameworks>
</PropertyGroup>
</When>
<When Condition="$(Configuration.EndsWith('InnerLoop')) == true">
@ -38,7 +38,7 @@
</When>
<Otherwise>
<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;netcoreapp2.1;netstandard2.1;netstandard2.0;netstandard1.3;net472</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;netcoreapp2.1;netstandard2.1;netstandard2.0;net472</TargetFrameworks>
</PropertyGroup>
</Otherwise>
</Choose>

12
tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs

@ -380,6 +380,18 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff
public void TiffDecoder_CanDecode_JpegCompressed<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel> => TestTiffDecoder(provider, useExactComparer: false);
// https://github.com/SixLabors/ImageSharp/issues/1891
[Theory]
[WithFile(Issues1891, PixelTypes.Rgba32)]
public void TiffDecoder_ThrowsException_WithTooManyDirectories<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel> => Assert.Throws<ImageFormatException>(
() =>
{
using (provider.GetImage(TiffDecoder))
{
}
});
[Theory]
[WithFileCollection(nameof(MultiframeTestImages), PixelTypes.Rgba32)]
public void DecodeMultiframe<TPixel>(TestImageProvider<TPixel> provider)

1
tests/ImageSharp.Tests/TestImages.cs

@ -840,6 +840,7 @@ namespace SixLabors.ImageSharp.Tests
public const string Flower32BitGrayPredictorLittleEndian = "Tiff/flower-minisblack-32_lsb_deflate_predictor.tiff";
public const string Issues1716Rgb161616BitLittleEndian = "Tiff/Issues/Issue1716.tiff";
public const string Issues1891 = "Tiff/Issues/Issue1891.tiff";
public const string SmallRgbDeflate = "Tiff/rgb_small_deflate.tiff";
public const string SmallRgbLzw = "Tiff/rgb_small_lzw.tiff";

3
tests/Images/Input/Tiff/Issues/Issue1891.tiff

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a2779c7fb2c2ad858e0d7efcfffd594cc6fb2846e0475a2998a3cda50f289b9b
size 307
Loading…
Cancel
Save