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.
2026-03-08 11:17:47 +01:00
|
|
|
using System.IO;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
|
|
|
using SixLabors.ImageSharp.PixelFormats;
|
|
|
|
|
using MaddoShared.ImageSharpTests.Helpers;
|
2026-03-12 19:40:58 +01:00
|
|
|
using Shouldly;
|
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.
2026-03-08 11:17:47 +01:00
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
2026-03-12 19:40:58 +01:00
|
|
|
(bottomCount > 50).ShouldBeTrue($"Expected text pixels in bottom band, found {bottomCount}");
|
|
|
|
|
(bottomCount > topCount).ShouldBeTrue("Expected more non-background pixels at bottom than top");
|
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.
2026-03-08 11:17:47 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|