Browse Source

Adding updated tests and reducing image sizes.

Former-commit-id: 054373e5c704ca0ca2a26770863549b2eeca7165
af/merge-core
James South 12 years ago
parent
commit
dc613fb549
  1. 15
      src/ImageProcessor.UnitTests/Extensions/DoubleExtensionsUnitTests.cs
  2. 5
      src/ImageProcessor.UnitTests/Extensions/IntegerExtensionsUnitTests.cs
  3. 90
      src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs
  4. 2
      src/ImageProcessor.UnitTests/Images/autorotate.jpg.REMOVED.git-id
  5. 2
      src/ImageProcessor.UnitTests/Images/cmyk-profile-euroscale.jpg.REMOVED.git-id
  6. 2
      src/ImageProcessor.UnitTests/Images/cmyk.jpg.REMOVED.git-id
  7. 2
      src/ImageProcessor.UnitTests/Images/color-vision-test.gif.REMOVED.git-id
  8. 2
      src/ImageProcessor.UnitTests/Images/exif-Tulips.jpg.REMOVED.git-id
  9. 2
      src/ImageProcessor.UnitTests/Images/exif-rocks.jpg.REMOVED.git-id
  10. 2
      src/ImageProcessor.UnitTests/Images/format-Penguins-8bit.png.REMOVED.git-id
  11. 2
      src/ImageProcessor.UnitTests/Images/format-Penguins.bmp.REMOVED.git-id
  12. 2
      src/ImageProcessor.UnitTests/Images/format-Penguins.gif.REMOVED.git-id
  13. 2
      src/ImageProcessor.UnitTests/Images/format-Penguins.jpg.REMOVED.git-id
  14. 2
      src/ImageProcessor.UnitTests/Images/format-Penguins.png.REMOVED.git-id
  15. 3
      src/ImageProcessor.UnitTests/Images/format-animated.gif
  16. 1
      src/ImageProcessor.UnitTests/Images/format-animated.gif.REMOVED.git-id
  17. 4
      src/ImageProcessor.UnitTests/Images/hi-color.png
  18. 4
      src/ImageProcessor.UnitTests/Images/hi-contrast.jpg
  19. 4
      src/ImageProcessor.UnitTests/Images/hi-saturation.jpg
  20. 2
      src/ImageProcessor.UnitTests/Images/profile-adobe-rgb.jpg.REMOVED.git-id
  21. 2
      src/ImageProcessor.UnitTests/Images/profile-srgb.jpg.REMOVED.git-id
  22. 4
      src/ImageProcessor.UnitTests/Images/size-Penguins-200.jpg
  23. 4
      src/ImageProcessor.UnitTests/Images/text-over-transparent.png
  24. 3
      src/ImageProcessor.UnitTests/Images/udendørs.jpg
  25. 1
      src/ImageProcessor.UnitTests/Images/udendørs.jpg.REMOVED.git-id
  26. 5
      src/ImageProcessor/ImageFactory.cs
  27. 10
      src/ImageProcessor/Imaging/Formats/GifEncoder.cs
  28. 2
      src/ImageProcessor/Imaging/Formats/JpegFormat.cs
  29. 19
      src/ImageProcessorConsole/Program.cs
  30. 2
      src/ImageProcessorConsole/images/output/120430.gif.REMOVED.git-id
  31. 2
      src/ImageProcessorConsole/images/output/Tl4Yb.gif.REMOVED.git-id
  32. 3
      src/ImageProcessorConsole/images/output/circle.png
  33. 2
      src/ImageProcessorConsole/images/output/nLpfllv.gif.REMOVED.git-id

15
src/ImageProcessor.UnitTests/Extensions/DoubleExtensionsUnitTests.cs

@ -8,9 +8,8 @@
// </summary> // </summary>
// -------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------
namespace ImageProcessor.UnitTests namespace ImageProcessor.UnitTests.Extensions
{ {
using System;
using System.Collections.Generic; using System.Collections.Generic;
using Common.Extensions; using Common.Extensions;
using NUnit.Framework; using NUnit.Framework;
@ -32,11 +31,13 @@ namespace ImageProcessor.UnitTests
[TestFixtureSetUp] [TestFixtureSetUp]
public void Init() public void Init()
{ {
this.doubleToByteTests = new Dictionary<double, byte>(); this.doubleToByteTests = new Dictionary<double, byte>
this.doubleToByteTests.Add(-10, 0x0); {
this.doubleToByteTests.Add(1.5, 0x1); { -10, 0x0 },
this.doubleToByteTests.Add(25.7, 0x19); { 1.5, 0x1 },
this.doubleToByteTests.Add(1289047, 0xFF); { 25.7, 0x19 },
{ 1289047, 0xFF }
};
} }
/// <summary> /// <summary>

5
src/ImageProcessor.UnitTests/Extensions/IntegerExtensionsUnitTests.cs

@ -8,9 +8,8 @@
// </summary> // </summary>
// -------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------
namespace ImageProcessor.UnitTests namespace ImageProcessor.UnitTests.Extensions
{ {
using System;
using Common.Extensions; using Common.Extensions;
using NUnit.Framework; using NUnit.Framework;
@ -31,7 +30,7 @@ namespace ImageProcessor.UnitTests
[TestCase(3156, 0xFF)] [TestCase(3156, 0xFF)]
public void ToByteTest(int input, byte expected) public void ToByteTest(int input, byte expected)
{ {
var result = input.ToByte(); byte result = input.ToByte();
Assert.AreEqual(expected, result); Assert.AreEqual(expected, result);
} }
} }

90
src/ImageProcessor.UnitTests/Extensions/StringExtensionsUnitTests.cs

@ -8,11 +8,11 @@
// </summary> // </summary>
// -------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------
namespace ImageProcessor.UnitTests namespace ImageProcessor.UnitTests.Extensions
{ {
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Common.Extensions; using ImageProcessor.Common.Extensions;
using NUnit.Framework; using NUnit.Framework;
/// <summary> /// <summary>
@ -25,7 +25,7 @@ namespace ImageProcessor.UnitTests
/// Tests the MD5 fingerprint /// Tests the MD5 fingerprint
/// </summary> /// </summary>
/// <param name="input">The input value</param> /// <param name="input">The input value</param>
/// <param name="expected">The expexted output of the hash</param> /// <param name="expected">The expected output of the hash</param>
[Test] [Test]
[TestCase("test input", "2e7f7a62eabf0993239ca17c78c464d9")] [TestCase("test input", "2e7f7a62eabf0993239ca17c78c464d9")]
[TestCase("lorem ipsum dolor", "96ee002fee25e8b675a477c9750fa360")] [TestCase("lorem ipsum dolor", "96ee002fee25e8b675a477c9750fa360")]
@ -33,8 +33,8 @@ namespace ImageProcessor.UnitTests
[TestCase("1234567890", "e15e31c3d8898c92ab172a4311be9e84")] [TestCase("1234567890", "e15e31c3d8898c92ab172a4311be9e84")]
public void TestToMd5Fingerprint(string input, string expected) public void TestToMd5Fingerprint(string input, string expected)
{ {
var result = input.ToMD5Fingerprint(); string result = input.ToMD5Fingerprint();
var comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); bool comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase);
Assert.True(comparison); Assert.True(comparison);
} }
@ -42,7 +42,7 @@ namespace ImageProcessor.UnitTests
/// Tests the SHA-1 fingerprint /// Tests the SHA-1 fingerprint
/// </summary> /// </summary>
/// <param name="input">The input value</param> /// <param name="input">The input value</param>
/// <param name="expected">The expexted output of the hash</param> /// <param name="expected">The expected output of the hash</param>
[Test] [Test]
[TestCase("test input", "49883b34e5a0f48224dd6230f471e9dc1bdbeaf5")] [TestCase("test input", "49883b34e5a0f48224dd6230f471e9dc1bdbeaf5")]
[TestCase("lorem ipsum dolor", "75899ad8827a32493928903aecd6e931bf36f967")] [TestCase("lorem ipsum dolor", "75899ad8827a32493928903aecd6e931bf36f967")]
@ -50,8 +50,8 @@ namespace ImageProcessor.UnitTests
[TestCase("1234567890", "01b307acba4f54f55aafc33bb06bbbf6ca803e9a")] [TestCase("1234567890", "01b307acba4f54f55aafc33bb06bbbf6ca803e9a")]
public void TestToSHA1Fingerprint(string input, string expected) public void TestToSHA1Fingerprint(string input, string expected)
{ {
var result = input.ToSHA1Fingerprint(); string result = input.ToSHA1Fingerprint();
var comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); bool comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase);
Assert.True(comparison); Assert.True(comparison);
} }
@ -59,7 +59,7 @@ namespace ImageProcessor.UnitTests
/// Tests the SHA-256 fingerprint /// Tests the SHA-256 fingerprint
/// </summary> /// </summary>
/// <param name="input">The input value</param> /// <param name="input">The input value</param>
/// <param name="expected">The expexted output of the hash</param> /// <param name="expected">The expected output of the hash</param>
[Test] [Test]
[TestCase("test input", "9dfe6f15d1ab73af898739394fd22fd72a03db01834582f24bb2e1c66c7aaeae")] [TestCase("test input", "9dfe6f15d1ab73af898739394fd22fd72a03db01834582f24bb2e1c66c7aaeae")]
[TestCase("lorem ipsum dolor", "ed03353266c993ea9afb9900a3ca688ddec1656941b1ca15ee1650a022616dfa")] [TestCase("lorem ipsum dolor", "ed03353266c993ea9afb9900a3ca688ddec1656941b1ca15ee1650a022616dfa")]
@ -67,8 +67,8 @@ namespace ImageProcessor.UnitTests
[TestCase("1234567890", "c775e7b757ede630cd0aa1113bd102661ab38829ca52a6422ab782862f268646")] [TestCase("1234567890", "c775e7b757ede630cd0aa1113bd102661ab38829ca52a6422ab782862f268646")]
public void TestToSHA256Fingerprint(string input, string expected) public void TestToSHA256Fingerprint(string input, string expected)
{ {
var result = input.ToSHA256Fingerprint(); string result = input.ToSHA256Fingerprint();
var comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); bool comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase);
Assert.True(comparison); Assert.True(comparison);
} }
@ -76,7 +76,7 @@ namespace ImageProcessor.UnitTests
/// Tests the SHA-512 fingerprint /// Tests the SHA-512 fingerprint
/// </summary> /// </summary>
/// <param name="input">The input value</param> /// <param name="input">The input value</param>
/// <param name="expected">The expexted output of the hash</param> /// <param name="expected">The expected output of the hash</param>
[Test] [Test]
[TestCase("test input", "40aa1b203c9d8ee150b21c3c7cda8261492e5420c5f2b9f7380700e094c303b48e62f319c1da0e32eb40d113c5f1749cc61aeb499167890ab82f2cc9bb706971")] [TestCase("test input", "40aa1b203c9d8ee150b21c3c7cda8261492e5420c5f2b9f7380700e094c303b48e62f319c1da0e32eb40d113c5f1749cc61aeb499167890ab82f2cc9bb706971")]
[TestCase("lorem ipsum dolor", "cd813e13d1d3919cdccc31c19d8f8b70bd25e9819f8770a011c8c7a6228536e6c9427b338cd732f2da3c0444dfebef838b745cdaf3fd5dcba8db24fc83a3f6ef")] [TestCase("lorem ipsum dolor", "cd813e13d1d3919cdccc31c19d8f8b70bd25e9819f8770a011c8c7a6228536e6c9427b338cd732f2da3c0444dfebef838b745cdaf3fd5dcba8db24fc83a3f6ef")]
@ -84,49 +84,73 @@ namespace ImageProcessor.UnitTests
[TestCase("1234567890", "12b03226a6d8be9c6e8cd5e55dc6c7920caaa39df14aab92d5e3ea9340d1c8a4d3d0b8e4314f1f6ef131ba4bf1ceb9186ab87c801af0d5c95b1befb8cedae2b9")] [TestCase("1234567890", "12b03226a6d8be9c6e8cd5e55dc6c7920caaa39df14aab92d5e3ea9340d1c8a4d3d0b8e4314f1f6ef131ba4bf1ceb9186ab87c801af0d5c95b1befb8cedae2b9")]
public void TestToSHA512Fingerprint(string input, string expected) public void TestToSHA512Fingerprint(string input, string expected)
{ {
var result = input.ToSHA512Fingerprint(); string result = input.ToSHA512Fingerprint();
var comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase); bool comparison = result.Equals(expected, StringComparison.InvariantCultureIgnoreCase);
Assert.True(comparison); Assert.True(comparison);
} }
/// <summary> /// <summary>
/// Tests the pasing to an integer array /// Tests the passing to an integer array
/// </summary> /// </summary>
[Test] [Test]
public void TestToIntegerArray() public void TestToIntegerArray()
{ {
Dictionary<string, int[]> data = new Dictionary<string, int[]>(); Dictionary<string, int[]> data = new Dictionary<string, int[]>
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 }); "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<string, int[]> item in data)
{ {
var result = item.Key.ToPositiveIntegerArray(); int[] result = item.Key.ToPositiveIntegerArray();
Assert.AreEqual(item.Value, result); Assert.AreEqual(item.Value, result);
} }
} }
/// <summary> /// <summary>
/// Tests the pasing to an float array /// Tests the passing to an float array
/// </summary> /// </summary>
[Test] [Test]
public void TestToFloatArray() public void TestToFloatArray()
{ {
Dictionary<string, float[]> data = new Dictionary<string, float[]>(); Dictionary<string, float[]> data = new Dictionary<string, float[]>
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 }); "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<string, float[]> item in data)
{ {
var result = item.Key.ToPositiveFloatArray(); float[] result = item.Key.ToPositiveFloatArray();
Assert.AreEqual(item.Value, result); Assert.AreEqual(item.Value, result);
} }
} }
/// <summary> /// <summary>
/// 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.
/// </summary> /// </summary>
/// <param name="input">The value to test</param> /// <param name="input">The value to test</param>
/// <param name="expected">Whether the value is correct</param> /// <param name="expected">Whether the value is correct</param>
@ -139,10 +163,10 @@ namespace ImageProcessor.UnitTests
[TestCase(".", true)] [TestCase(".", true)]
[TestCase("_", true)] [TestCase("_", true)]
[TestCase("~", true)] [TestCase("~", true)]
[TestCase(":", true)] [TestCase(":", false)]
[TestCase("/", true)] [TestCase("/", true)]
[TestCase("?", true)] [TestCase("?", true)]
[TestCase("#", true)] [TestCase("#", false)]
[TestCase("[", false)] [TestCase("[", false)]
[TestCase("]", false)] [TestCase("]", false)]
[TestCase("@", true)] [TestCase("@", true)]
@ -159,9 +183,9 @@ namespace ImageProcessor.UnitTests
[TestCase("=", true)] [TestCase("=", true)]
[TestCase("lorem ipsum", false)] [TestCase("lorem ipsum", false)]
[TestCase("é", 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); Assert.AreEqual(expected, result);
} }
} }

