public void ShouldMakeFileSmallerWhenStreamIsCompressibleGifStream()
                {
                    var optimizer = new ImageOptimizer();

                    AssertCompress(Files.FujiFilmFinePixS1ProGIF, true, (Stream stream) =>
                    {
                        return(optimizer.LosslessCompress(stream));
                    });
                }
Exemple #2
0
                public void ShouldThrowExceptionWhenFileNameIsNull()
                {
                    var optimizer = new ImageOptimizer();

                    Assert.Throws <ArgumentNullException>("fileName", () =>
                    {
                        optimizer.Compress((string)null);
                    });
                }
Exemple #3
0
                public void ShouldNotThrowExceptionWhenIgnoringUnsupportedFileName()
                {
                    var optimizer = new ImageOptimizer {
                        IgnoreUnsupportedFormats = true
                    };
                    var compressionSuccess = optimizer.Compress(Files.InvitationTIF);

                    Assert.False(compressionSuccess);
                }
Exemple #4
0
                public void ShouldThrowExceptionWhenFileIsNull()
                {
                    var optimizer = new ImageOptimizer();

                    ExceptionAssert.Throws <ArgumentNullException>("file", () =>
                    {
                        optimizer.IsSupported((FileInfo)null);
                    });
                }
Exemple #5
0
                public void ShouldNotMakeFileSmallerWhenFileIsUncompressibleIcoFile()
                {
                    var optimizer = new ImageOptimizer();

                    AssertCompress(Files.ImageMagickICO, false, (FileInfo file) =>
                    {
                        return(optimizer.Compress(file));
                    });
                }
                public void ShouldThrowExceptionWhenFileNameIsNull()
                {
                    var optimizer = new ImageOptimizer();

                    ExceptionAssert.ThrowsArgumentNullException("fileName", () =>
                    {
                        optimizer.IsSupported((string)null);
                    });
                }
Exemple #7
0
                public void ShouldThrowExceptionWhenStreamIsNull()
                {
                    var optimizer = new ImageOptimizer();

                    ExceptionAssert.Throws <ArgumentNullException>("stream", () =>
                    {
                        optimizer.IsSupported((Stream)null);
                    });
                }
                public void ShouldNotMakeFileSmallerWhenStreamIsUncompressiblePngFile()
                {
                    var optimizer = new ImageOptimizer();

                    AssertCompress(Files.MagickNETIconPNG, false, (Stream stream) =>
                    {
                        return(optimizer.Compress(stream));
                    });
                }
                public void ShouldMakeFileSmallerWhenFileIsCompressibleIcoFile()
                {
                    var optimizer = new ImageOptimizer();

                    AssertCompress(Files.WandICO, true, (FileInfo file) =>
                    {
                        return(optimizer.Compress(file));
                    });
                }
                public void ShouldNotMakeFileSmallerWhenFileNameIsUncompressibleJpgFile()
                {
                    var optimizer = new ImageOptimizer();

                    AssertCompress(Files.LetterJPG, false, (string fileName) =>
                    {
                        return(optimizer.Compress(fileName));
                    });
                }
                public void ShouldMakeFileSmallerWhenStreamIsCompressibleIcoFile()
                {
                    var optimizer = new ImageOptimizer();

                    AssertCompress(Files.WandICO, true, (Stream stream) =>
                    {
                        return(optimizer.Compress(stream));
                    });
                }
                public void ShouldMakeFileSmallerWhenFileNameIsCompressiblePnggFile()
                {
                    var optimizer = new ImageOptimizer();

                    AssertCompress(Files.SnakewarePNG, true, (string fileName) =>
                    {
                        return(optimizer.Compress(fileName));
                    });
                }
                public void ShouldNotMakeFileSmallerWhenStreamIsCompressibleGifStream()
                {
                    var optimizer = new ImageOptimizer();

                    AssertCompress(Files.RoseSparkleGIF, false, (Stream stream) =>
                    {
                        return(optimizer.LosslessCompress(stream));
                    });
                }
                public void ShouldNotMakeFileSmallerWhenStreamIsCompressibleIcoStream()
                {
                    var optimizer = new ImageOptimizer();

                    AssertCompress(Files.ImageMagickICO, false, (Stream stream) =>
                    {
                        return(optimizer.LosslessCompress(stream));
                    });
                }
                public void ShouldThrowExceptionWhenFileIsNull()
                {
                    var optimizer = new ImageOptimizer();

                    ExceptionAssert.ThrowsArgumentNullException("file", () =>
                    {
                        optimizer.LosslessCompress((FileInfo)null);
                    });
                }
