From dc613fb5495c125d213ad55b50ca49c41c2a66a8 Mon Sep 17 00:00:00 2001 From: James South Date: Sat, 5 Jul 2014 13:31:06 +0100 Subject: [PATCH] Adding updated tests and reducing image sizes. Former-commit-id: 054373e5c704ca0ca2a26770863549b2eeca7165 --- .../Extensions/DoubleExtensionsUnitTests.cs | 15 ++-- .../Extensions/IntegerExtensionsUnitTests.cs | 5 +- .../Extensions/StringExtensionsUnitTests.cs | 90 ++++++++++++------- .../Images/autorotate.jpg.REMOVED.git-id | 2 +- .../cmyk-profile-euroscale.jpg.REMOVED.git-id | 2 +- .../Images/cmyk.jpg.REMOVED.git-id | 2 +- .../color-vision-test.gif.REMOVED.git-id | 2 +- .../Images/exif-Tulips.jpg.REMOVED.git-id | 2 +- .../Images/exif-rocks.jpg.REMOVED.git-id | 2 +- .../format-Penguins-8bit.png.REMOVED.git-id | 2 +- .../Images/format-Penguins.bmp.REMOVED.git-id | 2 +- .../Images/format-Penguins.gif.REMOVED.git-id | 2 +- .../Images/format-Penguins.jpg.REMOVED.git-id | 2 +- .../Images/format-Penguins.png.REMOVED.git-id | 2 +- .../Images/format-animated.gif | 3 - .../Images/format-animated.gif.REMOVED.git-id | 1 + .../Images/hi-color.png | 4 +- .../Images/hi-contrast.jpg | 4 +- .../Images/hi-saturation.jpg | 4 +- .../profile-adobe-rgb.jpg.REMOVED.git-id | 2 +- .../Images/profile-srgb.jpg.REMOVED.git-id | 2 +- .../Images/size-Penguins-200.jpg | 4 +- .../Images/text-over-transparent.png | 4 +- .../Images/udendørs.jpg | 3 + .../Images/udendørs.jpg.REMOVED.git-id | 1 - src/ImageProcessor/ImageFactory.cs | 5 +- .../Imaging/Formats/GifEncoder.cs | 10 +-- .../Imaging/Formats/JpegFormat.cs | 2 +- src/ImageProcessorConsole/Program.cs | 19 ++-- .../images/output/120430.gif.REMOVED.git-id | 2 +- .../images/output/Tl4Yb.gif.REMOVED.git-id | 2 +- .../images/output/circle.png | 3 + .../images/output/nLpfllv.gif.REMOVED.git-id | 2 +- 33 files changed, 116 insertions(+), 93 deletions(-) delete mode 100644 src/ImageProcessor.UnitTests/Images/format-animated.gif create mode 100644 src/ImageProcessor.UnitTests/Images/format-animated.gif.REMOVED.git-id create mode 100644 src/ImageProcessor.UnitTests/Images/udendørs.jpg delete mode 100644 src/ImageProcessor.UnitTests/Images/udendørs.jpg.REMOVED.git-id create mode 100644 src/ImageProcessorConsole/images/output/circle.png diff --git a/src/ImageProcessor.UnitTests/Extensions/DoubleExtensionsUnitTests.cs b/src/ImageProcessor.UnitTests/Extensions/DoubleExtensionsUnitTests.cs index 108a9a246..cba1c07bc 100644 --- a/src/ImageProcessor.UnitTests/Extensions/DoubleExtensionsUnitTests.cs +++ b/src/ImageProcessor.UnitTests/Extensions/DoubleExtensionsUnitTests.cs @@ -8,9 +8,8 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace ImageProcessor.UnitTests +namespace ImageProcessor.UnitTests.Extensions { - using System; using System.Collections.Generic; using Common.Extensions; using NUnit.Framework; @@ -32,11 +31,13 @@ namespace ImageProcessor.UnitTests [TestFixtureSetUp] public void Init() { - this.doubleToByteTests = new Dictionary(); - this.doubleToByteTests.Add(-10, 0x0); - this.doubleToByteTests.Add(1.5, 0x1); - this.doubleToByteTests.Add(25.7, 0x19); - this.doubleToByteTests.Add(1289047, 0xFF); + this.doubleToByteTests = new Dictionary + { + { -10, 0x0 }, + { 1.5, 0x1 }, + { 25.7, 0x19 }, + { 1289047, 0xFF } + }; } /// diff --git a/src/ImageProcessor.UnitTests/Extensions/IntegerExtensionsUnitTests.cs b/src/ImageProcessor.UnitTests/Extensions/IntegerExtensionsUnitTests.cs index 1e85e633b..2adbe3b17 100644 --- a/src/ImageProcessor.UnitTests/Extensions/IntegerExtensionsUnitTests.cs +++ b/src/ImageProcessor.UnitTests/Extensions/IntegerExtensionsUnitTests.cs @@ -8,9 +8,8 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace ImageProcessor.UnitTests +namespace ImageProcessor.UnitTests.Extensions { - using System; using Common.Extensions; using NUnit.Framework; @@ -31,7 +30,7 @@ namespace ImageProcessor.UnitTests [TestCase(3156, 0xFF)] public void ToByteTest(int input, byte expected) { - var result = input.ToByte(); + byte result = input.ToByte(); Assert.AreEqual(expected, result); } } diff --git a/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs b/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs index 70f3e83db..c89c09dcd 100644 --- a/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs +++ b/src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs @@ -8,11 +8,11 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace ImageProcessor.UnitTests +namespace ImageProcessor.UnitTests.Extensions { using System; using System.Collections.Generic; - using Common.Extensions; + using ImageProcessor.Common.Extensions; using NUnit.Framework; /// @@ -25,7 +25,7 @@ namespace ImageProcessor.UnitTests /// Tests the MD5 fingerprint /// /// The input value - /// The expexted output of the hash + /// The expected output of the hash [Test] [TestCase("test input", "2e7f7a62eabf0993239ca17c78c464d9")] [TestCase("lorem ipsum dolor", "96ee002fee25e8b675a477c9750fa360")] @@ -33,8 +33,8 @@ namespace ImageProcessor.UnitTests [TestCase("1234567890", "e15e31c3d8898c92ab172a4311be9e84")] public void TestToMd5Fingerprint(string input, string expected) { - var result = input.ToMD5Fingerprint(); - var comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); + string result = input.ToMD5Fingerprint(); + bool comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); Assert.True(comparison); } @@ -42,7 +42,7 @@ namespace ImageProcessor.UnitTests /// Tests the SHA-1 fingerprint /// /// The input value - /// The expexted output of the hash + /// The expected output of the hash [Test] [TestCase("test input", "49883b34e5a0f48224dd6230f471e9dc1bdbeaf5")] [TestCase("lorem ipsum dolor", "75899ad8827a32493928903aecd6e931bf36f967")] @@ -50,8 +50,8 @@ namespace ImageProcessor.UnitTests [TestCase("1234567890", "01b307acba4f54f55aafc33bb06bbbf6ca803e9a")] public void TestToSHA1Fingerprint(string input, string expected) { - var result = input.ToSHA1Fingerprint(); - var comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); + string result = input.ToSHA1Fingerprint(); + bool comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); Assert.True(comparison); } @@ -59,7 +59,7 @@ namespace ImageProcessor.UnitTests /// Tests the SHA-256 fingerprint /// /// The input value - /// The expexted output of the hash + /// The expected output of the hash [Test] [TestCase("test input", "9dfe6f15d1ab73af898739394fd22fd72a03db01834582f24bb2e1c66c7aaeae")] [TestCase("lorem ipsum dolor", "ed03353266c993ea9afb9900a3ca688ddec1656941b1ca15ee1650a022616dfa")] @@ -67,8 +67,8 @@ namespace ImageProcessor.UnitTests [TestCase("1234567890", "c775e7b757ede630cd0aa1113bd102661ab38829ca52a6422ab782862f268646")] public void TestToSHA256Fingerprint(string input, string expected) { - var result = input.ToSHA256Fingerprint(); - var comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); + string result = input.ToSHA256Fingerprint(); + bool comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); Assert.True(comparison); } @@ -76,7 +76,7 @@ namespace ImageProcessor.UnitTests /// Tests the SHA-512 fingerprint /// /// The input value - /// The expexted output of the hash + /// The expected output of the hash [Test] [TestCase("test input", "40aa1b203c9d8ee150b21c3c7cda8261492e5420c5f2b9f7380700e094c303b48e62f319c1da0e32eb40d113c5f1749cc61aeb499167890ab82f2cc9bb706971")] [TestCase("lorem ipsum dolor", "cd813e13d1d3919cdccc31c19d8f8b70bd25e9819f8770a011c8c7a6228536e6c9427b338cd732f2da3c0444dfebef838b745cdaf3fd5dcba8db24fc83a3f6ef")] @@ -84,49 +84,73 @@ namespace ImageProcessor.UnitTests [TestCase("1234567890", "12b03226a6d8be9c6e8cd5e55dc6c7920caaa39df14aab92d5e3ea9340d1c8a4d3d0b8e4314f1f6ef131ba4bf1ceb9186ab87c801af0d5c95b1befb8cedae2b9")] public void TestToSHA512Fingerprint(string input, string expected) { - var result = input.ToSHA512Fingerprint(); - var comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); + string result = input.ToSHA512Fingerprint(); + bool comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); Assert.True(comparison); } /// - /// Tests the pasing to an integer array + /// Tests the passing to an integer array /// [Test] public void TestToIntegerArray() { - Dictionary data = new Dictionary(); - data.Add("123-456,78-90", new int[] { 123, 456, 78, 90 }); - data.Add("87390174,741897498,74816,748297,57355", new int[] { 87390174, 741897498, 74816, 748297, 57355 }); - data.Add("1-2-3", new int[] { 1, 2, 3 }); + Dictionary data = new Dictionary + { + { + "123-456,78-90", + new[] { 123, 456, 78, 90 } + }, + { + "87390174,741897498,74816,748297,57355", + new[] + { + 87390174, 741897498, 74816, + 748297, 57355 + } + }, + { "1-2-3", new[] { 1, 2, 3 } } + }; - foreach (var item in data) + foreach (KeyValuePair item in data) { - var result = item.Key.ToPositiveIntegerArray(); + int[] result = item.Key.ToPositiveIntegerArray(); Assert.AreEqual(item.Value, result); } } /// - /// Tests the pasing to an float array + /// Tests the passing to an float array /// [Test] public void TestToFloatArray() { - Dictionary data = new Dictionary(); - data.Add("12.3-4.56,78-9.0", new float[] { 12.3F, 4.56F, 78, 9 }); - data.Add("87390.174,7.41897498,748.16,748297,5.7355", new float[] { 87390.174F, 7.41897498F, 748.16F, 748297, 5.7355F }); - data.Add("1-2-3", new float[] { 1, 2, 3 }); + Dictionary data = new Dictionary + { + { + "12.3-4.56,78-9.0", + new[] { 12.3F, 4.56F, 78, 9 } + }, + { + "87390.174,7.41897498,748.16,748297,5.7355", + new[] + { + 87390.174F, 7.41897498F, + 748.16F, 748297, 5.7355F + } + }, + { "1-2-3", new float[] { 1, 2, 3 } } + }; - foreach (var item in data) + foreach (KeyValuePair item in data) { - var result = item.Key.ToPositiveFloatArray(); + float[] result = item.Key.ToPositiveFloatArray(); Assert.AreEqual(item.Value, result); } } /// - /// Tests if the value is a valid URI + /// Tests if the value is a valid URI path name. I.E the path part of a uri. /// /// The value to test /// Whether the value is correct @@ -139,10 +163,10 @@ namespace ImageProcessor.UnitTests [TestCase(".", true)] [TestCase("_", true)] [TestCase("~", true)] - [TestCase(":", true)] + [TestCase(":", false)] [TestCase("/", true)] [TestCase("?", true)] - [TestCase("#", true)] + [TestCase("#", false)] [TestCase("[", false)] [TestCase("]", false)] [TestCase("@", true)] @@ -159,9 +183,9 @@ namespace ImageProcessor.UnitTests [TestCase("=", true)] [TestCase("lorem ipsum", false)] [TestCase("é", false)] - public void TestIsValidUri(string input, bool expected) + public void TestIsValidUriPathName(string input, bool expected) { - var result = input.IsValidVirtualPathName(); + bool result = input.IsValidVirtualPathName(); Assert.AreEqual(expected, result); } } diff --git a/src/ImageProcessor.UnitTests/Images/autorotate.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/autorotate.jpg.REMOVED.git-id index 19785c8e5..1b5e335ff 100644 --- a/src/ImageProcessor.UnitTests/Images/autorotate.jpg.REMOVED.git-id +++ b/src/ImageProcessor.UnitTests/Images/autorotate.jpg.REMOVED.git-id @@ -1 +1 @@ -85a8ae18f9955def2b42ba9240bce4de1bfe5781 \ No newline at end of file +75b37593bb2e505bf4fbe874eaf30debd6161c2e \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/cmyk-profile-euroscale.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/cmyk-profile-euroscale.jpg.REMOVED.git-id index 7747bdaae..11eb19931 100644 --- a/src/ImageProcessor.UnitTests/Images/cmyk-profile-euroscale.jpg.REMOVED.git-id +++ b/src/ImageProcessor.UnitTests/Images/cmyk-profile-euroscale.jpg.REMOVED.git-id @@ -1 +1 @@ -13492524f9d984c12adfe6183a4c1d92fb11ec4e \ No newline at end of file +d0a1a39a6729e826098ae5e987c22c34c989b7e3 \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/cmyk.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/cmyk.jpg.REMOVED.git-id index 30b05146b..9ba0b9f39 100644 --- a/src/ImageProcessor.UnitTests/Images/cmyk.jpg.REMOVED.git-id +++ b/src/ImageProcessor.UnitTests/Images/cmyk.jpg.REMOVED.git-id @@ -1 +1 @@ -ed725726e4ac1ffeac821664af14865a66fa933f \ No newline at end of file +9160894da31fedebb1fcd64eb57ca173187c63a6 \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/color-vision-test.gif.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/color-vision-test.gif.REMOVED.git-id index 5c4f4195d..ed1d0b80b 100644 --- a/src/ImageProcessor.UnitTests/Images/color-vision-test.gif.REMOVED.git-id +++ b/src/ImageProcessor.UnitTests/Images/color-vision-test.gif.REMOVED.git-id @@ -1 +1 @@ -35a926115b13b61dc37308f8d903b42d14f92924 \ No newline at end of file +b169fac4f1591e81e91c0bb6fed6dcf62a34c80e \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/exif-Tulips.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/exif-Tulips.jpg.REMOVED.git-id index 84b9aff85..20704f4a9 100644 --- a/src/ImageProcessor.UnitTests/Images/exif-Tulips.jpg.REMOVED.git-id +++ b/src/ImageProcessor.UnitTests/Images/exif-Tulips.jpg.REMOVED.git-id @@ -1 +1 @@ -54c51eb6a86f31a42433b8167470fb18dad32c7d \ No newline at end of file +9d7e7964a2285363171929315b15ec69f14831ef \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/exif-rocks.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/exif-rocks.jpg.REMOVED.git-id index 41c6c25df..2e03e238f 100644 --- a/src/ImageProcessor.UnitTests/Images/exif-rocks.jpg.REMOVED.git-id +++ b/src/ImageProcessor.UnitTests/Images/exif-rocks.jpg.REMOVED.git-id @@ -1 +1 @@ -33b6912af301bf216ee81d82b2c3ce6c49e03021 \ No newline at end of file +be31c9c0dea90586e2965208611fad024f6a5b08 \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/format-Penguins-8bit.png.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/format-Penguins-8bit.png.REMOVED.git-id index aa9a70e0f..c48cdc177 100644 --- a/src/ImageProcessor.UnitTests/Images/format-Penguins-8bit.png.REMOVED.git-id +++ b/src/ImageProcessor.UnitTests/Images/format-Penguins-8bit.png.REMOVED.git-id @@ -1 +1 @@ -c3d556d9d486b8b8b49cdbcc9c12a9d3a2db4c1f \ No newline at end of file +51ccec74a0351599de104f166b32d2860acaf089 \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/format-Penguins.bmp.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/format-Penguins.bmp.REMOVED.git-id index 74f69293c..9ba53bc67 100644 --- a/src/ImageProcessor.UnitTests/Images/format-Penguins.bmp.REMOVED.git-id +++ b/src/ImageProcessor.UnitTests/Images/format-Penguins.bmp.REMOVED.git-id @@ -1 +1 @@ -8150b46ab27c62ba51aaba551eef3f1a30f08de9 \ No newline at end of file +d7adbea2db4e3388541e31a229e5741677aaa7fd \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/format-Penguins.gif.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/format-Penguins.gif.REMOVED.git-id index ce873d473..225d59af3 100644 --- a/src/ImageProcessor.UnitTests/Images/format-Penguins.gif.REMOVED.git-id +++ b/src/ImageProcessor.UnitTests/Images/format-Penguins.gif.REMOVED.git-id @@ -1 +1 @@ -6ad3b846d4697584ff601ac481b14a4d3bbb5736 \ No newline at end of file +b301e58d431a78d3f17be53be1cdc94c86286389 \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/format-Penguins.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/format-Penguins.jpg.REMOVED.git-id index ad4371113..06482dbd9 100644 --- a/src/ImageProcessor.UnitTests/Images/format-Penguins.jpg.REMOVED.git-id +++ b/src/ImageProcessor.UnitTests/Images/format-Penguins.jpg.REMOVED.git-id @@ -1 +1 @@ -030ab8a685bebb796c24cc710edd9e69859164f6 \ No newline at end of file +ee5a15e7f8fc2655d5c1fc736a05857ab3d885bd \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/format-Penguins.png.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/format-Penguins.png.REMOVED.git-id index 78062a0e7..4ab6b372b 100644 --- a/src/ImageProcessor.UnitTests/Images/format-Penguins.png.REMOVED.git-id +++ b/src/ImageProcessor.UnitTests/Images/format-Penguins.png.REMOVED.git-id @@ -1 +1 @@ -a2c796fbb7de948230a22982ab74892891dd5198 \ No newline at end of file +b6434b5a35e989d4fa71ede1a8316fedeee7ae5f \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/format-animated.gif b/src/ImageProcessor.UnitTests/Images/format-animated.gif deleted file mode 100644 index ac36f6f25..000000000 --- a/src/ImageProcessor.UnitTests/Images/format-animated.gif +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:6212724b3e94908939823d0753b4307923b65d7a27f51823dd3ba7656543349c -size 22525 diff --git a/src/ImageProcessor.UnitTests/Images/format-animated.gif.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/format-animated.gif.REMOVED.git-id new file mode 100644 index 000000000..ac3664d5f --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/format-animated.gif.REMOVED.git-id @@ -0,0 +1 @@ +a41fb1117e1d730a4a488dcb67e0b867aa3c614e \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/hi-color.png b/src/ImageProcessor.UnitTests/Images/hi-color.png index a9de4cc09..cc8677aa8 100644 --- a/src/ImageProcessor.UnitTests/Images/hi-color.png +++ b/src/ImageProcessor.UnitTests/Images/hi-color.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:977cc9071257655c9923d267ea5bd417b69754367c2f1aa8765247b68e2bb878 -size 1539 +oid sha256:2f1263641d5e6ed29e96f211f4d78870496c29912245ac7d3c48716ee0ede313 +size 23922 diff --git a/src/ImageProcessor.UnitTests/Images/hi-contrast.jpg b/src/ImageProcessor.UnitTests/Images/hi-contrast.jpg index 98ac863a2..94581b505 100644 --- a/src/ImageProcessor.UnitTests/Images/hi-contrast.jpg +++ b/src/ImageProcessor.UnitTests/Images/hi-contrast.jpg @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c0ce9e02f2a4663a0a0ed433d5594be87b3fa0387bc8335e80f84d59c34aa424 -size 51058 +oid sha256:1d6fb72b9710edcfba0f75dcd349712d5e940ec87650a08380f8180e6c9a62b2 +size 34996 diff --git a/src/ImageProcessor.UnitTests/Images/hi-saturation.jpg b/src/ImageProcessor.UnitTests/Images/hi-saturation.jpg index b56f9a83c..3405e88a5 100644 --- a/src/ImageProcessor.UnitTests/Images/hi-saturation.jpg +++ b/src/ImageProcessor.UnitTests/Images/hi-saturation.jpg @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6b2012b2eda13a531645c287c254ae5de0e9070368cb4bc806f48314e0464ccd -size 33850 +oid sha256:fa947c3b5904e0138c359d7ccd81ad3209330880d412f1b09dfe32a355ee6d3b +size 51300 diff --git a/src/ImageProcessor.UnitTests/Images/profile-adobe-rgb.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/profile-adobe-rgb.jpg.REMOVED.git-id index 4ffbf7a8a..8064ffb21 100644 --- a/src/ImageProcessor.UnitTests/Images/profile-adobe-rgb.jpg.REMOVED.git-id +++ b/src/ImageProcessor.UnitTests/Images/profile-adobe-rgb.jpg.REMOVED.git-id @@ -1 +1 @@ -e29f32091aa13a5b047ccd960f3dc6da9656c84b \ No newline at end of file +189f79f9b9604c5413aba928662d84edd426142d \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/profile-srgb.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/profile-srgb.jpg.REMOVED.git-id index f409bc82b..101151778 100644 --- a/src/ImageProcessor.UnitTests/Images/profile-srgb.jpg.REMOVED.git-id +++ b/src/ImageProcessor.UnitTests/Images/profile-srgb.jpg.REMOVED.git-id @@ -1 +1 @@ -ab9deaa737f9db9bf0f563e7843ba9b7981cec86 \ No newline at end of file +f731bdf700d2718f528317263264e5466374c5e5 \ No newline at end of file diff --git a/src/ImageProcessor.UnitTests/Images/size-Penguins-200.jpg b/src/ImageProcessor.UnitTests/Images/size-Penguins-200.jpg index 07605996f..4520c9c95 100644 --- a/src/ImageProcessor.UnitTests/Images/size-Penguins-200.jpg +++ b/src/ImageProcessor.UnitTests/Images/size-Penguins-200.jpg @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:672de68017f17260126901065f1c6ade2b2981d33dea0dea1606bf7cfb6fdcf3 -size 10119 +oid sha256:f0b24fb4937a0416bf62f7a743d2679c7eb2014bceb1a898826fb08e6231bad7 +size 37476 diff --git a/src/ImageProcessor.UnitTests/Images/text-over-transparent.png b/src/ImageProcessor.UnitTests/Images/text-over-transparent.png index 33d4962bc..1ae73c91f 100644 --- a/src/ImageProcessor.UnitTests/Images/text-over-transparent.png +++ b/src/ImageProcessor.UnitTests/Images/text-over-transparent.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2322d8dd81df86b8135d399743ea758ad26d6b2ccdcc704e2687ae72d0c187e7 -size 7317 +oid sha256:ba300af935752628b37a7f892369e7229f4f6ae701522cdedeefcf5c2b251afa +size 7680 diff --git a/src/ImageProcessor.UnitTests/Images/udendørs.jpg b/src/ImageProcessor.UnitTests/Images/udendørs.jpg new file mode 100644 index 000000000..84fb0cc3a --- /dev/null +++ b/src/ImageProcessor.UnitTests/Images/udendørs.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:65434ff6c6d5f502308e627fcfbe1d26402b83fb5efba15749ffbb5e8795995e +size 55987 diff --git a/src/ImageProcessor.UnitTests/Images/udendørs.jpg.REMOVED.git-id b/src/ImageProcessor.UnitTests/Images/udendørs.jpg.REMOVED.git-id deleted file mode 100644 index 0db1445a2..000000000 --- a/src/ImageProcessor.UnitTests/Images/udendørs.jpg.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -4d040d9aa3519b3d2303419d1f03eebebf88e956 \ No newline at end of file diff --git a/src/ImageProcessor/ImageFactory.cs b/src/ImageProcessor/ImageFactory.cs index f2f573268..7e37983c3 100644 --- a/src/ImageProcessor/ImageFactory.cs +++ b/src/ImageProcessor/ImageFactory.cs @@ -158,9 +158,10 @@ namespace ImageProcessor this.CurrentImageFormat = format; // Always load the data. - foreach (PropertyItem propertyItem in this.Image.PropertyItems) + // TODO. Some custom data doesn't seem to get copied by default methods. + foreach (int id in this.Image.PropertyIdList) { - this.ExifPropertyItems[propertyItem.Id] = propertyItem; + this.ExifPropertyItems[id] = this.Image.GetPropertyItem(id); } this.ShouldProcess = true; diff --git a/src/ImageProcessor/Imaging/Formats/GifEncoder.cs b/src/ImageProcessor/Imaging/Formats/GifEncoder.cs index 662ad314c..b7650d099 100644 --- a/src/ImageProcessor/Imaging/Formats/GifEncoder.cs +++ b/src/ImageProcessor/Imaging/Formats/GifEncoder.cs @@ -282,17 +282,17 @@ namespace ImageProcessor.Imaging.Formats { int count = this.repeatCount.GetValueOrDefault(0); - // File Header sinature and version. + // File Header signature and version. this.WriteString(FileType); this.WriteString(FileVersion); // Write the logical screen descriptor. this.WriteShort(this.width.GetValueOrDefault(w)); // Initial Logical Width this.WriteShort(this.height.GetValueOrDefault(h)); // Initial Logical Height - + // Read the global color table info. sourceGif.Position = SourceGlobalColorInfoPosition; - this.WriteByte(sourceGif.ReadByte()); + this.WriteByte(sourceGif.ReadByte()); this.WriteByte(0); // Background Color Index this.WriteByte(0); // Pixel aspect ratio @@ -301,7 +301,7 @@ namespace ImageProcessor.Imaging.Formats // The different browsers interpret the spec differently when adding a loop. // If the loop count is one IE and FF < 3 (incorrectly) loop an extra number of times. // Removing the Netscape header should fix this. - if (count != 1) + if (count > -1 && count != 1) { // Application Extension Header this.WriteShort(ApplicationExtensionBlockIdentifier); @@ -357,7 +357,7 @@ namespace ImageProcessor.Imaging.Formats this.WriteShort(GraphicControlExtensionBlockIdentifier); // Identifier this.WriteByte(GraphicControlExtensionBlockSize); // Block Size this.WriteByte(blockhead[3] & 0xf7 | 0x08); // Setting disposal flag - this.WriteShort(Convert.ToInt32(frameDelay / 10)); // Setting frame delay + this.WriteShort(Convert.ToInt32(frameDelay / 10.0f)); // Setting frame delay this.WriteByte(blockhead[6]); // Transparent color index this.WriteByte(0); // Terminator } diff --git a/src/ImageProcessor/Imaging/Formats/JpegFormat.cs b/src/ImageProcessor/Imaging/Formats/JpegFormat.cs index ae5fd05c3..f7ff73c66 100644 --- a/src/ImageProcessor/Imaging/Formats/JpegFormat.cs +++ b/src/ImageProcessor/Imaging/Formats/JpegFormat.cs @@ -75,7 +75,7 @@ namespace ImageProcessor.Imaging.Formats { base.ApplyProcessor(processor, factory); - // Set the property item information from any Exif metadata. + // Set the property item information from any Exif metadata. // We do this here so that they can be changed between processor methods. if (factory.PreserveExifData) { diff --git a/src/ImageProcessorConsole/Program.cs b/src/ImageProcessorConsole/Program.cs index 248fe1d7f..5bacb50dd 100644 --- a/src/ImageProcessorConsole/Program.cs +++ b/src/ImageProcessorConsole/Program.cs @@ -15,9 +15,7 @@ namespace ImageProcessorConsole using System.Drawing; using System.IO; using System.Linq; - using ImageProcessor; - using ImageProcessor.Imaging.Formats; /// /// The program. @@ -33,6 +31,7 @@ namespace ImageProcessorConsole public static void Main(string[] args) { string path = new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath; + // ReSharper disable once AssignNullToNotNullAttribute string resolvedPath = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(path), @"..\..\images\input")); DirectoryInfo di = new DirectoryInfo(resolvedPath); @@ -41,10 +40,8 @@ namespace ImageProcessorConsole di.Create(); } - //FileInfo[] files = di.GetFiles("*.jpg"); - //FileInfo[] files = di.GetFiles(); - IEnumerable files = GetFilesByExtensions(di, ".gif", ".webp"); - + IEnumerable files = GetFilesByExtensions(di, ".gif"); + //IEnumerable files = GetFilesByExtensions(di, ".gif", ".webp", ".bmp", ".jpg", ".png"); foreach (FileInfo fileInfo in files) { @@ -53,18 +50,13 @@ namespace ImageProcessorConsole // ImageProcessor using (MemoryStream inStream = new MemoryStream(photoBytes)) { - using (ImageFactory imageFactory = new ImageFactory()) + using (ImageFactory imageFactory = new ImageFactory(true)) { Size size = new Size(200, 200); // Load, resize, set the format and quality and save an image. imageFactory.Load(inStream) - //.AutoRotate() .Constrain(size) - //.Format(new WebPFormat()) - //.Quality(5) - // ReSharper disable once AssignNullToNotNullAttribute - // .Save(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(path), @"..\..\images\output", Path.GetFileNameWithoutExtension(fileInfo.Name) + ".webp"))); .Save(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(path), @"..\..\images\output", fileInfo.Name))); } } @@ -74,7 +66,10 @@ namespace ImageProcessorConsole public static IEnumerable GetFilesByExtensions(DirectoryInfo dir, params string[] extensions) { if (extensions == null) + { throw new ArgumentNullException("extensions"); + } + IEnumerable files = dir.EnumerateFiles(); return files.Where(f => extensions.Contains(f.Extension, StringComparer.OrdinalIgnoreCase)); } diff --git a/src/ImageProcessorConsole/images/output/120430.gif.REMOVED.git-id b/src/ImageProcessorConsole/images/output/120430.gif.REMOVED.git-id index 71ce555c1..4767fd13d 100644 --- a/src/ImageProcessorConsole/images/output/120430.gif.REMOVED.git-id +++ b/src/ImageProcessorConsole/images/output/120430.gif.REMOVED.git-id @@ -1 +1 @@ -30ec5c05548fd350f9b7c699715848b9fbfb8ca9 \ No newline at end of file +6f3f997e323adb1fce142930d86338efacffc3fd \ No newline at end of file diff --git a/src/ImageProcessorConsole/images/output/Tl4Yb.gif.REMOVED.git-id b/src/ImageProcessorConsole/images/output/Tl4Yb.gif.REMOVED.git-id index 6515d65a0..f0f194a2b 100644 --- a/src/ImageProcessorConsole/images/output/Tl4Yb.gif.REMOVED.git-id +++ b/src/ImageProcessorConsole/images/output/Tl4Yb.gif.REMOVED.git-id @@ -1 +1 @@ -fdc62fc2d056ab885eb9e8fd12b9155ee86d7c43 \ No newline at end of file +3ab082661fc5d88f88643c47409e196d66e26d4b \ No newline at end of file diff --git a/src/ImageProcessorConsole/images/output/circle.png b/src/ImageProcessorConsole/images/output/circle.png new file mode 100644 index 000000000..a96f1ecf3 --- /dev/null +++ b/src/ImageProcessorConsole/images/output/circle.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f31110b7933864eff3b149371c962174a8855a1c65f4fee7cb3bc63a79b71467 +size 2905 diff --git a/src/ImageProcessorConsole/images/output/nLpfllv.gif.REMOVED.git-id b/src/ImageProcessorConsole/images/output/nLpfllv.gif.REMOVED.git-id index c07be0b0f..b8684cd60 100644 --- a/src/ImageProcessorConsole/images/output/nLpfllv.gif.REMOVED.git-id +++ b/src/ImageProcessorConsole/images/output/nLpfllv.gif.REMOVED.git-id @@ -1 +1 @@ -77cce70db3722920d60f4b17a45a5e390a09838a \ No newline at end of file +e2c2fbac64987ad26e19f5d2721fcaa60fee843d \ No newline at end of file