2
src/ImageProcessor.UnitTests/Images/autorotate.jpg.REMOVED.git-id

@ -1 +1 @@
85a8ae18f9955def2b42ba9240bce4de1bfe5781 75b37593bb2e505bf4fbe874eaf30debd6161c2e

2
src/ImageProcessor.UnitTests/Images/cmyk-profile-euroscale.jpg.REMOVED.git-id

@ -1 +1 @@
13492524f9d984c12adfe6183a4c1d92fb11ec4e d0a1a39a6729e826098ae5e987c22c34c989b7e3

2
src/ImageProcessor.UnitTests/Images/cmyk.jpg.REMOVED.git-id

@ -1 +1 @@
ed725726e4ac1ffeac821664af14865a66fa933f 9160894da31fedebb1fcd64eb57ca173187c63a6

2
src/ImageProcessor.UnitTests/Images/color-vision-test.gif.REMOVED.git-id

@ -1 +1 @@
35a926115b13b61dc37308f8d903b42d14f92924 b169fac4f1591e81e91c0bb6fed6dcf62a34c80e

2
src/ImageProcessor.UnitTests/Images/exif-Tulips.jpg.REMOVED.git-id

@ -1 +1 @@
54c51eb6a86f31a42433b8167470fb18dad32c7d 9d7e7964a2285363171929315b15ec69f14831ef

