Пример #1
0
        public void CropPng()
        {
            var rendition = new MediaTransformation(new MediaSource("1045645"), "png")
                .Resize(100, 100)
                .Crop(0, 0, 85, 20);

            Assert.Equal("100x100/crop:0-0_85x20.png", rendition.GetFullName());
            Assert.Equal("1045645/100x100/crop:0-0_85x20.png", rendition.GetPath());

            var rendition2 = MediaTransformation.ParsePath(rendition.GetPath());

            Assert.Equal("1045645", rendition2.Source.Key);
            Assert.Equal("png", rendition2.Format);
            Assert.Equal(2, rendition2.GetTransforms().Count);
            Assert.Equal("100x100", rendition2.GetTransforms()[0].ToString());
            Assert.Equal("crop:0-0_85x20", rendition2.GetTransforms()[1].ToString());
        }
Пример #2
0
        public void Filters()
        {
            var transformation = new MediaTransformation(new MediaSource("1045645", 100, 50), "jpeg")
                .Transform(new ApplyFilter("contrast", "2"))
                .Transform(new ApplyFilter("grayscale", "1"))
                .Transform(new ApplyFilter("sepia", "1"));

            Assert.Equal(100, transformation.Width);
            Assert.Equal(50, transformation.Height);

            Assert.Equal("contrast(2)/grayscale(1)/sepia(1).jpeg", transformation.GetFullName());

            var rendition2 = MediaTransformation.ParsePath(transformation.GetPath());
            Assert.Equal(3, rendition2.GetTransforms().Count);

            Assert.Equal("contrast", ((ApplyFilter)rendition2.GetTransforms()[0]).Name);
            Assert.Equal("grayscale", ((ApplyFilter)rendition2.GetTransforms()[1]).Name);
            Assert.Equal("sepia", ((ApplyFilter)rendition2.GetTransforms()[2]).Name);
        }
Пример #3
0
        public void RotatedSizeIsCorrect()
        {
            var rendition = new MediaTransformation(new MediaSource("1", 100, 50), "jpeg").Rotate(90);

            Assert.Equal(50, rendition.Width);
            Assert.Equal(100, rendition.Height);

            Assert.Equal("1/rotate(90).jpeg", rendition.GetPath());
        }
Пример #4
0
        public void ResizeJpeg()
        {
            var rendition = new MediaTransformation(new MediaSource("64a5e3944d4f11c05cde1a60efa9b86e9c4c6e54f3cb17269454472fdfa88d89"), "jpeg").Resize(85, 20);

            Assert.Equal("85x20.jpeg", rendition.GetFullName());
            Assert.Equal("64a5e3944d4f11c05cde1a60efa9b86e9c4c6e54f3cb17269454472fdfa88d89/85x20.jpeg", rendition.GetPath());

            var rendition2 = MediaTransformation.ParsePath(rendition.GetPath());

            Assert.Equal("jpeg", rendition2.Format);
            Assert.Equal(1, rendition2.GetTransforms().Count);
            Assert.Equal("85x20", rendition2.GetTransforms()[0].ToString());
        }
Пример #5
0
        public void ResizedJpegUriIsCorrect()
        {
            var rendition = new MediaTransformation(new MediaSource("64a5e3944d4f11c05cde1a60efa9b86e9c4c6e54f3cb17269454472fdfa88d89"), "jpeg").Resize(85, 20);

            Assert.Equal("64a5e3944d4f11c05cde1a60efa9b86e9c4c6e54f3cb17269454472fdfa88d89/85x20.jpeg", rendition.GetPath());
        }
Пример #6
0
        public void ResizeAndRotated90()
        {
            var rendition = new MediaTransformation(new MediaSource("1045645"), "jpeg")
                .Resize(50, 50)
                .Crop(0, 0, 85, 20)
                .Rotate(90);

            Assert.Equal("50x50/crop:0-0_85x20/rotate(90).jpeg", rendition.GetFullName());

            var rendition2 = MediaTransformation.ParsePath(rendition.GetPath());

            Assert.Equal(20, rendition.Width);
            Assert.Equal(85, rendition.Height);

            Assert.Equal(3, rendition2.GetTransforms().Count);

            Assert.Equal(90, ((Rotate)rendition2.GetTransforms()[2]).Angle);
        }
Пример #7
0
        public void OrientedPhotoHasCorrectThings()
        {
            var rendition = new MediaTransformation(new MediaSource("1", 100, 50), MediaOrientation.Rotate90, "jpeg");

            Assert.Equal(50, rendition.Width);
            Assert.Equal(100, rendition.Height);

            Assert.Equal("rotate(90)", rendition.GetTransforms()[0].ToString());

            Assert.Equal("1/rotate(90).jpeg", rendition.GetPath());
        }