Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/ImageSharp/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using SixLabors.ImageSharp.Formats.Jpeg;
using SixLabors.ImageSharp.Formats.Png;
using SixLabors.ImageSharp.Formats.Tga;
using SixLabors.ImageSharp.Formats.Tiff;
using SixLabors.ImageSharp.IO;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.Processing;
Expand Down Expand Up @@ -39,7 +40,7 @@ public Configuration()
/// <summary>
/// Initializes a new instance of the <see cref="Configuration" /> class.
/// </summary>
/// <param name="configurationModules">A collection of configuration modules to register</param>
/// <param name="configurationModules">A collection of configuration modules to register.</param>
public Configuration(params IConfigurationModule[] configurationModules)
{
if (configurationModules != null)
Expand Down Expand Up @@ -77,7 +78,7 @@ public int MaxDegreeOfParallelism

/// <summary>
/// Gets or sets the size of the buffer to use when working with streams.
/// Intitialized with <see cref="DefaultStreamProcessingBufferSize"/> by default.
/// Initialized with <see cref="DefaultStreamProcessingBufferSize"/> by default.
/// </summary>
public int StreamProcessingBufferSize
{
Expand Down Expand Up @@ -180,6 +181,7 @@ public Configuration Clone()
/// <see cref="GifConfigurationModule"/>
/// <see cref="BmpConfigurationModule"/>.
/// <see cref="TgaConfigurationModule"/>.
/// <see cref="TiffConfigurationModule"/>.
/// </summary>
/// <returns>The default configuration of <see cref="Configuration"/>.</returns>
internal static Configuration CreateDefaultInstance()
Expand All @@ -189,7 +191,8 @@ internal static Configuration CreateDefaultInstance()
new JpegConfigurationModule(),
new GifConfigurationModule(),
new BmpConfigurationModule(),
new TgaConfigurationModule());
new TgaConfigurationModule(),
new TiffConfigurationModule());
}
}
}
23 changes: 0 additions & 23 deletions src/ImageSharp/Formats/Tiff/ConfigurationExtensions.cs

This file was deleted.

4 changes: 1 addition & 3 deletions tests/ImageSharp.Benchmarks/Codecs/DecodeTiff.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

using BenchmarkDotNet.Attributes;

using SixLabors.ImageSharp.Formats.Tiff;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Tests;

Expand All @@ -23,7 +22,7 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs
[Config(typeof(Config.ShortMultiFramework))]
public class DecodeTiff
{
private string prevImage = null;
private string prevImage;

private byte[] data;

Expand Down Expand Up @@ -68,7 +67,6 @@ public void Config()
if (this.configuration == null)
{
this.configuration = new Configuration();
this.configuration.AddTiff();
this.configuration.StreamProcessingBufferSize = BufferSize;
}
}
Expand Down
2 changes: 0 additions & 2 deletions tests/ImageSharp.Benchmarks/Codecs/EncodeTiff.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ public void ReadImages()
if (this.core == null)
{
this.configuration = new Configuration();
this.configuration.AddTiff();

this.core = Image.Load<Rgba32>(this.configuration, this.TestImageFullPath);
this.drawing = System.Drawing.Image.FromFile(this.TestImageFullPath);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/ImageSharp.Tests/ConfigurationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ public class ConfigurationTests

public Configuration DefaultConfiguration { get; }

private readonly int expectedDefaultConfigurationCount = 5;
private readonly int expectedDefaultConfigurationCount = 6;

public ConfigurationTests()
{
// the shallow copy of configuration should behave exactly like the default configuration,
// The shallow copy of configuration should behave exactly like the default configuration,
// so by using the copy, we test both the default and the copy.
this.DefaultConfiguration = Configuration.CreateDefaultInstance().Clone();
this.ConfigurationEmpty = new Configuration();
Expand Down
11 changes: 10 additions & 1 deletion tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace SixLabors.ImageSharp.Tests.Formats
public class GeneralFormatTests
{
/// <summary>
/// A collection made up of one file for each image format
/// A collection made up of one file for each image format.
/// </summary>
public static readonly IEnumerable<string> DefaultFiles =
new[]
Expand Down Expand Up @@ -149,6 +149,11 @@ public void ImageCanConvertFormat()
{
image.SaveAsTga(output);
}

using (FileStream output = File.OpenWrite(Path.Combine(path, $"{file.FileNameWithoutExtension}.tiff")))
{
image.SaveAsTga(output);
}
}
}
}
Expand Down Expand Up @@ -196,6 +201,10 @@ public void ImageShouldPreservePixelByteOrderWhenSerialized()
[InlineData(100, 100, "tga")]
[InlineData(100, 10, "tga")]
[InlineData(10, 100, "tga")]
[InlineData(100, 100, "tiff")]
[InlineData(100, 10, "tiff")]
[InlineData(10, 100, "tiff")]

