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
50
MaddoShared.ImageSharpTests/Tests/TextPositioningTests.cs
Normal file
50
MaddoShared.ImageSharpTests/Tests/TextPositioningTests.cs
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
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 TextPositioningTests
|
||||
{
|
||||
[TestMethod]
|
||||
public async Task TextAtBottom_IncreasesNonBackgroundPixelCountInBottomBand()
|
||||
{
|
||||
using var ws = new TempWorkspace();
|
||||
|
||||
// create white background input
|
||||
var inputPath = TestImageFactory.CreateSolidJpeg(ws.SourceDir.FullName, "input.jpg", 800, 600, new Rgba32(255, 255, 255, 255));
|
||||
|
||||
var pic = CreatorFactory.CreateDefaultPicSettings();
|
||||
pic.Posizione = "BASSO";
|
||||
pic.DimStandard = 48; // big text
|
||||
pic.TestoFirmaStart = "SAMPLE TEXT";
|
||||
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);
|
||||
|
||||
// bottom band (lower 25% of image)
|
||||
var bottomY = (int)(600 * 0.75);
|
||||
var bottomCount = PixelInspector.CountNonBackgroundPixels(outPath, 0, bottomY, 800, 600 - bottomY, new Rgba32(255, 255, 255, 255), tolerance: 10);
|
||||
|
||||
// top band (upper 25%)
|
||||
var topCount = PixelInspector.CountNonBackgroundPixels(outPath, 0, 0, 800, (int)(600 * 0.25), new Rgba32(255, 255, 255, 255), tolerance: 10);
|
||||
|
||||
Assert.IsTrue(bottomCount > 50, $"Expected text pixels in bottom band, found {bottomCount}");
|
||||
Assert.IsTrue(bottomCount > topCount, "Expected more non-background pixels at bottom than top");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue