diff options
author | crupest <crupest@outlook.com> | 2021-04-27 18:52:57 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-04-27 18:52:57 +0800 |
commit | 1b751781f0681a047f3d3d6097009478886ee2f5 (patch) | |
tree | 4710ab0c761a264f090f9aa74a45e62fd39450f8 /BackEnd/Timeline/Services/Imaging/IImageService.cs | |
parent | 6c9778b55dd8367d38280c66e0f308c5332029ed (diff) | |
download | timeline-1b751781f0681a047f3d3d6097009478886ee2f5.tar.gz timeline-1b751781f0681a047f3d3d6097009478886ee2f5.tar.bz2 timeline-1b751781f0681a047f3d3d6097009478886ee2f5.zip |
refactor: ...
Diffstat (limited to 'BackEnd/Timeline/Services/Imaging/IImageService.cs')
-rw-r--r-- | BackEnd/Timeline/Services/Imaging/IImageService.cs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/BackEnd/Timeline/Services/Imaging/IImageService.cs b/BackEnd/Timeline/Services/Imaging/IImageService.cs new file mode 100644 index 00000000..9e595ff8 --- /dev/null +++ b/BackEnd/Timeline/Services/Imaging/IImageService.cs @@ -0,0 +1,32 @@ +using SixLabors.ImageSharp.Formats;
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Timeline.Services.Imaging
+{
+ public interface IImageService
+ {
+ /// <summary>
+ /// Detect the format of a image.
+ /// </summary>
+ /// <param name="data"></param>
+ /// <param name="cancellationToken"></param>
+ /// <returns>The image format.</returns>
+ /// <exception cref="ArgumentNullException">Thrown when <paramref name="data"/> is null.</exception>
+ /// <exception cref="ImageException">Thrown when image data can't be detected.</exception>
+ Task<IImageFormat> DetectFormatAsync(byte[] data, CancellationToken cancellationToken = default);
+
+ /// <summary>
+ /// Validate a image data.
+ /// </summary>
+ /// <param name="data">The data of the image. Can't be null.</param>
+ /// <param name="requestType">If not null, the real image format will be check against the requested format and throw if not match. If null, then do not check.</param>
+ /// <param name="square">If true, image must be square.</param>
+ /// <param name="cancellationToken">Cancellation token.</param>
+ /// <returns>The format.</returns>
+ /// <exception cref="ArgumentNullException">Thrown when <paramref name="data"/> is null.</exception>
+ /// <exception cref="ImageException">Thrown when image data can't be decoded or real type does not match request type or image is not square when required.</exception>
+ Task<IImageFormat> ValidateAsync(byte[] data, string? requestType = null, bool square = false, CancellationToken cancellationToken = default);
+ }
+}
|