2
src/ImageProcessor.UnitTests/Images/exif-rocks.jpg.REMOVED.git-id

@ -1 +1 @@
33b6912af301bf216ee81d82b2c3ce6c49e03021 be31c9c0dea90586e2965208611fad024f6a5b08

2
src/ImageProcessor.UnitTests/Images/format-Penguins-8bit.png.REMOVED.git-id

@ -1 +1 @@
c3d556d9d486b8b8b49cdbcc9c12a9d3a2db4c1f 51ccec74a0351599de104f166b32d2860acaf089

2
src/ImageProcessor.UnitTests/Images/format-Penguins.bmp.REMOVED.git-id

@ -1 +1 @@
8150b46ab27c62ba51aaba551eef3f1a30f08de9 d7adbea2db4e3388541e31a229e5741677aaa7fd

2
src/ImageProcessor.UnitTests/Images/format-Penguins.gif.REMOVED.git-id

@ -1 +1 @@
6ad3b846d4697584ff601ac481b14a4d3bbb5736 b301e58d431a78d3f17be53be1cdc94c86286389

2
src/ImageProcessor.UnitTests/Images/format-Penguins.jpg.REMOVED.git-id

@ -1 +1 @@
030ab8a685bebb796c24cc710edd9e69859164f6 ee5a15e7f8fc2655d5c1fc736a05857ab3d885bd

