示例#1
0
        public void TransformHonorsFitWhenStretch()
        {
            var operation = new ResizeOperation(
                "Test.png",
                _directory,
                Settings(x => x.SelectedSize.Fit = ResizeFit.Stretch));

            operation.Execute();

            AssertEx.Image(
                _directory.File(),
                image =>
            {
                Assert.Equal(Colors.Black, image.Frames[0].GetFirstPixel());
                Assert.Equal(96, image.Frames[0].PixelWidth);
                Assert.Equal(96, image.Frames[0].PixelHeight);
            });
        }
        public void TransformHonorsShrinkOnlyWhenAutoWidth()
        {
            var operation = new ResizeOperation(
                "Test.png",
                _directory,
                Settings(
                    x =>
            {
                x.ShrinkOnly          = true;
                x.SelectedSize.Width  = 0;
                x.SelectedSize.Height = 288;
            }));

            operation.Execute();

            AssertEx.Image(
                _directory.File(),
                image => Assert.Equal(96, image.Frames[0].PixelHeight));
        }
        public void Transform_honors_shrink_only_when_auto_height()
        {
            var operation = new ResizeOperation(
                "Test.png",
                _directory,
                Settings(
                    x =>
            {
                x.ShrinkOnly          = true;
                x.SelectedSize.Width  = 288;
                x.SelectedSize.Height = 0;
            }));

            operation.Execute();

            AssertEx.Image(
                _directory.File(),
                image => Assert.Equal(192, image.Frames[0].PixelWidth));
        }
示例#4
0
        public void StripMetadataWhenNoMetadataPresent()
        {
            var operation = new ResizeOperation(
                "TestMetadataIssue1928_NoMetadata.jpg",
                _directory,
                Settings(
                    x =>
            {
                x.RemoveMetadata = true;
            }));

            operation.Execute();

            AssertEx.Image(
                _directory.File(),
                image => Assert.IsNull(((BitmapMetadata)image.Frames[0].Metadata).DateTaken));
            AssertEx.Image(
                _directory.File(),
                image => Assert.IsNull(((BitmapMetadata)image.Frames[0].Metadata).GetQuerySafe("System.Photo.Orientation")));
        }
        public void ExecuteKeepsDateModifiedWhenReplacingOriginals()
        {
            var path = Path.Combine(_directory, "Test.png");

            File.Copy("Test.png", path);

            var originalDateModified = File.GetLastWriteTimeUtc(path);

            var operation = new ResizeOperation(
                path,
                null,
                Settings(
                    s =>
            {
                s.KeepDateModified = true;
                s.Replace          = true;
            }));

            operation.Execute();

            Assert.Equal(originalDateModified, File.GetLastWriteTimeUtc(_directory.File()));
        }
        public void TransformIgnoresShrinkOnlyWhenPercent()
        {
            var operation = new ResizeOperation(
                "Test.png",
                _directory,
                Settings(
                    x =>
            {
                x.ShrinkOnly         = true;
                x.SelectedSize.Width = 133.3;
                x.SelectedSize.Unit  = ResizeUnit.Percent;
            }));

            operation.Execute();

            AssertEx.Image(
                _directory.File(),
                image =>
            {
                Assert.Equal(256, image.Frames[0].PixelWidth);
                Assert.Equal(128, image.Frames[0].PixelHeight);
            });
        }
        public void TransformIgnoresIgnoreOrientationWhenAuto()
        {
            var operation = new ResizeOperation(
                "Test.png",
                _directory,
                Settings(
                    x =>
            {
                x.IgnoreOrientation   = true;
                x.SelectedSize.Width  = 96;
                x.SelectedSize.Height = 0;
            }));

            operation.Execute();

            AssertEx.Image(
                _directory.File(),
                image =>
            {
                Assert.Equal(96, image.Frames[0].PixelWidth);
                Assert.Equal(48, image.Frames[0].PixelHeight);
            });
        }
示例#8
0
        public void TransformIgnoresOrientationWhenPortraitToLandscape()
        {
            var operation = new ResizeOperation(
                "TestPortrait.png",
                _directory,
                Settings(
                    x =>
            {
                x.IgnoreOrientation   = true;
                x.SelectedSize.Width  = 192;
                x.SelectedSize.Height = 96;
            }));

            operation.Execute();

            AssertEx.Image(
                _directory.File(),
                image =>
            {
                Assert.AreEqual(96, image.Frames[0].PixelWidth);
                Assert.AreEqual(192, image.Frames[0].PixelHeight);
            });
        }
示例#9
0
        public void Transform_ignores_orientation_when_landscape_to_portrait()
        {
            var operation = new ResizeOperation(
                "Test.png",
                _directory,
                Settings(
                    x =>
            {
                x.IgnoreOrientation   = true;
                x.SelectedSize.Width  = 96;
                x.SelectedSize.Height = 192;
            }));

            operation.Execute();

            AssertEx.Image(
                _directory.File(),
                image =>
            {
                Assert.Equal(192, image.Frames[0].PixelWidth);
                Assert.Equal(96, image.Frames[0].PixelHeight);
            });
        }