diff --git a/src/ImageSharp/IImage.cs b/src/ImageSharp/IImage.cs
index 4612daa2d4..b9e2cee616 100644
--- a/src/ImageSharp/IImage.cs
+++ b/src/ImageSharp/IImage.cs
@@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0.
using System;
-using SixLabors.Primitives;
namespace SixLabors.ImageSharp
{
@@ -11,16 +10,5 @@ namespace SixLabors.ImageSharp
///
public interface IImage : IImageInfo, IDisposable
{
- ///
- /// Gets the size of the image.
- ///
- /// The
- Size Size();
-
- ///
- /// Gets the bounds of the image.
- ///
- /// The
- Rectangle Bounds();
}
}
\ No newline at end of file
diff --git a/src/ImageSharp/ImageInfoExtensions.cs b/src/ImageSharp/ImageInfoExtensions.cs
new file mode 100644
index 0000000000..0f2b2ba975
--- /dev/null
+++ b/src/ImageSharp/ImageInfoExtensions.cs
@@ -0,0 +1,27 @@
+// Copyright (c) Six Labors and contributors.
+// Licensed under the Apache License, Version 2.0.
+
+using SixLabors.Primitives;
+
+namespace SixLabors.ImageSharp
+{
+ ///
+ /// Extension methods that allow the addition of geometry calculating methods to the type
+ ///
+ public static class ImageInfoExtensions
+ {
+ ///
+ /// Gets the bounds of the image.
+ ///
+ /// The image info
+ /// The
+ public static Size Size(this IImageInfo info) => new Size(info.Width, info.Height);
+
+ ///
+ /// Gets the bounds of the image.
+ ///
+ /// The image info
+ /// The
+ public static Rectangle Bounds(this IImageInfo info) => new Rectangle(0, 0, info.Width, info.Height);
+ }
+}
diff --git a/src/ImageSharp/Image{TPixel}.cs b/src/ImageSharp/Image{TPixel}.cs
index 66ae13db89..78a091e414 100644
--- a/src/ImageSharp/Image{TPixel}.cs
+++ b/src/ImageSharp/Image{TPixel}.cs
@@ -10,7 +10,6 @@ using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.MetaData;
using SixLabors.ImageSharp.PixelFormats;
-using SixLabors.Primitives;
namespace SixLabors.ImageSharp
{
@@ -18,7 +17,7 @@ namespace SixLabors.ImageSharp
/// Encapsulates an image, which consists of the pixel data for a graphics image and its attributes.
///
/// The pixel format.
- public sealed partial class Image : IImage, IConfigurable
+ public sealed class Image : IImage, IConfigurable
where TPixel : struct, IPixel
{
private readonly Configuration configuration;
@@ -123,12 +122,6 @@ namespace SixLabors.ImageSharp
set => this.PixelSource.PixelBuffer[x, y] = value;
}
- ///
- public Size Size() => new Size(this.Width, this.Height);
-
- ///
- public Rectangle Bounds() => new Rectangle(0, 0, this.Width, this.Height);
-
///
/// Saves the image to the given stream using the given image encoder.
///
diff --git a/src/ImageSharp/MetaData/ImageMetaData.cs b/src/ImageSharp/MetaData/ImageMetaData.cs
index e36f2a69f2..9613e9b465 100644
--- a/src/ImageSharp/MetaData/ImageMetaData.cs
+++ b/src/ImageSharp/MetaData/ImageMetaData.cs
@@ -2,8 +2,6 @@
// Licensed under the Apache License, Version 2.0.
using System.Collections.Generic;
-using SixLabors.ImageSharp.Formats;
-using SixLabors.ImageSharp.Formats.Gif;
using SixLabors.ImageSharp.MetaData.Profiles.Exif;
using SixLabors.ImageSharp.MetaData.Profiles.Icc;
diff --git a/tests/ImageSharp.Tests/ImageInfoTests.cs b/tests/ImageSharp.Tests/ImageInfoTests.cs
new file mode 100644
index 0000000000..91f6804c0f
--- /dev/null
+++ b/tests/ImageSharp.Tests/ImageInfoTests.cs
@@ -0,0 +1,34 @@
+// Copyright (c) Six Labors and contributors.
+// Licensed under the Apache License, Version 2.0.
+
+using SixLabors.ImageSharp.Formats;
+using SixLabors.ImageSharp.MetaData;
+using SixLabors.Primitives;
+
+using Xunit;
+
+namespace SixLabors.ImageSharp.Tests
+{
+ public class ImageInfoTests
+ {
+ [Fact]
+ public void ImageInfoInitializesCorrectly()
+ {
+ const int Width = 50;
+ const int Height = 60;
+ var size = new Size(Width, Height);
+ var rectangle = new Rectangle(0, 0, Width, Height);
+ var pixelType = new PixelTypeInfo(8);
+ var meta = new ImageMetaData();
+
+ var info = new ImageInfo(pixelType, Width, Height, meta);
+
+ Assert.Equal(pixelType, info.PixelType);
+ Assert.Equal(Width, info.Width);
+ Assert.Equal(Height, info.Height);
+ Assert.Equal(size, info.Size());
+ Assert.Equal(rectangle, info.Bounds());
+ Assert.Equal(meta, info.MetaData);
+ }
+ }
+}