2
src/ImageProcessor.UnitTests/Images/format-Penguins.png.REMOVED.git-id

@ -1 +1 @@
a2c796fbb7de948230a22982ab74892891dd5198 b6434b5a35e989d4fa71ede1a8316fedeee7ae5f

3
src/ImageProcessor.UnitTests/Images/format-animated.gif

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:6212724b3e94908939823d0753b4307923b65d7a27f51823dd3ba7656543349c
size 22525

1
src/ImageProcessor.UnitTests/Images/format-animated.gif.REMOVED.git-id

@ -0,0 +1 @@
a41fb1117e1d730a4a488dcb67e0b867aa3c614e

4
src/ImageProcessor.UnitTests/Images/hi-color.png

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:977cc9071257655c9923d267ea5bd417b69754367c2f1aa8765247b68e2bb878 oid sha256:2f1263641d5e6ed29e96f211f4d78870496c29912245ac7d3c48716ee0ede313
size 1539 size 23922

4
src/ImageProcessor.UnitTests/Images/hi-contrast.jpg

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:c0ce9e02f2a4663a0a0ed433d5594be87b3fa0387bc8335e80f84d59c34aa424 oid sha256:1d6fb72b9710edcfba0f75dcd349712d5e940ec87650a08380f8180e6c9a62b2
size 51058 size 34996

4
src/ImageProcessor.UnitTests/Images/hi-saturation.jpg

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:6b2012b2eda13a531645c287c254ae5de0e9070368cb4bc806f48314e0464ccd oid sha256:fa947c3b5904e0138c359d7ccd81ad3209330880d412f1b09dfe32a355ee6d3b
size 33850 size 51300

2
src/ImageProcessor.UnitTests/Images/profile-adobe-rgb.jpg.REMOVED.git-id

@ -1 +1 @@
e29f32091aa13a5b047ccd960f3dc6da9656c84b 189f79f9b9604c5413aba928662d84edd426142d

2
src/ImageProcessor.UnitTests/Images/profile-srgb.jpg.REMOVED.git-id

@ -1 +1 @@
ab9deaa737f9db9bf0f563e7843ba9b7981cec86 f731bdf700d2718f528317263264e5466374c5e5

