public void GetTinyImage_DoesNotChangeSize() { using (var cache = new RuntimeImageProcessor(new BookRenamedEvent()) { TargetDimension = 100 }) using (var file = MakeTempPNGImage(10, 10)) { using (var img = ImageUtils.GetImageFromFile(cache.GetPathToResizedImage(file.Path))) { Assert.AreEqual(10, img.Width); } } }
public void GetWideImage_ReturnsShrunkImageWithCorrectProportions() { using (var cache = new RuntimeImageProcessor(new BookRenamedEvent()) { TargetDimension = 100 }) using (var file = MakeTempPNGImage(200, 80)) { using (var img = ImageUtils.GetImageFromFile(cache.GetPathToResizedImage(file.Path))) { Assert.AreEqual(100, img.Width); Assert.AreEqual(40, img.Height); } } }
public void GetJPG_ReturnsShrunkJPG() { using (var cache = new RuntimeImageProcessor(new BookRenamedEvent()) { TargetDimension = 100 }) using (var file = MakeTempJPGImage(200, 80)) { var pathToResizedImage = cache.GetPathToResizedImage(file.Path); using (var img = ImageUtils.GetImageFromFile(pathToResizedImage)) { Assert.AreEqual(".jpg", Path.GetExtension(pathToResizedImage)); //TODO: why does this always report PNG format? Checks by hand of the file show it as jpg //Assert.AreEqual(ImageFormat.Jpeg.Guid, img.RawFormat.Guid); Assert.AreEqual(100, img.Width); Assert.AreEqual(40, img.Height); } } }