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..79ed5e34dd Binary files /dev/null and b/src/Test/Test/Resized/240px_228406_276791782435436_815038966_n.jpg differ 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..155d03abc9 Binary files /dev/null and b/src/Test/Test/Resized/240px_MSwanson - Wide Large - Rock 02.jpg differ 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..366b7cb8bc Binary files /dev/null and b/src/Test/Test/Resized/240px_Neck2-1.jpg differ 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..387d049a68 Binary files /dev/null and b/src/Test/Test/Resized/320px_228406_276791782435436_815038966_n.jpg differ 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..54f1b50584 Binary files /dev/null and b/src/Test/Test/Resized/320px_MSwanson - Wide Large - Rock 02.jpg differ 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..1bc7e6a8e5 Binary files /dev/null and b/src/Test/Test/Resized/320px_Neck2-1.jpg differ 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..fc6a899b76 Binary files /dev/null and b/src/Test/Test/Resized/460px_228406_276791782435436_815038966_n.jpg differ 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..8747ee6614 Binary files /dev/null and b/src/Test/Test/Resized/460px_MSwanson - Wide Large - Rock 02.jpg differ 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..05a0d33e2e Binary files /dev/null and b/src/Test/Test/Resized/460px_Neck2-1.jpg differ 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