Browse Source

v1.8.1.2 pre

- Fixes #28 Sigma parsing error
- Format now determines jpeg/jpg & tiff/tif files
- Touches #18 Hopeful fix.


Former-commit-id: bff79b25501b3a985c54a4753ba781b313d2e844
pull/17/head
James South 12 years ago
parent
commit
393cf1caa8
  1. 18
      src/ImageProcessor/ImageFactory.cs
  2. 4
      src/ImageProcessor/Imaging/ImageUtils.cs
  3. 6
      src/ImageProcessor/Processors/Format.cs
  4. 2
      src/ImageProcessor/Processors/GaussianBlur.cs
  5. 3
      src/ImageProcessor/Processors/GaussianSharpen.cs
  6. 4
      src/ImageProcessor/Properties/AssemblyInfo.cs
  7. 4
      src/TestWebsites/NET45/Test_Website_NET45/Views/Home/Index.cshtml

18
src/ImageProcessor/ImageFactory.cs

@ -40,11 +40,6 @@ namespace ImageProcessor
/// </summary>
private ImageFormat backupImageFormat;
/// <summary>
/// The original extension.
/// </summary>
private string originalExtension;
/// <summary>
/// Whether the image is indexed.
/// </summary>
@ -110,6 +105,11 @@ namespace ImageProcessor
/// Gets the file format of the image.
/// </summary>
public ImageFormat ImageFormat { get; private set; }
/// <summary>
/// Gets or sets the original extension.
/// </summary>
internal string OriginalExtension { get; set; }
/// <summary>
/// Gets or sets the quality of output for jpeg images as a percentile.
@ -191,7 +191,7 @@ namespace ImageProcessor
this.JpegQuality = DefaultJpegQuality;
ImageFormat imageFormat = ImageUtils.GetImageFormat(imageName);
this.backupImageFormat = imageFormat;
this.originalExtension = Path.GetExtension(this.ImagePath);
this.OriginalExtension = Path.GetExtension(this.ImagePath);
this.ImageFormat = imageFormat;
this.isIndexed = ImageUtils.IsIndexed(this.Image);
this.ShouldProcess = true;
@ -762,7 +762,7 @@ namespace ImageProcessor
// We need to check here if the path has an extension and remove it if so.
// This is so we can add the correct image format.
int length = filePath.LastIndexOf(".", StringComparison.Ordinal);
string extension = ImageUtils.GetExtensionFromImageFormat(this.ImageFormat, this.originalExtension);
string extension = ImageUtils.GetExtensionFromImageFormat(this.ImageFormat, this.OriginalExtension);
filePath = length == -1 ? filePath + extension : filePath.Substring(0, length) + extension;
// Fix the colour palette of indexed images.
@ -795,7 +795,7 @@ namespace ImageProcessor
this.Image.Save(filePath, imageCodecInfo, encoderParameters);
break;
}
catch (IOException)
catch (Exception)
{
Thread.Sleep(200);
}
@ -817,7 +817,7 @@ namespace ImageProcessor
this.Image.Save(filePath, this.ImageFormat);
break;
}
catch (IOException)
catch (Exception)
{
Thread.Sleep(200);
}

4
src/ImageProcessor/Imaging/ImageUtils.cs

@ -27,12 +27,12 @@ namespace ImageProcessor.Imaging
/// <summary>
/// The image format regex.
/// </summary>
private static readonly Regex FormatRegex = new Regex(@"(\.?)(j(pg|peg)|bmp|png|gif|ti(f|ff))", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.RightToLeft);
private static readonly Regex FormatRegex = new Regex(@"(\.?)(j(pg|peg)|bmp|png|gif|ti(ff|f))", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.RightToLeft);
/// <summary>
/// The image format regex for matching the file format at the end of a string.
/// </summary>
private static readonly Regex EndFormatRegex = new Regex(@"(\.)(j(pg|peg)|bmp|png|gif|ti(f|ff))$", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.RightToLeft);
private static readonly Regex EndFormatRegex = new Regex(@"(\.)(j(pg|peg)|bmp|png|gif|ti(ff|f))$", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.RightToLeft);
/// <summary>
/// Returns the correct response type based on the given request path.

6
src/ImageProcessor/Processors/Format.cs

@ -25,7 +25,7 @@ namespace ImageProcessor.Processors
/// <summary>
/// The regular expression to search strings for.
/// </summary>
private static readonly Regex QueryRegex = new Regex(@"format=(j(pg|peg)|png|png8|bmp|gif|tif)", RegexOptions.Compiled);
private static readonly Regex QueryRegex = new Regex(@"format=(j(pg|peg)|png|png8|bmp|gif|ti(ff|f))", RegexOptions.Compiled);
#region IGraphicsProcessor Members
/// <summary>
@ -132,15 +132,17 @@ namespace ImageProcessor.Processors
isIndexed = true;
break;
case "tif":
case "tiff":
imageFormat = ImageFormat.Tiff;
break;
default:
// Should be a jpeg.
// Should be a jpeg or jpg.
imageFormat = ImageFormat.Jpeg;
break;
}
// Set the internal property.
factory.OriginalExtension = string.Format(".{0}", format);
factory.Format(imageFormat, isIndexed);
return factory.Image;

2
src/ImageProcessor/Processors/GaussianBlur.cs

@ -35,7 +35,7 @@ namespace ImageProcessor.Processors
/// <summary>
/// The sigma regex.
/// </summary>
private static readonly Regex SigmaRegex = new Regex(@"sigma-\d+(.+\d+)?", RegexOptions.Compiled);
private static readonly Regex SigmaRegex = new Regex(@"sigma-\d+(.?\d+)?", RegexOptions.Compiled);
/// <summary>
/// The threshold regex.

3
src/ImageProcessor/Processors/GaussianSharpen.cs

@ -35,13 +35,14 @@ namespace ImageProcessor.Processors
/// <summary>
/// The sigma regex.
/// </summary>
private static readonly Regex SigmaRegex = new Regex(@"sigma-\d+(.+\d+)?", RegexOptions.Compiled);
private static readonly Regex SigmaRegex = new Regex(@"sigma-\d+(.?\d+)?", RegexOptions.Compiled);
/// <summary>
/// The threshold regex.
/// </summary>
private static readonly Regex ThresholdRegex = new Regex(@"threshold-\d+", RegexOptions.Compiled);
#endregion
#region IGraphicsProcessor Members
/// <summary>
/// Gets the regular expression to search strings for.

4
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.8.1.1")]
[assembly: AssemblyFileVersion("1.8.1.1")]
[assembly: AssemblyVersion("1.8.1.2")]
[assembly: AssemblyFileVersion("1.8.1.2")]

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

@ -173,11 +173,11 @@
<div class="row">
<div class="col-s-6">
<h2>Gaussian Blur</h2>
<img src="/images/Penguins.jpg?width=300&blur=7" />
<img src="/images/Penguins.jpg?width=300&blur=11,sigma-1.5,threshold-10" />
</div>
<div class="col-s-6">
<h2>Gaussian Sharpen</h2>
<img src="/images/Penguins.jpg?width=300&sharpen=7" />
<img src="/images/Penguins.jpg?width=300&blur=11,sigma-1.5,threshold-10" />
</div>
</div>
</section>

Loading…
Cancel
Save