Browse Source

Rename extension

pull/1574/head
James Jackson-South 6 years ago
parent
commit
29eb7efdde
  1. 20
      src/ImageSharp/Advanced/AdvancedImageExtensions.cs
  2. 4
      src/ImageSharp/ImageExtensions.cs
  3. 2
      tests/ImageSharp.Tests/Image/ImageTests.SaveAsync.cs

20
src/ImageSharp/Advanced/AdvancedImageExtensions.cs

@ -18,16 +18,16 @@ namespace SixLabors.ImageSharp.Advanced
public static class AdvancedImageExtensions
{
/// <summary>
/// For a given path find the best encoder to use
/// For a given file path find the best encoder to use via its extension.
/// </summary>
/// <param name="source">The source.</param>
/// <param name="path">The Path</param>
/// <param name="source">The source image.</param>
/// <param name="filePath">The target file path to save the image to.</param>
/// <returns>The matching encoder.</returns>
public static IImageEncoder FindEncoded(this Image source, string path)
public static IImageEncoder DetectEncoder(this Image source, string filePath)
{
Guard.NotNull(path, nameof(path));
Guard.NotNull(filePath, nameof(filePath));
string ext = Path.GetExtension(path);
string ext = Path.GetExtension(filePath);
IImageFormat format = source.GetConfiguration().ImageFormatsManager.FindFormatByFileExtension(ext);
if (format is null)
{
@ -62,8 +62,8 @@ namespace SixLabors.ImageSharp.Advanced
/// Accepts a <see cref="IImageVisitor"/> to implement a double-dispatch pattern in order to
/// apply pixel-specific operations on non-generic <see cref="Image"/> instances
/// </summary>
/// <param name="source">The source.</param>
/// <param name="visitor">The visitor.</param>
/// <param name="source">The source image.</param>
/// <param name="visitor">The image visitor.</param>
public static void AcceptVisitor(this Image source, IImageVisitor visitor)
=> source.Accept(visitor);
@ -71,8 +71,8 @@ namespace SixLabors.ImageSharp.Advanced
/// Accepts a <see cref="IImageVisitor"/> to implement a double-dispatch pattern in order to
/// apply pixel-specific operations on non-generic <see cref="Image"/> instances
/// </summary>
/// <param name="source">The source.</param>
/// <param name="visitor">The visitor.</param>
/// <param name="source">The source image.</param>
/// <param name="visitor">The image visitor.</param>
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
public static async Task AcceptVisitorAsync(this Image source, IImageVisitorAsync visitor)
=> await source.AcceptAsync(visitor).ConfigureAwait(false);

4
src/ImageSharp/ImageExtensions.cs

@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp
/// <param name="path">The file path to save the image to.</param>
/// <exception cref="ArgumentNullException">The path is null.</exception>
public static void Save(this Image source, string path)
=> source.Save(path, source.FindEncoded(path));
=> source.Save(path, source.DetectEncoder(path));
/// <summary>
/// Writes the image to the given stream using the currently loaded image format.
@ -33,7 +33,7 @@ namespace SixLabors.ImageSharp
/// <exception cref="ArgumentNullException">The path is null.</exception>
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
public static Task SaveAsync(this Image source, string path)
=> source.SaveAsync(path, source.FindEncoded(path));
=> source.SaveAsync(path, source.DetectEncoder(path));
/// <summary>
/// Writes the image to the given stream using the currently loaded image format.

2
tests/ImageSharp.Tests/Image/ImageTests.SaveAsync.cs

@ -95,7 +95,7 @@ namespace SixLabors.ImageSharp.Tests
{
using (var image = new Image<Rgba32>(5, 5))
{
IImageEncoder encoder = image.FindEncoded(filename);
IImageEncoder encoder = image.DetectEncoder(filename);
using (var stream = new MemoryStream())
{
var asyncStream = new AsyncStreamWrapper(stream, () => false);

Loading…
Cancel
Save