Exemple #16
0
                public void ShouldReturnFalseWhenStreamCannotRead()
                {
                    var optimizer = new ImageOptimizer();

                    using (var stream = new TestStream(false, true, true))
                    {
                        Assert.False(optimizer.IsSupported(stream));
                    }
                }
                public void ShouldThrowExceptionWhenFileNameIsInvalid()
                {
                    var optimizer = new ImageOptimizer();

                    ExceptionAssert.Throws <MagickBlobErrorException>(() =>
                    {
                        optimizer.LosslessCompress(Files.Missing);
                    }, "error/blob.c/OpenBlob");
                }
                public void ShouldThrowExceptionWhenFileIsUnsupportedFormat()
                {
                    var optimizer = new ImageOptimizer();

                    ExceptionAssert.Throws <MagickCorruptImageErrorException>(() =>
                    {
                        optimizer.LosslessCompress(Files.InvitationTIF);
                    }, "Invalid format");
                }
                public void ShouldThrowExceptionWhenFileNameIsEmpty()
                {
                    var optimizer = new ImageOptimizer();

                    ExceptionAssert.ThrowsArgumentException("fileName", () =>
                    {
                        optimizer.IsSupported(string.Empty);
                    });
                }
                public void ShouldMakeFileSmallerWhenFileNameIsCompressibleJpgFile()
                {
                    var optimizer = new ImageOptimizer();

                    AssertCompress(Files.ImageMagickJPG, true, (string file) =>
                    {
                        return(optimizer.LosslessCompress(file));
                    });
                }
Exemple #21
0
                public void ShouldReturnFalseWhenStreamCannotSeek()
                {
                    var optimizer = new ImageOptimizer();

                    using (TestStream stream = new TestStream(true, true, false))
                    {
                        Assert.IsFalse(optimizer.IsSupported(stream));
                    }
                }
                public void ShouldNotMakeFileSmallerWhenFileNameIsUncompressiblePngFile()
                {
                    var optimizer = new ImageOptimizer();

                    AssertCompress(Files.MagickNETIconPNG, false, (string file) =>
                    {
                        return(optimizer.LosslessCompress(file));
                    });
                }
Exemple #23
0
                public void ShouldMakeFileSmallerWhenFileIsCompressibleGifFile()
                {
                    var optimizer = new ImageOptimizer();

                    AssertCompress(Files.FujiFilmFinePixS1ProGIF, true, (FileInfo file) =>
                    {
                        return(optimizer.Compress(file));
                    });
                }
                public void ShouldThrowExceptionWhenStreamIsNull()
                {
                    var optimizer = new ImageOptimizer();

                    ExceptionAssert.ThrowsArgumentNullException("stream", () =>
                    {
                        optimizer.LosslessCompress((Stream)null);
                    });
                }
Exemple #25
0
                public void ShouldNotMakeFileSmallerWhenFileIsUncompressibleGifFile()
                {
                    var optimizer = new ImageOptimizer();

                    AssertCompress(Files.RoseSparkleGIF, false, (FileInfo file) =>
                    {
                        return(optimizer.Compress(file));
                    });
                }
                public void ShouldMakeFileSmallerWhenStreamIsCompressiblePngFile()
                {
                    var optimizer = new ImageOptimizer();

                    AssertCompress(Files.SnakewarePNG, true, (Stream file) =>
                    {
                        return(optimizer.LosslessCompress(file));
                    });
                }
Exemple #27
0
                public void ShouldThrowExceptionWhenFileNameIsEmpty()
                {
                    var optimizer = new ImageOptimizer();

                    Assert.Throws <ArgumentException>("fileName", () =>
                    {
                        optimizer.Compress(string.Empty);
                    });
                }
                public void ShouldNotMakeFileSmallerWhenStreamIsCompressibleJpgFile()
                {
                    var optimizer = new ImageOptimizer();

                    AssertCompress(Files.LetterJPG, false, (Stream file) =>
                    {
                        return(optimizer.LosslessCompress(file));
                    });
                }
                public void ShouldMakeFileSmallerWhenStreamIsCompressibleJpgStrea()
                {
                    var optimizer = new ImageOptimizer();

                    AssertCompress(Files.ImageMagickJPG, true, (Stream stream) =>
                    {
                        return(optimizer.LosslessCompress(stream));
                    });
                }
Exemple #30
0
        private static void Compress(string file)
        {
            ImageOptimizer optimizer = new ImageOptimizer()
            {
                OptimalCompression       = true,
                IgnoreUnsupportedFormats = true
            };

            optimizer.LosslessCompress(file);
        }