Browse Source

Mark webp as experimental, dont register it in the default config

pull/1552/head
Brian Popow 6 years ago
parent
commit
7505dfe90a
  1. 10
      src/ImageSharp/Configuration.cs
  2. 4
      src/ImageSharp/Formats/WebP/Lossy/Vp8Encoder.cs
  3. 1
      src/ImageSharp/Formats/WebP/WebPDecoder.cs
  4. 1
      src/ImageSharp/Formats/WebP/WebPEncoder.cs
  5. 1
      src/ImageSharp/Formats/WebP/WebPFormat.cs
  6. 1
      src/ImageSharp/Formats/WebP/WebpConfigurationModule.cs
  7. 2
      tests/ImageSharp.Tests/ConfigurationTests.cs
  8. 7
      tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs
  9. 2
      tests/ImageSharp.Tests/Formats/ImageFormatManagerTests.cs
  10. 7
      tests/ImageSharp.Tests/Formats/WebP/WebPDecoderTests.cs

10
src/ImageSharp/Configuration.cs

@ -6,7 +6,6 @@ using System.Collections.Concurrent;
using System.Collections.Generic;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Formats.Bmp;
using SixLabors.ImageSharp.Formats.Experimental.WebP;
using SixLabors.ImageSharp.Formats.Gif;
using SixLabors.ImageSharp.Formats.Jpeg;
using SixLabors.ImageSharp.Formats.Png;
@ -78,7 +77,7 @@ namespace SixLabors.ImageSharp
/// <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
{
@ -95,9 +94,9 @@ namespace SixLabors.ImageSharp
}
/// <summary>
/// Gets a set of properties for the Congiguration.
/// Gets a set of properties for the Configuration.
/// </summary>
/// <remarks>This can be used for storing global settings and defaults to be accessable to processors.</remarks>
/// <remarks>This can be used for storing global settings and defaults to be accessible to processors.</remarks>
public IDictionary<object, object> Properties { get; } = new ConcurrentDictionary<object, object>();
/// <summary>
@ -190,8 +189,7 @@ namespace SixLabors.ImageSharp
new JpegConfigurationModule(),
new GifConfigurationModule(),
new BmpConfigurationModule(),
new TgaConfigurationModule(),
new WebPConfigurationModule());
new TgaConfigurationModule());
}
}
}

4
src/ImageSharp/Formats/WebP/Lossy/Vp8Encoder.cs

@ -181,9 +181,9 @@ namespace SixLabors.ImageSharp.Formats.Experimental.WebP.Lossy
this.filterHeader = new Vp8FilterHeader();
int predSize = (((4 * this.mbw) + 1) * ((4 * this.mbh) + 1)) + this.predsWidth + 1;
this.proba = new Vp8EncProba();
this.Preds = new byte[predSize * 2]; // TODO: figure out how much mem we need here. This is too much.
this.predsWidth = (4 * this.mbw) + 1;
this.proba = new Vp8EncProba();
this.Preds = new byte[predSize + this.predsWidth + this.mbw];
// Initialize with default values, which the reference c implementation uses,
// to be able to compare to the original and spot differences.

1
src/ImageSharp/Formats/WebP/WebPDecoder.cs

@ -12,6 +12,7 @@ using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Formats.Experimental.WebP
{
/// <summary>
/// EXPERIMENTAL:
/// Image decoder for generating an image out of a webp stream.
/// </summary>
public sealed class WebPDecoder : IImageDecoder, IWebPDecoderOptions, IImageInfoDetector

1
src/ImageSharp/Formats/WebP/WebPEncoder.cs

@ -10,6 +10,7 @@ using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Formats.Experimental.WebP
{
/// <summary>
/// EXPERIMENTAL:
/// Image encoder for writing an image to a stream in the WebP format.
/// </summary>
public sealed class WebPEncoder : IImageEncoder, IWebPEncoderOptions

1
src/ImageSharp/Formats/WebP/WebPFormat.cs

@ -6,6 +6,7 @@ using System.Collections.Generic;
namespace SixLabors.ImageSharp.Formats.Experimental.WebP
{
/// <summary>
/// EXPERIMENTAL:
/// Registers the image encoders, decoders and mime type detectors for the WebP format
/// </summary>
public sealed class WebPFormat : IImageFormat<WebPMetadata>

1
src/ImageSharp/Formats/WebP/WebpConfigurationModule.cs

@ -4,6 +4,7 @@
namespace SixLabors.ImageSharp.Formats.Experimental.WebP
{
/// <summary>
/// EXPERIMENTAL:
/// Registers the image encoders, decoders and mime type detectors for the webp format.
/// </summary>
public sealed class WebPConfigurationModule : IConfigurationModule

2
tests/ImageSharp.Tests/ConfigurationTests.cs

@ -21,7 +21,7 @@ namespace SixLabors.ImageSharp.Tests
public Configuration DefaultConfiguration { get; }
private readonly int expectedDefaultConfigurationCount = 6;
private readonly int expectedDefaultConfigurationCount = 5;
public ConfigurationTests()
{

7
tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs

@ -127,11 +127,6 @@ namespace SixLabors.ImageSharp.Tests.Formats
{
image.SaveAsTga(output);
}
using (FileStream output = File.OpenWrite(Path.Combine(path, $"{file.FileNameWithoutExtension}.webp")))
{
image.SaveAsWebp(output);
}
}
}
}
@ -179,8 +174,6 @@ namespace SixLabors.ImageSharp.Tests.Formats
[InlineData(100, 100, "tga")]
[InlineData(100, 10, "tga")]
[InlineData(10, 100, "tga")]
[InlineData(100, 10, "webp")]
[InlineData(10, 100, "webp")]
public void CanIdentifyImageLoadedFromBytes(int width, int height, string extension)
{
using (var image = Image.LoadPixelData(new Rgba32[width * height], width, height))

2
tests/ImageSharp.Tests/Formats/ImageFormatManagerTests.cs

@ -37,14 +37,12 @@ namespace SixLabors.ImageSharp.Tests.Formats
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<WebPEncoder>().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<WebPDecoder>().Count());
}
[Fact]

7
tests/ImageSharp.Tests/Formats/WebP/WebPDecoderTests.cs

@ -20,6 +20,13 @@ namespace SixLabors.ImageSharp.Tests.Formats.WebP
private static MagickReferenceDecoder ReferenceDecoder => new MagickReferenceDecoder();
public WebPDecoderTests()
{
Configuration.Default.ImageFormatsManager.AddImageFormat(WebPFormat.Instance);
Configuration.Default.ImageFormatsManager.AddImageFormatDetector(new WebPImageFormatDetector());
Configuration.Default.ImageFormatsManager.SetDecoder(WebPFormat.Instance, new WebPDecoder());
}
[Theory]
[InlineData(Lossless.GreenTransform1, 1000, 307, 32)]
[InlineData(Lossless.BikeThreeTransforms, 250, 195, 32)]

Loading…
Cancel
Save