public void CanIdentifyImageLoadedFromBytes(int width, int height, string extension)
{
using (var image = Image.LoadPixelData(new Rgba32[width * height], width, height))
Expand Down
3 changes: 3 additions & 0 deletions tests/ImageSharp.Tests/Formats/ImageFormatManagerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using SixLabors.ImageSharp.Formats.Jpeg;
using SixLabors.ImageSharp.Formats.Png;
using SixLabors.ImageSharp.Formats.Tga;
using SixLabors.ImageSharp.Formats.Tiff;
using SixLabors.ImageSharp.PixelFormats;
using Xunit;

Expand All @@ -36,12 +37,14 @@ public void IfAutoLoadWellKnownFormatsIsTrueAllFormatsAreLoaded()
Assert.Equal(1, this.DefaultFormatsManager.ImageEncoders.Select(item => item.Value).OfType<JpegEncoder>().Count());
Assert.Equal(1, this.DefaultFormatsManager.ImageEncoders.Select(item => item.Value).OfType<GifEncoder>().Count());
Assert.Equal(1, this.DefaultFormatsManager.ImageEncoders.Select(item => item.Value).OfType<TgaEncoder>().Count());
Assert.Equal(1, this.DefaultFormatsManager.ImageEncoders.Select(item => item.Value).OfType<TiffEncoder>().Count());

Assert.Equal(1, this.DefaultFormatsManager.ImageDecoders.Select(item => item.Value).OfType<PngDecoder>().Count());
Assert.Equal(1, this.DefaultFormatsManager.ImageDecoders.Select(item => item.Value).OfType<BmpDecoder>().Count());
Assert.Equal(1, this.DefaultFormatsManager.ImageDecoders.Select(item => item.Value).OfType<JpegDecoder>().Count());
Assert.Equal(1, this.DefaultFormatsManager.ImageDecoders.Select(item => item.Value).OfType<BmpDecoder>().Count());
Assert.Equal(1, this.DefaultFormatsManager.ImageDecoders.Select(item => item.Value).OfType<TgaDecoder>().Count());
Assert.Equal(1, this.DefaultFormatsManager.ImageDecoders.Select(item => item.Value).OfType<TiffDecoder>().Count());
}

