Browse Source

Adding ability to set size and width to change aspect ratio

Former-commit-id: 078adf8fcfe69cea6ec26c8da60dbfc22775a9d0
pull/17/head
JimBobSquarePants 14 years ago
parent
commit
f5271812f2
  1. 6
      src/ImageProcessor.Web/Properties/AssemblyInfo.cs
  2. 45
      src/ImageProcessor/Processors/Resize.cs
  3. 6
      src/ImageProcessor/Properties/AssemblyInfo.cs

6
src/ImageProcessor.Web/Properties/AssemblyInfo.cs

@ -6,8 +6,8 @@ using System.Runtime.InteropServices;
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ImageProcessor.Web")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyDescription("A library for on-the-fly processing of image files with .NET written in C#")]
[assembly: AssemblyConfiguration("James South")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ImageProcessor.Web")]
[assembly: AssemblyCopyright("Copyright © 2012")]
@ -32,5 +32,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("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyFileVersion("1.0.0.0")]

45
src/ImageProcessor/Processors/Resize.cs

@ -8,7 +8,6 @@ namespace ImageProcessor.Processors
{
#region Using
using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
@ -25,7 +24,7 @@ namespace ImageProcessor.Processors
/// <summary>
/// The regular expression to search strings for.
/// </summary>
private static readonly Regex QueryRegex = new Regex(@"(width|height)=\d+", RegexOptions.Compiled);
private static readonly Regex QueryRegex = new Regex(@"((width|height)=\d+|resize=width-\d+\|height-\d+)", RegexOptions.Compiled);
#region IGraphicsProcessor Members
/// <summary>
@ -60,7 +59,7 @@ namespace ImageProcessor.Processors
return QueryRegex;
}
}
/// <summary>
/// Gets or sets DynamicParameter.
/// </summary>
@ -99,22 +98,31 @@ namespace ImageProcessor.Processors
/// </returns>
public int MatchRegexIndex(string queryString)
{
int index = 0;
int index = 0;
// Set the sort order to max to allow filtering.
this.SortOrder = int.MaxValue;
Size size = new Size();
// Set the sort order to max to allow filtering.
this.SortOrder = int.MaxValue;
Size size = new Size();
foreach (Match match in this.RegexPattern.Matches(queryString))
foreach (Match match in this.RegexPattern.Matches(queryString))
{
if (match.Success)
{
if (match.Success)
if (index == 0)
{
if (index == 0)
{
// Set the index on the first instance only.
this.SortOrder = match.Index;
}
// Set the index on the first instance only.
this.SortOrder = match.Index;
}
if (match.Value.Contains("resize"))
{
int[] values = match.Value.ToIntegerArray();
size.Width = values[0];
size.Height = values[1];
}
else
{
if (match.Value.Contains("width"))
{
size.Width = match.Value.ToIntegerArray()[0];
@ -123,13 +131,14 @@ namespace ImageProcessor.Processors
{
size.Height = match.Value.ToIntegerArray()[0];
}
index += 1;
}
index += 1;
}
}
this.DynamicParameter = size;
return this.SortOrder;
this.DynamicParameter = size;
return this.SortOrder;
}
/// <summary>

6
src/ImageProcessor/Properties/AssemblyInfo.cs

@ -7,9 +7,9 @@ using System.Security;
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ImageProcessor")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyDescription("A library for on-the-fly processing of image files with Asp.NET written in C#")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyCompany("James South")]
[assembly: AssemblyProduct("ImageProcessor")]
[assembly: AssemblyCopyright("Copyright © 2012")]
[assembly: AssemblyTrademark("")]
@ -33,6 +33,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.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyFileVersion("1.0.0.0")]

Loading…
Cancel
Save