4
src/ImageProcessor.UnitTests/Images/size-Penguins-200.jpg

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:672de68017f17260126901065f1c6ade2b2981d33dea0dea1606bf7cfb6fdcf3 oid sha256:f0b24fb4937a0416bf62f7a743d2679c7eb2014bceb1a898826fb08e6231bad7
size 10119 size 37476

4
src/ImageProcessor.UnitTests/Images/text-over-transparent.png

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:2322d8dd81df86b8135d399743ea758ad26d6b2ccdcc704e2687ae72d0c187e7 oid sha256:ba300af935752628b37a7f892369e7229f4f6ae701522cdedeefcf5c2b251afa
size 7317 size 7680

3
src/ImageProcessor.UnitTests/Images/udendørs.jpg

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:65434ff6c6d5f502308e627fcfbe1d26402b83fb5efba15749ffbb5e8795995e
size 55987

1
src/ImageProcessor.UnitTests/Images/udendørs.jpg.REMOVED.git-id

@ -1 +0,0 @@
4d040d9aa3519b3d2303419d1f03eebebf88e956

5
src/ImageProcessor/ImageFactory.cs

@ -158,9 +158,10 @@ namespace ImageProcessor
this.CurrentImageFormat = format; this.CurrentImageFormat = format;
// Always load the data. // 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; this.ShouldProcess = true;

10
src/ImageProcessor/Imaging/Formats/GifEncoder.cs