[Fact]
Expand Down
40 changes: 16 additions & 24 deletions tests/ImageSharp.Tests/Formats/Tiff/ImageExtensionsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,18 @@ namespace SixLabors.ImageSharp.Tests.Formats.Tiff
[Trait("Format", "Tiff")]
public class ImageExtensionsTest
{
private readonly Configuration configuration;

public ImageExtensionsTest()
{
this.configuration = new Configuration();
this.configuration.AddTiff();
}

[Fact]
public void SaveAsTiff_Path()
{
string dir = TestEnvironment.CreateOutputDirectory(nameof(ImageExtensionsTest));
string file = Path.Combine(dir, "SaveAsTiff_Path.tiff");

using (var image = new Image<Rgba32>(this.configuration, 10, 10))
using (var image = new Image<Rgba32>(10, 10))
{
image.SaveAsTiff(file);
}

using (Image.Load(this.configuration, file, out IImageFormat mime))
using (Image.Load(file, out IImageFormat mime))
{
Assert.Equal("image/tiff", mime.DefaultMimeType);
}
Expand All @@ -44,12 +36,12 @@ public async Task SaveAsTiffAsync_Path()
string dir = TestEnvironment.CreateOutputDirectory(nameof(ImageExtensionsTest));
string file = Path.Combine(dir, "SaveAsTiffAsync_Path.tiff");

using (var image = new Image<Rgba32>(this.configuration, 10, 10))
using (var image = new Image<Rgba32>(10, 10))
{
await image.SaveAsTiffAsync(file);
}

using (Image.Load(this.configuration, file, out IImageFormat mime))
using (Image.Load(file, out IImageFormat mime))
{
Assert.Equal("image/tiff", mime.DefaultMimeType);
}
Expand All @@ -61,12 +53,12 @@ public void SaveAsTiff_Path_Encoder()
string dir = TestEnvironment.CreateOutputDirectory(nameof(ImageExtensions));
string file = Path.Combine(dir, "SaveAsTiff_Path_Encoder.tiff");

using (var image = new Image<Rgba32>(this.configuration, 10, 10))
using (var image = new Image<Rgba32>(10, 10))
{
image.SaveAsTiff(file, new TiffEncoder());
}

using (Image.Load(this.configuration, file, out IImageFormat mime))
using (Image.Load(file, out IImageFormat mime))
{
Assert.Equal("image/tiff", mime.DefaultMimeType);
}
Expand All @@ -78,12 +70,12 @@ public async Task SaveAsTiffAsync_Path_Encoder()
string dir = TestEnvironment.CreateOutputDirectory(nameof(ImageExtensions));
string file = Path.Combine(dir, "SaveAsTiffAsync_Path_Encoder.tiff");

using (var image = new Image<Rgba32>(this.configuration, 10, 10))
using (var image = new Image<Rgba32>(10, 10))
{
await image.SaveAsTiffAsync(file, new TiffEncoder());
}

using (Image.Load(this.configuration, file, out IImageFormat mime))
using (Image.Load(file, out IImageFormat mime))
{
Assert.Equal("image/tiff", mime.DefaultMimeType);
}
Expand All @@ -94,14 +86,14 @@ public void SaveAsTiff_Stream()
{
using var memoryStream = new MemoryStream();

using (var image = new Image<Rgba32>(this.configuration, 10, 10))
using (var image = new Image<Rgba32>(10, 10))
{
image.SaveAsTiff(memoryStream);
}

memoryStream.Position = 0;

using (Image.Load(this.configuration, memoryStream, out IImageFormat mime))
using (Image.Load(memoryStream, out IImageFormat mime))
{
Assert.Equal("image/tiff", mime.DefaultMimeType);
}
Expand All @@ -112,14 +104,14 @@ public async Task SaveAsTiffAsync_StreamAsync()
{
using var memoryStream = new MemoryStream();

using (var image = new Image<Rgba32>(this.configuration, 10, 10))
using (var image = new Image<Rgba32>(10, 10))
{
await image.SaveAsTiffAsync(memoryStream);
}

memoryStream.Position = 0;

using (Image.Load(this.configuration, memoryStream, out IImageFormat mime))
using (Image.Load(memoryStream, out IImageFormat mime))
{
Assert.Equal("image/tiff", mime.DefaultMimeType);
}
Expand All @@ -130,14 +122,14 @@ public void SaveAsTiff_Stream_Encoder()
{
using var memoryStream = new MemoryStream();

using (var image = new Image<Rgba32>(this.configuration, 10, 10))
using (var image = new Image<Rgba32>(10, 10))
{
image.SaveAsTiff(memoryStream, new TiffEncoder());
}

memoryStream.Position = 0;

using (Image.Load(this.configuration, memoryStream, out IImageFormat mime))
using (Image.Load(memoryStream, out IImageFormat mime))
{
Assert.Equal("image/tiff", mime.DefaultMimeType);
}
Expand All @@ -148,14 +140,14 @@ public async Task SaveAsTiffAsync_Stream_Encoder()
{
using var memoryStream = new MemoryStream();

using (var image = new Image<Rgba32>(this.configuration, 10, 10))
using (var image = new Image<Rgba32>(10, 10))
{
await image.SaveAsTiffAsync(memoryStream, new TiffEncoder());
}

memoryStream.Position = 0;

using (Image.Load(this.configuration, memoryStream, out IImageFormat mime))
using (Image.Load(memoryStream, out IImageFormat mime))
{
Assert.Equal("image/tiff", mime.DefaultMimeType);
}
Expand Down
14 changes: 3 additions & 11 deletions tests/ImageSharp.Tests/Formats/Tiff/TiffDecoderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,6 @@ public class TiffDecoderTests

private static MagickReferenceDecoder ReferenceDecoder => new MagickReferenceDecoder();

private readonly Configuration configuration;

public TiffDecoderTests()
{
this.configuration = new Configuration();
this.configuration.AddTiff();
}

[Theory]
[WithFileCollection(nameof(NotSupportedImages), PixelTypes.Rgba32)]
public void ThrowsNotSupported<TPixel>(TestImageProvider<TPixel> provider)
Expand All @@ -50,7 +42,7 @@ public void Identify(string imagePath, int expectedPixelSize, int expectedWidth,
var testFile = TestFile.Create(imagePath);
using (var stream = new MemoryStream(testFile.Bytes, false))
{
IImageInfo info = Image.Identify(this.configuration, stream);
IImageInfo info = Image.Identify(stream);

Assert.Equal(expectedPixelSize, info.PixelType?.BitsPerPixel);
Assert.Equal(expectedWidth, info.Width);
Expand All @@ -70,14 +62,14 @@ public void ByteOrder(string imagePath, ByteOrder expectedByteOrder)
var testFile = TestFile.Create(imagePath);
using (var stream = new MemoryStream(testFile.Bytes, false))
{
IImageInfo info = Image.Identify(this.configuration, stream);
IImageInfo info = Image.Identify(stream);

Assert.NotNull(info.Metadata);
Assert.Equal(expectedByteOrder, info.Metadata.GetTiffMetadata().ByteOrder);

stream.Seek(0, SeekOrigin.Begin);

using var img = Image.Load(this.configuration, stream);
using var img = Image.Load(stream);
Assert.Equal(expectedByteOrder, img.Metadata.GetTiffMetadata().ByteOrder);
}
}
Expand Down
Loading