diff --git a/src/ImageProcessor.Tests/RegularExpressionUnitTests.cs b/src/ImageProcessor.Tests/RegularExpressionUnitTests.cs index 938f3cf158..c9d2da4629 100644 --- a/src/ImageProcessor.Tests/RegularExpressionUnitTests.cs +++ b/src/ImageProcessor.Tests/RegularExpressionUnitTests.cs @@ -132,11 +132,7 @@ namespace ImageProcessor.Tests public void TestRotateRegex() { const string Querystring = "rotate=270"; - RotateLayer expected = new RotateLayer - { - Angle = 270, - BackgroundColor = Color.Transparent - }; + RotateLayer expected = new RotateLayer(270, Color.Transparent); Rotate rotate = new Rotate(); rotate.MatchRegexIndex(Querystring); diff --git a/src/ImageProcessor.Web/Caching/DiskCache.cs b/src/ImageProcessor.Web/Caching/DiskCache.cs index 5ad38d0514..33d48d19ff 100644 --- a/src/ImageProcessor.Web/Caching/DiskCache.cs +++ b/src/ImageProcessor.Web/Caching/DiskCache.cs @@ -304,7 +304,7 @@ namespace ImageProcessor.Web.Caching /// internal async Task SetCachedLastWriteTimeAsync() { - // Create Action delegate for IsNewOrUpdatedFile. + // Create Action delegate for SetCachedLastWriteTime. return await TaskHelpers.Run(() => this.SetCachedLastWriteTime()); } diff --git a/src/ImageProcessor.Web/Properties/AssemblyInfo.cs b/src/ImageProcessor.Web/Properties/AssemblyInfo.cs index 17f097b7cd..5d2325f207 100644 --- a/src/ImageProcessor.Web/Properties/AssemblyInfo.cs +++ b/src/ImageProcessor.Web/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ using System.Runtime.InteropServices; // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("2.1.1.0")] -[assembly: AssemblyFileVersion("2.1.1.0")] +[assembly: AssemblyVersion("2.1.2.0")] +[assembly: AssemblyFileVersion("2.1.2.0")] diff --git a/src/ImageProcessor/ImageFactory.cs b/src/ImageProcessor/ImageFactory.cs index ea9891d8bd..b9f710a558 100644 --- a/src/ImageProcessor/ImageFactory.cs +++ b/src/ImageProcessor/ImageFactory.cs @@ -184,7 +184,7 @@ namespace ImageProcessor } /// - /// Resets the ImageFactory to its original loaded state. + /// Resets the current image to its original loaded state. /// /// /// The current instance of the class. @@ -213,7 +213,6 @@ namespace ImageProcessor return this; } - #region Manipulation /// /// Adds a query-string to the image factory to allow auto-processing of remote files. @@ -317,7 +316,7 @@ namespace ImageProcessor } /// - /// Crops an image to the given coordinates. + /// Crops the current image to the given location and size. /// /// /// The containing the coordinates to crop the image to. @@ -338,7 +337,7 @@ namespace ImageProcessor } /// - /// Applies a filter to an image. + /// Applies a filter to the current image. /// /// /// The name of the filter to add to the image. @@ -359,7 +358,7 @@ namespace ImageProcessor } /// - /// Flips an image either horizontally or vertically. + /// Flips the current image either horizontally or vertically. /// /// /// Whether to flip the image vertically. @@ -384,7 +383,7 @@ namespace ImageProcessor } /// - /// Sets the output format of the image to the matching . + /// Sets the output format of the current image to the matching . /// /// The . to set the image to. /// @@ -401,7 +400,10 @@ namespace ImageProcessor } /// - /// Applies a filter to an image. + /// Alters the output quality of the current image. + /// + /// This method will only effect the output quality of jpeg images + /// /// /// A value between 1 and 100 to set the quality to. /// @@ -418,7 +420,7 @@ namespace ImageProcessor } /// - /// Resizes an image to the given dimensions. + /// Resizes the current image to the given dimensions. /// /// /// The containing the width and height to set the image to. @@ -517,7 +519,7 @@ namespace ImageProcessor } /// - /// Adds a text based watermark to the image + /// Adds a text based watermark to the current image. /// /// /// The containing the properties necessary to add diff --git a/src/ImageProcessor/Imaging/RotateLayer.cs b/src/ImageProcessor/Imaging/RotateLayer.cs index cdf5d75a1e..bce5ff1fca 100644 --- a/src/ImageProcessor/Imaging/RotateLayer.cs +++ b/src/ImageProcessor/Imaging/RotateLayer.cs @@ -26,6 +26,34 @@ namespace ImageProcessor.Imaging { this.BackgroundColor = Color.Transparent; } + + /// + /// Initializes a new instance of the class. + /// + /// + /// The angle at which to rotate the image. + /// + public RotateLayer(int angle) + { + this.Angle = angle; + this.BackgroundColor = Color.Transparent; + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// The angle at which to rotate the image. + /// + /// + /// The to set as the background color. + /// Used for image formats that do not support transparency + /// + public RotateLayer(int angle, Color backgroundColor) + { + this.Angle = angle; + this.BackgroundColor = backgroundColor; + } #endregion #region Properties diff --git a/src/ImageProcessor/Imaging/TextLayer.cs b/src/ImageProcessor/Imaging/TextLayer.cs index a98df299e8..df367eaa3a 100644 --- a/src/ImageProcessor/Imaging/TextLayer.cs +++ b/src/ImageProcessor/Imaging/TextLayer.cs @@ -14,7 +14,7 @@ namespace ImageProcessor.Imaging #endregion /// - /// Enacapsulates the properties required to add a layer of text to an image. + /// Encapsulates the properties required to add a layer of text to an image. /// public class TextLayer { diff --git a/src/ImageProcessor/Processors/Rotate.cs b/src/ImageProcessor/Processors/Rotate.cs index 480085aa51..831250700d 100644 --- a/src/ImageProcessor/Processors/Rotate.cs +++ b/src/ImageProcessor/Processors/Rotate.cs @@ -100,21 +100,20 @@ namespace ImageProcessor.Processors // Set the index on the first instance only. this.SortOrder = match.Index; - RotateLayer rotateLayer = new RotateLayer(); + RotateLayer rotateLayer; string toParse = match.Value; if (toParse.Contains("bgcolor")) { - rotateLayer.Angle = this.ParseAngle(toParse); - rotateLayer.BackgroundColor = this.ParseColor(toParse); + rotateLayer = new RotateLayer(this.ParseAngle(toParse), this.ParseColor(toParse)); } else { int degrees; int.TryParse(match.Value.Split('=')[1], out degrees); - rotateLayer.Angle = degrees; + rotateLayer = new RotateLayer(degrees); } this.DynamicParameter = rotateLayer; diff --git a/src/ImageProcessor/Properties/AssemblyInfo.cs b/src/ImageProcessor/Properties/AssemblyInfo.cs index a5f50e13df..c921411c06 100644 --- a/src/ImageProcessor/Properties/AssemblyInfo.cs +++ b/src/ImageProcessor/Properties/AssemblyInfo.cs @@ -32,6 +32,6 @@ using System.Security; // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("1.4.2.0")] -[assembly: AssemblyFileVersion("1.4.2.0")] +[assembly: AssemblyVersion("1.5.0.0")] +[assembly: AssemblyFileVersion("1.5.0.0")] diff --git a/src/Nuget/ImageProcessor.1.5.0.0.nupkg b/src/Nuget/ImageProcessor.1.5.0.0.nupkg new file mode 100644 index 0000000000..ef69659f55 Binary files /dev/null and b/src/Nuget/ImageProcessor.1.5.0.0.nupkg differ diff --git a/src/Nuget/ImageProcessor.Web.2.1.2.0.nupkg.REMOVED.git-id b/src/Nuget/ImageProcessor.Web.2.1.2.0.nupkg.REMOVED.git-id new file mode 100644 index 0000000000..fd25a7d258 --- /dev/null +++ b/src/Nuget/ImageProcessor.Web.2.1.2.0.nupkg.REMOVED.git-id @@ -0,0 +1 @@ +1ac41e14e3ae5f8ac9b06bcfbbacc6c4a9841863 \ No newline at end of file diff --git a/src/Test/Test/Controllers/HomeController.cs b/src/Test/Test/Controllers/HomeController.cs index 7751ac03f4..001908d616 100644 --- a/src/Test/Test/Controllers/HomeController.cs +++ b/src/Test/Test/Controllers/HomeController.cs @@ -6,11 +6,16 @@ using System.Web.Mvc; namespace Test.Controllers { + using System.Drawing; + using System.Drawing.Imaging; using System.IO; using System.Threading.Tasks; using System.Web.Hosting; + using ImageProcessor; using ImageProcessor.Helpers.Extensions; + using ImageProcessor.Imaging; + //using ImageProcessor.Web.Caching; public class HomeController : Controller @@ -22,6 +27,67 @@ namespace Test.Controllers return View(); } + public ActionResult Upload() + { + return View(); + } + + [HttpPost] + public ActionResult Upload(HttpPostedFileBase file) + { + Stream upload = file.InputStream; + int quality = 70; + ImageFormat format = ImageFormat.Jpeg; + Size size460 = new Size(460, 0); + Size size320 = new Size(320, 0); + Size size240 = new Size(240, 0); + + // Make sure the directory exists as Image.Save will not work without an existing directory. + string outputPath = HostingEnvironment.MapPath("~/Resized"); + if (outputPath != null) + { + DirectoryInfo directoryInfo = new DirectoryInfo(outputPath); + + if (!directoryInfo.Exists) + { + directoryInfo.Create(); + } + + // Make the three file paths + string outputfile1 = Path.Combine(outputPath, "460px_" + file.FileName); + string outputfile2 = Path.Combine(outputPath, "320px_" + file.FileName); + string outputfile3 = Path.Combine(outputPath, "240px_" + file.FileName); + + using (MemoryStream inStream = new MemoryStream()) + { + // Copy the stream across. + upload.CopyTo(inStream); + + using (ImageFactory imageFactory = new ImageFactory()) + { + // Load, resize, set the format and quality and save an image. + imageFactory.Load(inStream) + .Format(format) + .Quality(quality) + .Resize(size460) + .Save(outputfile1) + .Reset() + .Format(format) + .Quality(quality) + .Resize(size320) + .Save(outputfile2) + .Reset() + .Format(format) + .Quality(quality) + .Resize(size240) + .Save(outputfile3); + } + } + } + + return View(); + } + public ActionResult About() { List images = new List(); diff --git a/src/Test/Test/Resized/240px_228406_276791782435436_815038966_n.jpg b/src/Test/Test/Resized/240px_228406_276791782435436_815038966_n.jpg new file mode 100644 index 0000000000..86e525e3f7 --- /dev/null +++ b/src/Test/Test/Resized/240px_228406_276791782435436_815038966_n.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ea75dd804dbc2685d2189f9e5fba063427416cc3c024f9962ab10b8efc1471b0 +size 17302 diff --git a/src/Test/Test/Resized/240px_MSwanson - Wide Large - Rock 02.jpg b/src/Test/Test/Resized/240px_MSwanson - Wide Large - Rock 02.jpg new file mode 100644 index 0000000000..9043851f9f --- /dev/null +++ b/src/Test/Test/Resized/240px_MSwanson - Wide Large - Rock 02.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bc4e1cd326a27789dfa3ad493b25611f31133f733e193e3eb5b4f8bc14429d1f +size 16510 diff --git a/src/Test/Test/Resized/240px_Neck2-1.jpg b/src/Test/Test/Resized/240px_Neck2-1.jpg new file mode 100644 index 0000000000..8471f5d252 --- /dev/null +++ b/src/Test/Test/Resized/240px_Neck2-1.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2633b42dfcd1b253ae2733d854a8801bd8ed547157dbcb148c529a3f2e213298 +size 25044 diff --git a/src/Test/Test/Resized/320px_228406_276791782435436_815038966_n.jpg b/src/Test/Test/Resized/320px_228406_276791782435436_815038966_n.jpg new file mode 100644 index 0000000000..a7770e71e1 --- /dev/null +++ b/src/Test/Test/Resized/320px_228406_276791782435436_815038966_n.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:38e73ab2ad96ab405755b53559490954f5eb6fb2bedffa2b619cfd5369f66998 +size 28894 diff --git a/src/Test/Test/Resized/320px_MSwanson - Wide Large - Rock 02.jpg b/src/Test/Test/Resized/320px_MSwanson - Wide Large - Rock 02.jpg new file mode 100644 index 0000000000..51c860e358 --- /dev/null +++ b/src/Test/Test/Resized/320px_MSwanson - Wide Large - Rock 02.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:319b3e4178951cabacd28dfee025f076e69e2c789d8a193236912a907083826c +size 27223 diff --git a/src/Test/Test/Resized/320px_Neck2-1.jpg b/src/Test/Test/Resized/320px_Neck2-1.jpg new file mode 100644 index 0000000000..fff5897a31 --- /dev/null +++ b/src/Test/Test/Resized/320px_Neck2-1.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5b203a58a268c47fce91ef419f996ef175d5a87f967ac2cc7978fb07bb7906da +size 39920 diff --git a/src/Test/Test/Resized/460px_228406_276791782435436_815038966_n.jpg b/src/Test/Test/Resized/460px_228406_276791782435436_815038966_n.jpg new file mode 100644 index 0000000000..15033ed2d0 --- /dev/null +++ b/src/Test/Test/Resized/460px_228406_276791782435436_815038966_n.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0b50ba1e1003fcd44917f594081a3d4007ccbb65a2bd51e78de89c3ed413f301 +size 57565 diff --git a/src/Test/Test/Resized/460px_MSwanson - Wide Large - Rock 02.jpg b/src/Test/Test/Resized/460px_MSwanson - Wide Large - Rock 02.jpg new file mode 100644 index 0000000000..534c9f0ccf --- /dev/null +++ b/src/Test/Test/Resized/460px_MSwanson - Wide Large - Rock 02.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:24861d2f61cb23d5bd2ad01740a1086a0623bbc1b4ed35f04bda24b345b5c62a +size 28858 diff --git a/src/Test/Test/Resized/460px_Neck2-1.jpg b/src/Test/Test/Resized/460px_Neck2-1.jpg new file mode 100644 index 0000000000..ac5ff0fd06 --- /dev/null +++ b/src/Test/Test/Resized/460px_Neck2-1.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fca1fdc26920f19d9ee821975afd3640e25208993055e75d0118b29ba4c1f2d6 +size 41399 diff --git a/src/Test/Test/Test.csproj b/src/Test/Test/Test.csproj index b0c9b6fe67..7b2e3093ff 100644 --- a/src/Test/Test/Test.csproj +++ b/src/Test/Test/Test.csproj @@ -136,6 +136,9 @@ + + + 10.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) diff --git a/src/Test/Test/Views/Home/Upload.cshtml b/src/Test/Test/Views/Home/Upload.cshtml new file mode 100644 index 0000000000..cf077c2a4b --- /dev/null +++ b/src/Test/Test/Views/Home/Upload.cshtml @@ -0,0 +1,5 @@ +@using (Html.BeginForm("Upload", "Home", FormMethod.Post, new { enctype = "multipart/form-data" })) +{ + + +} \ No newline at end of file diff --git a/src/Test/Test/Web.config b/src/Test/Test/Web.config index e7c9d334c5..f6e8b95f05 100644 --- a/src/Test/Test/Web.config +++ b/src/Test/Test/Web.config @@ -4,84 +4,84 @@ http://go.microsoft.com/fwlink/?LinkId=152368 --> - - - -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file