- 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.
43 lines
1.4 KiB
C#
43 lines
1.4 KiB
C#
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);
|
|
}
|
|
}
|
|
}
|