mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 11:11:10 +00:00
Reorganizes the shared media library enumerations and adds the image file extension helper
This commit is contained in:
1 parent
ed96046769
commit
5529e99024
11 files changed
+286
-50
No files matched your search
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.PhotoLibrary;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Infrastructure.Common.Utilities;
|
||||
|
||||
/// <summary>
|
||||
/// Provides helpers for the <see cref="ImageType"/> enumeration.
|
||||
/// </summary>
|
||||
public static class ImageTypeUtilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the conventional file extension of the provided <paramref name="imageType"/>, without the leading dot.
|
||||
/// </summary>
|
||||
/// <param name="imageType">The image type whose file extension is resolved.</param>
|
||||
/// <returns>The file extension of the image type, or <c>bin</c> when the type is not a recognized image.</returns>
|
||||
public static string ToFileExtension(this ImageType imageType)
|
||||
{
|
||||
return imageType switch
|
||||
{
|
||||
ImageType.BMP => "bmp",
|
||||
ImageType.GIF => "gif",
|
||||
ImageType.PNG => "png",
|
||||
ImageType.TIFF => "tiff",
|
||||
ImageType.JPEG or ImageType.JPEG_CANON or ImageType.JPEG_UNKNOWN => "jpg",
|
||||
ImageType.PICT => "pct",
|
||||
ImageType.ICO => "ico",
|
||||
ImageType.PSD => "psd",
|
||||
ImageType.JPEG2000 => "jp2",
|
||||
ImageType.AVIF => "avif",
|
||||
ImageType.WEBP => "webp",
|
||||
ImageType.TGA => "tga",
|
||||
ImageType.SVG => "svg",
|
||||
_ => "bin"
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user