@ -282,17 +282,17 @@ namespace ImageProcessor.Imaging.Formats
{ {
int count = this.repeatCount.GetValueOrDefault(0); int count = this.repeatCount.GetValueOrDefault(0);
// File Header sinature and version. // File Header signature and version.
this.WriteString(FileType); this.WriteString(FileType);
this.WriteString(FileVersion); this.WriteString(FileVersion);
// Write the logical screen descriptor. // Write the logical screen descriptor.
this.WriteShort(this.width.GetValueOrDefault(w)); // Initial Logical Width this.WriteShort(this.width.GetValueOrDefault(w)); // Initial Logical Width
this.WriteShort(this.height.GetValueOrDefault(h)); // Initial Logical Height this.WriteShort(this.height.GetValueOrDefault(h)); // Initial Logical Height
// Read the global color table info. // Read the global color table info.
sourceGif.Position = SourceGlobalColorInfoPosition; sourceGif.Position = SourceGlobalColorInfoPosition;
this.WriteByte(sourceGif.ReadByte()); this.WriteByte(sourceGif.ReadByte());
this.WriteByte(0); // Background Color Index this.WriteByte(0); // Background Color Index
this.WriteByte(0); // Pixel aspect ratio 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. // The different browsers interpret the spec differently when adding a loop.
// If the loop count is one IE and FF &lt; 3 (incorrectly) loop an extra number of times. // If the loop count is one IE and FF &lt; 3 (incorrectly) loop an extra number of times.
// Removing the Netscape header should fix this. // Removing the Netscape header should fix this.
if (count != 1) if (count > -1 && count != 1)
{ {
// Application Extension Header // Application Extension Header
this.WriteShort(ApplicationExtensionBlockIdentifier); this.WriteShort(ApplicationExtensionBlockIdentifier);
@ -357,7 +357,7 @@ namespace ImageProcessor.Imaging.Formats
this.WriteShort(GraphicControlExtensionBlockIdentifier); // Identifier this.WriteShort(GraphicControlExtensionBlockIdentifier); // Identifier
this.WriteByte(GraphicControlExtensionBlockSize); // Block Size this.WriteByte(GraphicControlExtensionBlockSize); // Block Size
this.WriteByte(blockhead[3] & 0xf7 | 0x08); // Setting disposal flag 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(blockhead[6]); // Transparent color index
this.WriteByte(0); // Terminator this.WriteByte(0); // Terminator
} }

2
src/ImageProcessor/Imaging/Formats/JpegFormat.cs

@ -75,7 +75,7 @@ namespace ImageProcessor.Imaging.Formats
{ {
base.ApplyProcessor(processor, factory); 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. // We do this here so that they can be changed between processor methods.
if (factory.PreserveExifData) if (factory.PreserveExifData)
{ {

19
src/ImageProcessorConsole/Program.cs

@ -15,9 +15,7 @@ namespace ImageProcessorConsole
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using ImageProcessor; using ImageProcessor;
using ImageProcessor.Imaging.Formats;
/// <summary> /// <summary>
/// The program. /// The program.
@ -33,6 +31,7 @@ namespace ImageProcessorConsole
public static void Main(string[] args) public static void Main(string[] args)
{ {
string path = new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath; string path = new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath;
// ReSharper disable once AssignNullToNotNullAttribute // ReSharper disable once AssignNullToNotNullAttribute
string resolvedPath = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(path), @"..\..\images\input")); string resolvedPath = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(path), @"..\..\images\input"));
DirectoryInfo di = new DirectoryInfo(resolvedPath); DirectoryInfo di = new DirectoryInfo(resolvedPath);
@ -41,10 +40,8 @@ namespace ImageProcessorConsole
di.Create(); di.Create();
} }
//FileInfo[] files = di.GetFiles("*.jpg"); IEnumerable<FileInfo> files = GetFilesByExtensions(di, ".gif");
//FileInfo[] files = di.GetFiles(); //IEnumerable<FileInfo> files = GetFilesByExtensions(di, ".gif", ".webp", ".bmp", ".jpg", ".png");
IEnumerable<FileInfo> files = GetFilesByExtensions(di, ".gif", ".webp");
foreach (FileInfo fileInfo in files) foreach (FileInfo fileInfo in files)
{ {
@ -53,18 +50,13 @@ namespace ImageProcessorConsole
// ImageProcessor // ImageProcessor
using (MemoryStream inStream = new MemoryStream(photoBytes)) using (MemoryStream inStream = new MemoryStream(photoBytes))
{ {
using (ImageFactory imageFactory = new ImageFactory()) using (ImageFactory imageFactory = new ImageFactory(true))
{ {
Size size = new Size(200, 200); Size size = new Size(200, 200);
// Load, resize, set the format and quality and save an image. // Load, resize, set the format and quality and save an image.
imageFactory.Load(inStream) imageFactory.Load(inStream)
//.AutoRotate()
.Constrain(size) .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))); .Save(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(path), @"..\..\images\output", fileInfo.Name)));
} }
} }
@ -74,7 +66,10 @@ namespace ImageProcessorConsole
public static IEnumerable<FileInfo> GetFilesByExtensions(DirectoryInfo dir, params string[] extensions) public static IEnumerable<FileInfo> GetFilesByExtensions(DirectoryInfo dir, params string[] extensions)
{ {
if (extensions == null) if (extensions == null)
{
throw new ArgumentNullException("extensions"); throw new ArgumentNullException("extensions");
}
IEnumerable<FileInfo> files = dir.EnumerateFiles(); IEnumerable<FileInfo> files = dir.EnumerateFiles();
return files.Where(f => extensions.Contains(f.Extension, StringComparer.OrdinalIgnoreCase)); return files.Where(f => extensions.Contains(f.Extension, StringComparer.OrdinalIgnoreCase));
} }

2
src/ImageProcessorConsole/images/output/120430.gif.REMOVED.git-id

@ -1 +1 @@
30ec5c05548fd350f9b7c699715848b9fbfb8ca9 6f3f997e323adb1fce142930d86338efacffc3fd

2
src/ImageProcessorConsole/images/output/Tl4Yb.gif.REMOVED.git-id

@ -1 +1 @@
fdc62fc2d056ab885eb9e8fd12b9155ee86d7c43 3ab082661fc5d88f88643c47409e196d66e26d4b

3
src/ImageProcessorConsole/images/output/circle.png

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:f31110b7933864eff3b149371c962174a8855a1c65f4fee7cb3bc63a79b71467
size 2905

2
src/ImageProcessorConsole/images/output/nLpfllv.gif.REMOVED.git-id

@ -1 +1 @@
77cce70db3722920d60f4b17a45a5e390a09838a e2c2fbac64987ad26e19f5d2721fcaa60fee843d
Loading…
Cancel
Save