Skip to content

Commit

Permalink
v2.1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
JimBobSquarePants committed Apr 7, 2013
1 parent d09731b commit 66af63f
Show file tree
Hide file tree
Showing 23 changed files with 203 additions and 104 deletions.
6 changes: 1 addition & 5 deletions src/ImageProcessor.Tests/RegularExpressionUnitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,7 @@ public void TestResizeRegex()
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);
Expand Down
2 changes: 1 addition & 1 deletion src/ImageProcessor.Web/Caching/DiskCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ internal async Task<bool> IsNewOrUpdatedFileAsync()
/// </returns>
internal async Task<DateTime> SetCachedLastWriteTimeAsync()
{
// Create Action delegate for IsNewOrUpdatedFile.
// Create Action delegate for SetCachedLastWriteTime.
return await TaskHelpers.Run(() => this.SetCachedLastWriteTime());
}

Expand Down
4 changes: 2 additions & 2 deletions src/ImageProcessor.Web/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
//
// 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")]
20 changes: 11 additions & 9 deletions src/ImageProcessor/ImageFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public ImageFactory Load(string imagePath)
}

/// <summary>
/// Resets the ImageFactory to its original loaded state.
/// Resets the current image to its original loaded state.
/// </summary>
/// <returns>
/// The current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class.
Expand Down Expand Up @@ -213,7 +213,6 @@ public ImageFactory Reset()
return this;
}


#region Manipulation
/// <summary>
/// Adds a query-string to the image factory to allow auto-processing of remote files.
Expand Down Expand Up @@ -317,7 +316,7 @@ public ImageFactory Contrast(int percentage)
}

/// <summary>
/// Crops an image to the given coordinates.
/// Crops the current image to the given location and size.
/// </summary>
/// <param name="rectangle">
/// The <see cref="T:System.Drawing.Rectangle"/> containing the coordinates to crop the image to.
Expand All @@ -338,7 +337,7 @@ public ImageFactory Crop(Rectangle rectangle)
}

/// <summary>
/// Applies a filter to an image.
/// Applies a filter to the current image.
/// </summary>
/// <param name="filterName">
/// The name of the filter to add to the image.
Expand All @@ -359,7 +358,7 @@ public ImageFactory Filter(string filterName)
}

/// <summary>
/// Flips an image either horizontally or vertically.
/// Flips the current image either horizontally or vertically.
/// </summary>
/// <param name="flipVertically">
/// Whether to flip the image vertically.
Expand All @@ -384,7 +383,7 @@ public ImageFactory Flip(bool flipVertically)
}

/// <summary>
/// Sets the output format of the image to the matching <see cref="T:System.Drawing.Imaging.ImageFormat"/>.
/// Sets the output format of the current image to the matching <see cref="T:System.Drawing.Imaging.ImageFormat"/>.
/// </summary>
/// <param name="imageFormat">The <see cref="T:System.Drawing.Imaging.ImageFormat"/>. to set the image to.</param>
/// <returns>
Expand All @@ -401,7 +400,10 @@ public ImageFactory Format(ImageFormat imageFormat)
}

/// <summary>
/// Applies a filter to an image.
/// Alters the output quality of the current image.
/// <remarks>
/// This method will only effect the output quality of jpeg images
/// </remarks>
/// </summary>
/// <param name="percentage">A value between 1 and 100 to set the quality to.</param>
/// <returns>
Expand All @@ -418,7 +420,7 @@ public ImageFactory Quality(int percentage)
}

/// <summary>
/// Resizes an image to the given dimensions.
/// Resizes the current image to the given dimensions.
/// </summary>
/// <param name="size">
/// The <see cref="T:System.Drawing.Size"/> containing the width and height to set the image to.
Expand Down Expand Up @@ -517,7 +519,7 @@ public ImageFactory Vignette()
}

/// <summary>
/// Adds a text based watermark to the image
/// Adds a text based watermark to the current image.
/// </summary>
/// <param name="textLayer">
/// The <see cref="T:ImageProcessor.Imaging.TextLayer"/> containing the properties necessary to add
Expand Down
28 changes: 28 additions & 0 deletions src/ImageProcessor/Imaging/RotateLayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,34 @@ public RotateLayer()
{
this.BackgroundColor = Color.Transparent;
}

/// <summary>
/// Initializes a new instance of the <see cref="RotateLayer"/> class.
/// </summary>
/// <param name="angle">
/// The angle at which to rotate the image.
/// </param>
public RotateLayer(int angle)
{
this.Angle = angle;
this.BackgroundColor = Color.Transparent;
}

/// <summary>
/// Initializes a new instance of the <see cref="RotateLayer"/> class.
/// </summary>
/// <param name="angle">
/// The angle at which to rotate the image.
/// </param>
/// <param name="backgroundColor">
/// The <see cref="T:System.Drawing.Color"/> to set as the background color.
/// <remarks>Used for image formats that do not support transparency</remarks>
/// </param>
public RotateLayer(int angle, Color backgroundColor)
{
this.Angle = angle;
this.BackgroundColor = backgroundColor;
}
#endregion

#region Properties
Expand Down
2 changes: 1 addition & 1 deletion src/ImageProcessor/Imaging/TextLayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace ImageProcessor.Imaging
#endregion

/// <summary>
/// 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.
/// </summary>
public class TextLayer
{
Expand Down
7 changes: 3 additions & 4 deletions src/ImageProcessor/Processors/Rotate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,20 @@ public int MatchRegexIndex(string queryString)
// 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;
Expand Down
4 changes: 2 additions & 2 deletions src/ImageProcessor/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
//
// 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")]

Binary file added src/Nuget/ImageProcessor.1.5.0.0.nupkg
Binary file not shown.
Binary file added src/Nuget/ImageProcessor.Web.2.1.2.0.nupkg
Binary file not shown.
66 changes: 66 additions & 0 deletions src/Test/Test/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@

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
Expand All @@ -22,6 +27,67 @@ public ActionResult Index()
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<string> images = new List<string>();
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/Test/Test/Resized/240px_Neck2-1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/Test/Test/Resized/320px_Neck2-1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/Test/Test/Resized/460px_Neck2-1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/Test/Test/Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@
<ItemGroup>
<Content Include="Views\Home\Collisions.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Home\Upload.cshtml" />
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
Expand Down
5 changes: 5 additions & 0 deletions src/Test/Test/Views/Home/Upload.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@using (Html.BeginForm("Upload", "Home", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
<input type="file" name="file" />
<button type="submit">Upload</button>
}
Loading

0 comments on commit 66af63f

Please sign in to comment.