Browse Source

Fixing bgcolor regex

Former-commit-id: f878f9bea312ce4533e8ef3e5d432f059079c18b
af/merge-core
James South 12 years ago
parent
commit
21acd14434
  1. 8
      src/ImageProcessor/Processors/Resize.cs
  2. 13
      src/TestWebsites/NET45/Test_Website_NET45/Views/Home/Index.cshtml

8
src/ImageProcessor/Processors/Resize.cs

@ -30,7 +30,7 @@ namespace ImageProcessor.Processors
/// <summary>
/// The regular expression to search strings for.
/// </summary>
private static readonly Regex QueryRegex = new Regex(@"((width|height)=\d+)|(mode=(pad|stretch|crop))|(bgcolor-([0-9a-fA-F]{3}){1,2})", RegexOptions.Compiled);
private static readonly Regex QueryRegex = new Regex(@"((width|height)=\d+)|(mode=(pad|stretch|crop))|(bgcolor=([0-9a-fA-F]{3}){1,2})", RegexOptions.Compiled);
/// <summary>
/// The regular expression to search strings for the size attribute.
@ -45,7 +45,7 @@ namespace ImageProcessor.Processors
/// <summary>
/// The regular expression to search strings for the color attribute.
/// </summary>
private static readonly Regex ColorRegex = new Regex(@"bgcolor-([0-9a-fA-F]{3}){1,2}", RegexOptions.Compiled);
private static readonly Regex ColorRegex = new Regex(@"bgcolor=([0-9a-fA-F]{3}){1,2}", RegexOptions.Compiled);
#region IGraphicsProcessor Members
/// <summary>
@ -249,8 +249,8 @@ namespace ImageProcessor.Processors
{
foreach (Match match in ColorRegex.Matches(input))
{
// split on color-hex
return ColorTranslator.FromHtml("#" + match.Value.Split('-')[1]);
// Split on color-hex
return ColorTranslator.FromHtml("#" + match.Value.Split('=')[1]);
}
return Color.Transparent;

13
src/TestWebsites/NET45/Test_Website_NET45/Views/Home/Index.cshtml

@ -17,17 +17,14 @@
</div>
</div>
</section>
<section>
<section>
<div class="row">
<div class="column-6">
<h2>Padded</h2>
<h2>Padded</h2>
<div class="column-4">
<img src="/images/Penguins.jpg?width=300&height=500" />
@* <h3>Foreign language test.</h3>
<img src="/images/udendørs.jpg?width=300" />*@
</div>
<div class="column-6">
@* <h2>Cropped </h2>
<img src="/images/Penguins.jpg?crop=0-0-300-225" />*@
<div class="column-8">
<img src="/images/udendørs.jpg?width=600&height=250" />
</div>
</div>
</section>

Loading…
Cancel
Save