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
43
MaddoShared.ImageSharpTests/Tests/ImageResizingTests.cs
Normal file
43
MaddoShared.ImageSharpTests/Tests/ImageResizingTests.cs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
using MaddoShared.ImageSharpTests.Helpers;
|
||||
|
||||
namespace MaddoShared.ImageSharpTests.Tests
|
||||
{
|
||||
[TestClass]
|
||||
public class ImageResizingTests
|
||||
{
|
||||
[TestMethod]
|
||||
public async Task BigImageResizesRespectSettings()
|
||||
{
|
||||
using var ws = new TempWorkspace();
|
||||
|
||||
// create a large input image
|
||||
var inputPath = TestImageFactory.CreateSolidJpeg(ws.SourceDir.FullName, "input.jpg", 1600, 1200, new Rgba32(200, 200, 200, 255));
|
||||
|
||||
var pic = CreatorFactory.CreateDefaultPicSettings();
|
||||
pic.LarghezzaBig = 800;
|
||||
pic.AltezzaBig = 600;
|
||||
pic.CreaMiniature = false;
|
||||
|
||||
var svc = CreatorFactory.CreateImageCreator(pic);
|
||||
|
||||
var state = new MaddoShared.ImageState
|
||||
{
|
||||
WorkFile = new FileInfo(inputPath),
|
||||
DestDir = ws.DestDir,
|
||||
SourceDir = ws.SourceDir
|
||||
};
|
||||
|
||||
await svc.CreateImageAsync(state, null);
|
||||
|
||||
var outPath = Path.Combine(ws.DestDir.FullName, state.NomeFileBig);
|
||||
using var outImg = SixLabors.ImageSharp.Image.Load<Rgba32>(outPath);
|
||||
|
||||
Assert.AreEqual(800, outImg.Width);
|
||||
Assert.AreEqual(600, outImg.Height);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue