diff --git a/NetBarcode/Barcode.cs b/NetBarcode/Barcode.cs
index 6265a19..0a01f5b 100644
--- a/NetBarcode/Barcode.cs
+++ b/NetBarcode/Barcode.cs
@@ -1,10 +1,9 @@
-using NetBarcode.Types;
-using System;
+using System;
using System.IO;
using System.Linq;
+using System.Threading.Tasks;
+using NetBarcode.Types;
using SixLabors.Fonts;
-using SixLabors.ImageSharp.PixelFormats;
-using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Drawing.Processing;
using SixLabors.ImageSharp.Formats;
@@ -16,6 +15,8 @@
using SixLabors.ImageSharp.Formats.Tga;
using SixLabors.ImageSharp.Formats.Tiff;
using SixLabors.ImageSharp.Formats.Webp;
+using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.ImageSharp.Processing;
namespace NetBarcode
{
@@ -496,6 +497,17 @@ public void SaveImageFile(string path, ImageFormat imageFormat = ImageFormat.Jpe
image.Save(path, getImageEncoder(imageFormat));
}
+ ///
+ /// Saves the image to a file async.
+ ///
+ /// The file path for the image.
+ /// The image format. Defaults to Jpeg.
+ public async Task SaveImageFileAsync(string path, ImageFormat imageFormat = ImageFormat.Jpeg)
+ {
+ using (var image = GenerateImage())
+ await image.SaveAsync(path, getImageEncoder(imageFormat));
+ }
+
///
/// Gets the image in PNG format as a Base64 encoded string.
///
@@ -686,7 +698,7 @@ private Image GenerateImage()
{
var labelY = 0;
var labelX = 0;
-
+
switch (_labelPosition)
{
case LabelPosition.TopCenter:
@@ -711,7 +723,7 @@ private Image GenerateImage()
labelTextOptions.Origin = new Point(labelX, labelY);
- image.Mutate(x=> x.DrawText(labelTextOptions, _data, _foregroundColor));
+ image.Mutate(x => x.DrawText(labelTextOptions, _data, _foregroundColor));
}
return image;