Example #1
0
        public void Encode_IgnoreMetadataIsFalse_CommentsAreWritten()
        {
            EncoderOptions options = new EncoderOptions()
            {
                IgnoreMetadata = false
            };

            TestFile testFile = TestFile.Create(TestImages.Gif.Rings);

            using (Image input = testFile.CreateImage())
            {
                using (MemoryStream memStream = new MemoryStream())
                {
                    input.Save(memStream, new GifFormat(), options);

                    memStream.Position = 0;
                    using (Image output = Image.Load(memStream))
                    {
                        Assert.Equal(1, output.MetaData.Properties.Count);
                        Assert.Equal("Comments", output.MetaData.Properties[0].Name);
                        Assert.Equal("ImageSharp", output.MetaData.Properties[0].Value);
                    }
                }
            }
        }
Example #2
0
        public void Decode_IgnoreMetadataIsTrue_ExifProfileIgnored()
        {
            JpegDecoder options = new JpegDecoder()
            {
                IgnoreMetadata = true
            };

            TestFile testFile = TestFile.Create(TestImages.Jpeg.Baseline.Floorplan);

            using (Image <Rgba32> image = testFile.CreateImage(options))
            {
                Assert.Null(image.MetaData.ExifProfile);
            }
        }
Example #3
0
        public void Decode_IgnoreMetadataIsFalse_ExifProfileIsRead()
        {
            JpegDecoder decoder = new JpegDecoder()
            {
                IgnoreMetadata = false
            };

            TestFile testFile = TestFile.Create(TestImages.Jpeg.Baseline.Floorplan);

            using (Image <Rgba32> image = testFile.CreateImage(decoder))
            {
                Assert.NotNull(image.MetaData.ExifProfile);
            }
        }
Example #4
0
        public void Decode_IgnoreMetadataIsTrue_TextChunksAreIgnored()
        {
            PngDecoderOptions options = new PngDecoderOptions()
            {
                IgnoreMetadata = true
            };

            TestFile testFile = TestFile.Create(TestImages.Png.Blur);

            using (Image image = testFile.CreateImage(options))
            {
                Assert.Equal(0, image.MetaData.Properties.Count);
            }
        }
Example #5
0
        public void Decode_IgnoreMetadataIsTrue_CommentsAreIgnored()
        {
            DecoderOptions options = new DecoderOptions()
            {
                IgnoreMetadata = true
            };

            TestFile testFile = TestFile.Create(TestImages.Gif.Rings);

            using (Image <Rgba32> image = testFile.CreateImage(options))
            {
                Assert.Equal(0, image.MetaData.Properties.Count);
            }
        }
Example #6
0
        public void Decode_IgnoreMetadataIsFalse_ExifProfileIsRead()
        {
            DecoderOptions options = new DecoderOptions()
            {
                IgnoreMetadata = false
            };

            TestFile testFile = TestFile.Create(TestImages.Jpeg.Baseline.Floorplan);

            using (Image image = testFile.CreateImage(options))
            {
                Assert.NotNull(image.MetaData.ExifProfile);
            }
        }
Example #7
0
        public void Decode_TextEncodingSetToUnicode_TextIsReadWithCorrectEncoding()
        {
            PngDecoderOptions options = new PngDecoderOptions()
            {
                TextEncoding = Encoding.Unicode
            };

            TestFile testFile = TestFile.Create(TestImages.Png.Blur);

            using (Image image = testFile.CreateImage(options))
            {
                Assert.Equal(1, image.MetaData.Properties.Count);
                Assert.Equal("潓瑦慷敲", image.MetaData.Properties[0].Name);
            }
        }
Example #8
0
        public void Decode_TextEncodingSetToUnicode_TextIsReadWithCorrectEncoding()
        {
            GifDecoderOptions options = new GifDecoderOptions()
            {
                TextEncoding = Encoding.Unicode
            };

            TestFile testFile = TestFile.Create(TestImages.Gif.Rings);

            using (Image <Rgba32> image = testFile.CreateImage(options))
            {
                Assert.Equal(1, image.MetaData.Properties.Count);
                Assert.Equal("浉条卥慨灲", image.MetaData.Properties[0].Value);
            }
        }
Example #9
0
        public void Decode_IgnoreMetadataIsFalse_TextChunckIsRead()
        {
            PngDecoderOptions options = new PngDecoderOptions()
            {
                IgnoreMetadata = false
            };

            TestFile testFile = TestFile.Create(TestImages.Png.Blur);

            using (Image image = testFile.CreateImage(options))
            {
                Assert.Equal(1, image.MetaData.Properties.Count);
                Assert.Equal("Software", image.MetaData.Properties[0].Name);
                Assert.Equal("paint.net 4.0.6", image.MetaData.Properties[0].Value);
            }
        }
