-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
92 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
az-appservice-dotnet/services/v1/ImageProcessing/UpsideDownImageProcesserService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
namespace az_appservice_dotnet.services.v1.ImageProcessing; | ||
|
||
public class UpsideDownImageProcessorService : IImageProcessorService | ||
{ | ||
public Task<string> ProcessImageAsync(string imageFilePath) | ||
{ | ||
if (!File.Exists(imageFilePath)) | ||
{ | ||
throw new FileNotFoundException($"UpsideDownImageProcessorService: File not found: {imageFilePath}"); | ||
} | ||
|
||
var fileInfo = new FileInfo(imageFilePath); | ||
if (fileInfo.Length > 100 * 1024 * 1024) | ||
{ | ||
throw new FileLoadException($"UpsideDownImageProcessorService: File too large: {imageFilePath}"); | ||
} | ||
|
||
return Task.Run(() => | ||
{ | ||
using (Image image = Image.Load(imageFilePath)) | ||
{ | ||
image.Mutate(x => x.Flip(FlipMode.Vertical)); | ||
var tmpFilePath = Path.GetTempFileName() + ".jpg"; | ||
image.SaveAsJpeg(tmpFilePath); | ||
return tmpFilePath; | ||
} | ||
}); | ||
} | ||
|
||
public bool CanProcessImage(string imageFilePath) | ||
{ | ||
return imageFilePath.EndsWith(".jpg", StringComparison.InvariantCultureIgnoreCase) || | ||
imageFilePath.EndsWith(".png", StringComparison.InvariantCultureIgnoreCase); | ||
} | ||
|
||
public string[] SupportedFormats | ||
{ | ||
get { return new[] { "*.jpg", "*.png" }; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters