1- using NetBarcode . Types ;
2- using System ;
1+ using System ;
32using System . IO ;
43using System . Linq ;
4+ using System . Threading . Tasks ;
5+ using NetBarcode . Types ;
56using SixLabors . Fonts ;
6- using SixLabors . ImageSharp . PixelFormats ;
7- using SixLabors . ImageSharp . Processing ;
87using SixLabors . ImageSharp ;
98using SixLabors . ImageSharp . Drawing . Processing ;
109using SixLabors . ImageSharp . Formats ;
1615using SixLabors . ImageSharp . Formats . Tga ;
1716using SixLabors . ImageSharp . Formats . Tiff ;
1817using SixLabors . ImageSharp . Formats . Webp ;
18+ using SixLabors . ImageSharp . PixelFormats ;
19+ using SixLabors . ImageSharp . Processing ;
1920
2021namespace NetBarcode
2122{
@@ -496,6 +497,17 @@ public void SaveImageFile(string path, ImageFormat imageFormat = ImageFormat.Jpe
496497 image . Save ( path , getImageEncoder ( imageFormat ) ) ;
497498 }
498499
500+ /// <summary>
501+ /// Saves the image to a file async.
502+ /// </summary>
503+ /// <param name="path">The file path for the image.</param>
504+ /// <param name="imageFormat">The image format. Defaults to Jpeg.</param>
505+ public async Task SaveImageFileAsync ( string path , ImageFormat imageFormat = ImageFormat . Jpeg )
506+ {
507+ using ( var image = GenerateImage ( ) )
508+ await image . SaveAsync ( path , getImageEncoder ( imageFormat ) ) ;
509+ }
510+
499511 /// <summary>
500512 /// Gets the image in PNG format as a Base64 encoded string.
501513 /// </summary>
@@ -686,7 +698,7 @@ private Image GenerateImage()
686698 {
687699 var labelY = 0 ;
688700 var labelX = 0 ;
689-
701+
690702 switch ( _labelPosition )
691703 {
692704 case LabelPosition . TopCenter :
@@ -711,7 +723,7 @@ private Image GenerateImage()
711723
712724 labelTextOptions . Origin = new Point ( labelX , labelY ) ;
713725
714- image . Mutate ( x=> x . DrawText ( labelTextOptions , _data , _foregroundColor ) ) ;
726+ image . Mutate ( x => x . DrawText ( labelTextOptions , _data , _foregroundColor ) ) ;
715727 }
716728
717729 return image ;
0 commit comments