Example #10
0
        public void Decode_IgnoreMetadataIsFalse_CommentsAreRead()
        {
            DecoderOptions options = new DecoderOptions()
            {
                IgnoreMetadata = false
            };

            TestFile testFile = TestFile.Create(TestImages.Gif.Rings);

            using (Image <Rgba32> image = testFile.CreateImage(options))
            {
                Assert.Equal(1, image.MetaData.Properties.Count);
                Assert.Equal("Comments", image.MetaData.Properties[0].Name);
                Assert.Equal("ImageSharp", image.MetaData.Properties[0].Value);
            }
        }
Example #11
0
        public void Save_DetecedEncoding()
        {
            string file = TestFile.GetPath("../../TestOutput/Save_DetecedEncoding.png");

            System.IO.DirectoryInfo dir = System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(file));
            using (Image image = new Image(10, 10))
            {
                image.Save(file);
            }

            TestFile c = TestFile.Create("../../TestOutput/Save_DetecedEncoding.png");

            using (Image img = c.CreateImage())
            {
                Assert.IsType <PngFormat>(img.CurrentImageFormat);
            }
        }
Example #12
0
        public void Save_SetFormat()
        {
            string file = TestFile.GetPath("../../TestOutput/Save_SetFormat.dat");

            System.IO.DirectoryInfo dir = System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(file));
            using (Image <Rgba32> image = new Image <Rgba32>(10, 10))
            {
                image.Save(file, new PngFormat());
            }

            TestFile c = TestFile.Create("../../TestOutput/Save_SetFormat.dat");

            using (Image <Rgba32> img = c.CreateImage())
            {
                Assert.IsType <PngFormat>(img.CurrentImageFormat);
            }
        }
Example #13
0
        public void ImageShouldFlip(RotateType rotateType, FlipType flipType, ushort orientation)
        {
            string path = this.CreateOutputDirectory("AutoOrient");

            TestFile file = TestFile.Create(TestImages.Bmp.F);

            using (Image image = file.CreateImage())
            {
                image.MetaData.ExifProfile = new ExifProfile();
                image.MetaData.ExifProfile.SetValue(ExifTag.Orientation, orientation);

                using (FileStream before = File.OpenWrite($"{path}/before-{file.FileName}"))
                    using (FileStream after = File.OpenWrite($"{path}/after-{file.FileName}"))
                    {
                        image.RotateFlip(rotateType, flipType).Save(before).AutoOrient().Save(after);
                    }
            }
        }
Example #14
0
        public void Encode_IgnoreMetadataIsTrue_CommentsAreNotWritten()
        {
            GifEncoderOptions options = new GifEncoderOptions()
            {
                IgnoreMetadata = true
            };

            TestFile testFile = TestFile.Create(TestImages.Gif.Rings);

            using (Image input = testFile.CreateImage())
            {
                using (MemoryStream memStream = new MemoryStream())
                {
                    input.SaveAsGif(memStream, options);

                    memStream.Position = 0;
                    using (Image output = Image.Load(memStream))
                    {
                        Assert.Equal(0, output.MetaData.Properties.Count);
                    }
                }
            }
        }
Example #15
0
        public void Encode_IgnoreMetadataIsFalse_ExifProfileIsWritten()
        {
            EncoderOptions options = new EncoderOptions()
            {
                IgnoreMetadata = false
            };

            TestFile testFile = TestFile.Create(TestImages.Jpeg.Baseline.Floorplan);

            using (Image input = testFile.CreateImage())
            {
                using (MemoryStream memStream = new MemoryStream())
                {
                    input.Save(memStream, new JpegFormat(), options);

                    memStream.Position = 0;
                    using (Image output = Image.Load(memStream))
                    {
                        Assert.NotNull(output.MetaData.ExifProfile);
                    }
                }
            }
        }
Example #16
0
        public void Encode_IgnoreMetadataIsTrue_ExifProfileIgnored()
        {
            JpegEncoderOptions options = new JpegEncoderOptions()
            {
                IgnoreMetadata = true
            };

            TestFile testFile = TestFile.Create(TestImages.Jpeg.Baseline.Floorplan);

            using (Image input = testFile.CreateImage())
            {
                using (MemoryStream memStream = new MemoryStream())
                {
                    input.SaveAsJpeg(memStream, options);

                    memStream.Position = 0;
                    using (Image output = Image.Load(memStream))
                    {
                        Assert.Null(output.MetaData.ExifProfile);
                    }
                }
            }
        }