Implement ImageCreatorImageSharp using SixLabors.ImageSharp for image processing
- Added ImageCreatorImageSharp class for image creation, handling EXIF orientation, resizing, and saving images. - Replaced GDI+ dependencies with ImageSharp for cross-platform compatibility. - Introduced methods for drawing text and logos on images, including handling transparency and positioning. - Created a test plan for validating ImageCreatorImageSharp functionality, focusing on image resizing, text positioning, logo features, and EXIF orientation. - Added documentation for the test plan outlining goals, project structure, and implementation notes.
This commit is contained in:
parent
90fb03bf0c
commit
d62342aae1
11 changed files with 455 additions and 74 deletions
45
MaddoShared.ImageSharpTests/Helpers/TestImageFactory.cs
Normal file
45
MaddoShared.ImageSharpTests/Helpers/TestImageFactory.cs
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
using System.IO;
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
using SixLabors.ImageSharp.Processing;
|
||||
using SixLabors.ImageSharp.Formats.Jpeg;
|
||||
using SixLabors.ImageSharp.Metadata.Profiles.Exif;
|
||||
|
||||
namespace MaddoShared.ImageSharpTests.Helpers
|
||||
{
|
||||
public static class TestImageFactory
|
||||
{
|
||||
public static string CreateSolidJpeg(string directory, string fileName, int width, int height, Rgba32 color)
|
||||
{
|
||||
Directory.CreateDirectory(directory);
|
||||
var path = Path.Combine(directory, fileName);
|
||||
using var img = new Image<Rgba32>(width, height, color);
|
||||
var encoder = new JpegEncoder { Quality = 90 };
|
||||
img.Save(path, encoder);
|
||||
return path;
|
||||
}
|
||||
|
||||
public static string CreateSolidPng(string directory, string fileName, int width, int height, Rgba32 color)
|
||||
{
|
||||
Directory.CreateDirectory(directory);
|
||||
var path = Path.Combine(directory, fileName);
|
||||
using var img = new Image<Rgba32>(width, height, color);
|
||||
img.SaveAsPng(path);
|
||||
return path;
|
||||
}
|
||||
|
||||
public static string CreateJpegWithExifOrientation(string directory, string fileName, int width, int height, Rgba32 color, ushort orientation)
|
||||
{
|
||||
Directory.CreateDirectory(directory);
|
||||
var path = Path.Combine(directory, fileName);
|
||||
using var img = new Image<Rgba32>(width, height, color);
|
||||
// Add EXIF orientation
|
||||
var profile = new ExifProfile();
|
||||
profile.SetValue(ExifTag.Orientation, orientation);
|
||||
img.Metadata.ExifProfile = profile;
|
||||
var encoder = new JpegEncoder { Quality = 90 };
|
||||
img.Save(path, encoder);
|
||||
return path;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue