Browse Source

Refactoring contstrain method

Former-commit-id: 067625171fad56876018048da7d3c07353a4dca6
af/merge-core
James South 12 years ago
parent
commit
e3633409d2
  1. 56
      src/ImageProcessor.Tests/RegularExpressionUnitTests.cs
  2. 2
      src/ImageProcessor.Web/NET45/Caching/CacheIndexer.cs
  3. 14
      src/ImageProcessor.Web/NET45/Caching/CachedImage.cs
  4. 4
      src/ImageProcessor.Web/NET45/Properties/AssemblyInfo.cs
  5. 11
      src/ImageProcessor/ImageFactory.cs
  6. 2
      src/ImageProcessor/ImageProcessor.csproj
  7. 2
      src/ImageProcessor/Imaging/ResizeMode.cs
  8. 136
      src/ImageProcessor/Processors/Constrain.cs
  9. 250
      src/ImageProcessor/Processors/Resize.cs
  10. 274
      src/ImageProcessor/Processors/ResizeBase.cs
  11. 3
      src/TestWebsites/NET4/Content/responsive-legacy.min.css
  12. 3
      src/TestWebsites/NET4/Content/responsive.min.css
  13. 1
      src/TestWebsites/NET4/Content/responsive.min.css.REMOVED.git-id
  14. 30
      src/TestWebsites/NET4/Controllers/HomeController.cs
  15. 19
      src/TestWebsites/NET4/Test_Website.csproj
  16. 100
      src/TestWebsites/NET4/Views/Home/Bmp.cshtml
  17. 14
      src/TestWebsites/NET4/Views/Home/External.cshtml
  18. 99
      src/TestWebsites/NET4/Views/Home/Gif.cshtml
  19. 564
      src/TestWebsites/NET4/Views/Home/Index.cshtml
  20. 99
      src/TestWebsites/NET4/Views/Home/Png.cshtml
  21. 100
      src/TestWebsites/NET4/Views/Home/Png8.cshtml
  22. 99
      src/TestWebsites/NET4/Views/Home/Tiff.cshtml
  23. 41
      src/TestWebsites/NET4/Views/Shared/_Layout.cshtml
  24. 31
      src/TestWebsites/NET4/config/imageprocessor/processing.config
  25. 26
      src/TestWebsites/NET45/Test_Website_NET45/Views/Home/Index.cshtml
  26. 6
      src/TestWebsites/NET45/Test_Website_NET45/config/imageprocessor/processing.config

56
src/ImageProcessor.Tests/RegularExpressionUnitTests.cs

@ -56,44 +56,24 @@ namespace ImageProcessor.Tests
Assert.AreEqual(Expected, actual);
}
/// <summary>
/// The contrast regex unit test.
/// </summary>
[TestMethod]
public void TestContrastRegex()
{
const string Querystring = "contrast=56";
const int Expected = 56;
Contrast contrast = new Contrast();
contrast.MatchRegexIndex(Querystring);
int actual = contrast.DynamicParameter;
Assert.AreEqual(Expected, actual);
}
/// <summary>
/// The constrain regex unit test.
/// </summary>
[TestMethod]
public void TestConstrainRegex()
{
const string Querystring = "constrain=100,200";
const int ExpectedWidth = 100;
const int ExpectedHeight = 200;
Constrain contrast = new Constrain();
contrast.MatchRegexIndex(Querystring);
int actualWidth = contrast.DynamicParameter.Width;
int actualHeight = contrast.DynamicParameter.Height;
Assert.AreEqual(ExpectedWidth, actualWidth);
Assert.AreEqual(ExpectedHeight, actualHeight);
}
/// <summary>
/// <summary>
/// The contrast regex unit test.
/// </summary>
[TestMethod]
public void TestContrastRegex()
{
const string Querystring = "contrast=56";
const int Expected = 56;
Contrast contrast = new Contrast();
contrast.MatchRegexIndex(Querystring);
int actual = contrast.DynamicParameter;
Assert.AreEqual(Expected, actual);
}
/// <summary>
/// The rotate regex unit test.
/// </summary>
[TestMethod]

2
src/ImageProcessor.Web/NET45/Caching/CacheIndexer.cs

@ -82,7 +82,7 @@ namespace ImageProcessor.Web.Caching
{
// Add the CachedImage.
CacheItemPolicy policy = new CacheItemPolicy();
policy.ChangeMonitors.Add(new HostFileChangeMonitor(new List<string>() { cachedImage.Path }));
policy.ChangeMonitors.Add(new HostFileChangeMonitor(new List<string> { cachedImage.Path }));
MemCache.AddItem(cachedImage.Key, cachedImage, policy);
return cachedImage;

14
src/ImageProcessor.Web/NET45/Caching/CachedImage.cs

@ -1,4 +1,14 @@
namespace ImageProcessor.Web.Caching
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="CachedImage.cs" company="James South">
// Copyright (c) James South.
// Licensed under the Apache License, Version 2.0.
// </copyright>
// <summary>
// Describes a cached image
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace ImageProcessor.Web.Caching
{
#region Using
using System;
@ -7,7 +17,7 @@
/// <summary>
/// Describes a cached image
/// </summary>
public sealed class CachedImage
internal sealed class CachedImage
{
/// <summary>
/// Gets or sets the key identifying the cached image.

4
src/ImageProcessor.Web/NET45/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.4.0.0")]
[assembly: AssemblyFileVersion("2.4.0.0")]
[assembly: AssemblyVersion("3.0.0.0")]
[assembly: AssemblyFileVersion("3.0.0.0")]

11
src/ImageProcessor/ImageFactory.cs

@ -336,14 +336,9 @@ namespace ImageProcessor
{
if (this.ShouldProcess)
{
int width = size.Width;
int height = size.Height;
var constrainSettings = new Dictionary<string, string> { { "MaxWidth", width.ToString("G") }, { "MaxHeight", height.ToString("G") } };
Constrain constrain = new Constrain { DynamicParameter = new Size(width, height), Settings = constrainSettings };
ResizeLayer layer = new ResizeLayer(size, ResizeMode.Max);
this.Image = constrain.ProcessImage(this);
return this.Resize(layer);
}
return this;
@ -750,7 +745,7 @@ namespace ImageProcessor
{
if (this.ShouldProcess)
{
// Fix the colour palette of gif images.
// Fix the colour palette of gif and png8 images.
this.FixIndexedPallete();
if (this.ImageFormat.Equals(ImageFormat.Jpeg))

2
src/ImageProcessor/ImageProcessor.csproj

@ -84,9 +84,7 @@
<Compile Include="Imaging\TextLayer.cs" />
<Compile Include="Processors\Alpha.cs" />
<Compile Include="Processors\Brightness.cs" />
<Compile Include="Processors\Constrain.cs" />
<Compile Include="Processors\Contrast.cs" />
<Compile Include="Processors\ResizeBase.cs" />
<Compile Include="Processors\RoundedCorners.cs" />
<Compile Include="Processors\Saturation.cs" />
<Compile Include="Processors\Flip.cs" />

2
src/ImageProcessor/Imaging/ResizeMode.cs

@ -33,6 +33,6 @@ namespace ImageProcessor.Imaging
/// <summary>
/// Constrains the resized image to fit the bounds of its container.
/// </summary>
Constrain
Max
}
}

136
src/ImageProcessor/Processors/Constrain.cs

@ -1,136 +0,0 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Constrain.cs" company="James South">
// Copyright (c) James South.
// Licensed under the Apache License, Version 2.0.
// </copyright>
// <summary>
// Constrains an image to the given dimensions.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace ImageProcessor.Processors
{
#region Using
using System.Collections.Generic;
using System.Drawing;
using System.Text.RegularExpressions;
using ImageProcessor.Helpers.Extensions;
#endregion
/// <summary>
/// Constrains an image to the given dimensions.
/// </summary>
public class Constrain : ResizeBase
{
/// <summary>
/// The regular expression to search strings for.
/// </summary>
private static readonly Regex QueryRegex = new Regex(@"constrain=\d+[,-]\d+", RegexOptions.Compiled);
#region IGraphicsProcessor Members
/// <summary>
/// Gets the regular expression to search strings for.
/// </summary>
public override Regex RegexPattern
{
get
{
return QueryRegex;
}
}
/// <summary>
/// Gets or sets DynamicParameter.
/// </summary>
public override dynamic DynamicParameter { get; set; }
/// <summary>
/// Gets the order in which this processor is to be used in a chain.
/// </summary>
public override int SortOrder { get; protected set; }
/// <summary>
/// Gets or sets any additional settings required by the processor.
/// </summary>
public override Dictionary<string, string> Settings { get; set; }
/// <summary>
/// The position in the original string where the first character of the captured substring was found.
/// </summary>
/// <param name="queryString">
/// The query string to search.
/// </param>
/// <returns>
/// The zero-based starting position in the original string where the captured substring was found.
/// </returns>
public override int MatchRegexIndex(string queryString)
{
int index = 0;
// Set the sort order to max to allow filtering.
this.SortOrder = int.MaxValue;
foreach (Match match in this.RegexPattern.Matches(queryString))
{
if (match.Success)
{
if (index == 0)
{
// Set the index on the first instance only.
this.SortOrder = match.Index;
int[] constraints = match.Value.ToPositiveIntegerArray();
int x = constraints[0];
int y = constraints[1];
this.DynamicParameter = new Size(x, y);
}
index += 1;
}
}
return this.SortOrder;
}
/// <summary>
/// Processes the image.
/// </summary>
/// <param name="factory">
/// The the current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class containing
/// the image to process.
/// </param>
/// <returns>
/// The processed image from the current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class.
/// </returns>
public override Image ProcessImage(ImageFactory factory)
{
double constrainedWidth = this.DynamicParameter.Width;
double constrainedHeight = this.DynamicParameter.Height;
Image original = factory.Image;
double width = original.Width;
double height = original.Height;
if (width > constrainedWidth || height > constrainedHeight)
{
double constraintRatio = constrainedHeight / constrainedWidth;
double originalRatio = height / width;
Size newSize = originalRatio < constraintRatio
? new Size((int)constrainedWidth, 0)
: new Size(0, (int)constrainedHeight);
int defaultMaxWidth;
int defaultMaxHeight;
int.TryParse(this.Settings["MaxWidth"], out defaultMaxWidth);
int.TryParse(this.Settings["MaxHeight"], out defaultMaxHeight);
return this.ResizeImage(factory, newSize.Width, newSize.Height, defaultMaxWidth, defaultMaxHeight, Color.Transparent);
}
return factory.Image;
}
#endregion
}
}

250
src/ImageProcessor/Processors/Resize.cs

@ -15,6 +15,8 @@ namespace ImageProcessor.Processors
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Text;
using System.Text.RegularExpressions;
using ImageProcessor.Helpers.Extensions;
@ -25,12 +27,12 @@ namespace ImageProcessor.Processors
/// <summary>
/// Resizes an image to the given dimensions.
/// </summary>
public class Resize : ResizeBase
public class Resize : IGraphicsProcessor
{
/// <summary>
/// The regular expression to search strings for.
/// </summary>
private static readonly Regex QueryRegex = new Regex(@"((width|height)=\d+)|(mode=(pad|stretch|crop|constrain))|(anchor=(top|bottom|left|right|center))|(bgcolor=([0-9a-fA-F]{3}){1,2})", RegexOptions.Compiled);
private static readonly Regex QueryRegex = new Regex(@"((width|height)=\d+)|(mode=(pad|stretch|crop|max))|(anchor=(top|bottom|left|right|center))|(bgcolor=([0-9a-fA-F]{3}){1,2})", RegexOptions.Compiled);
/// <summary>
/// The regular expression to search strings for the size attribute.
@ -40,7 +42,7 @@ namespace ImageProcessor.Processors
/// <summary>
/// The regular expression to search strings for the mode attribute.
/// </summary>
private static readonly Regex ModeRegex = new Regex(@"mode=(pad|stretch|crop|constrain)", RegexOptions.Compiled);
private static readonly Regex ModeRegex = new Regex(@"mode=(pad|stretch|crop|max)", RegexOptions.Compiled);
/// <summary>
/// The regular expression to search strings for the anchor attribute.
@ -56,7 +58,7 @@ namespace ImageProcessor.Processors
/// <summary>
/// Gets the regular expression to search strings for.
/// </summary>
public override Regex RegexPattern
public Regex RegexPattern
{
get
{
@ -67,7 +69,7 @@ namespace ImageProcessor.Processors
/// <summary>
/// Gets or sets DynamicParameter.
/// </summary>
public override dynamic DynamicParameter
public dynamic DynamicParameter
{
get;
set;
@ -76,16 +78,16 @@ namespace ImageProcessor.Processors
/// <summary>
/// Gets the order in which this processor is to be used in a chain.
/// </summary>
public override int SortOrder
public int SortOrder
{
get;
protected set;
private set;
}
/// <summary>
/// Gets or sets any additional settings required by the processor.
/// </summary>
public override Dictionary<string, string> Settings
public Dictionary<string, string> Settings
{
get;
set;
@ -100,7 +102,7 @@ namespace ImageProcessor.Processors
/// <returns>
/// The zero-based starting position in the original string where the captured substring was found.
/// </returns>
public override int MatchRegexIndex(string queryString)
public int MatchRegexIndex(string queryString)
{
int index = 0;
@ -151,7 +153,7 @@ namespace ImageProcessor.Processors
/// <returns>
/// The processed image from the current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class.
/// </returns>
public override Image ProcessImage(ImageFactory factory)
public Image ProcessImage(ImageFactory factory)
{
int width = this.DynamicParameter.Size.Width ?? 0;
int height = this.DynamicParameter.Size.Height ?? 0;
@ -164,17 +166,227 @@ namespace ImageProcessor.Processors
int.TryParse(this.Settings["MaxWidth"], out defaultMaxWidth);
int.TryParse(this.Settings["MaxHeight"], out defaultMaxHeight);
if (mode == ResizeMode.Constrain)
return this.ResizeImage(factory, width, height, defaultMaxWidth, defaultMaxHeight, backgroundColor, mode, anchor);
}
#endregion
/// <summary>
/// The resize image.
/// </summary>
/// <param name="factory">
/// The the current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class containing
/// the image to process.
/// </param>
/// <param name="width">
/// The width to resize the image to.
/// </param>
/// <param name="height">
/// The height to resize the image to.
/// </param>
/// <param name="defaultMaxWidth">
/// The default max width to resize the image to.
/// </param>
/// <param name="defaultMaxHeight">
/// The default max height to resize the image to.
/// </param>
/// <param name="backgroundColor">
/// The background color to pad the image with.
/// </param>
/// <param name="resizeMode">
/// The mode with which to resize the image.
/// </param>
/// <param name="anchorPosition">
/// The anchor position to place the image at.
/// </param>
/// <returns>
/// The processed image from the current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class.
/// </returns>
private Image ResizeImage(
ImageFactory factory,
int width,
int height,
int defaultMaxWidth,
int defaultMaxHeight,
Color backgroundColor,
ResizeMode resizeMode = ResizeMode.Pad,
AnchorPosition anchorPosition = AnchorPosition.Center)
{
Bitmap newImage = null;
Image image = factory.Image;
try
{
// Just use the old constrain plugin to handle the resize.
var constrainSettings = new Dictionary<string, string> { { "MaxWidth", defaultMaxWidth.ToString("G") }, { "MaxHeight", defaultMaxHeight.ToString("G") } };
Constrain constrain = new Constrain { DynamicParameter = new Size(width, height), Settings = constrainSettings };
return constrain.ProcessImage(factory);
int sourceWidth = image.Width;
int sourceHeight = image.Height;
int destinationWidth = width;
int destinationHeight = height;
int maxWidth = defaultMaxWidth > 0 ? defaultMaxWidth : int.MaxValue;
int maxHeight = defaultMaxHeight > 0 ? defaultMaxHeight : int.MaxValue;
// Fractional variants for preserving aspect ratio.
double percentHeight = Math.Abs(height / (double)sourceHeight);
double percentWidth = Math.Abs(width / (double)sourceWidth);
int destinationX = 0;
int destinationY = 0;
// Change the destination rectangle coordinates if padding and
// there has been a set width and height.
if (resizeMode == ResizeMode.Pad && width > 0 && height > 0)
{
double ratio;
if (percentHeight < percentWidth)
{
ratio = percentHeight;
destinationX = (int)((width - (sourceWidth * ratio)) / 2);
destinationWidth = (int)Math.Floor(sourceWidth * percentHeight);
}
else
{
ratio = percentWidth;
destinationY = (int)((height - (sourceHeight * ratio)) / 2);
destinationHeight = (int)Math.Floor(sourceHeight * percentWidth);
}
}
// Change the destination rectangle coordinates if cropping and
// there has been a set width and height.
if (resizeMode == ResizeMode.Crop && width > 0 && height > 0)
{
double ratio;
if (percentHeight < percentWidth)
{
ratio = percentWidth;
switch (anchorPosition)
{
case AnchorPosition.Top:
destinationY = 0;
break;
case AnchorPosition.Bottom:
destinationY = (int)(height - (sourceHeight * ratio));
break;
default:
destinationY = (int)((height - (sourceHeight * ratio)) / 2);
break;
}
destinationHeight = (int)Math.Floor(sourceHeight * percentWidth);
}
else
{
ratio = percentHeight;
switch (anchorPosition)
{
case AnchorPosition.Left:
destinationX = 0;
break;
case AnchorPosition.Right:
destinationX = (int)(width - (sourceWidth * ratio));
break;
default:
destinationX = (int)((width - (sourceWidth * ratio)) / 2);
break;
}
destinationWidth = (int)Math.Floor(sourceWidth * percentHeight);
}
}
// Constrain the image to fit the maximum possible height or width.
if (resizeMode == ResizeMode.Max)
{
if (sourceWidth > width || sourceHeight > height)
{
double ratio = Math.Abs(height / width);
double sourceRatio = Math.Abs(sourceHeight / sourceWidth);
if (sourceRatio < ratio)
{
height = 0;
}
else
{
width = 0;
}
}
}
// If height or width is not passed we assume that the standard ratio is to be kept.
if (height == 0)
{
destinationHeight = (int)Math.Floor(sourceHeight * percentWidth);
height = destinationHeight;
}
if (width == 0)
{
destinationWidth = (int)Math.Floor(sourceWidth * percentHeight);
width = destinationWidth;
}
if (width > 0 && height > 0 && width <= maxWidth && height <= maxHeight)
{
// Don't use an object initializer here.
// ReSharper disable once UseObjectOrCollectionInitializer
newImage = new Bitmap(width, height, PixelFormat.Format32bppPArgb);
newImage.Tag = image.Tag;
using (Graphics graphics = Graphics.FromImage(newImage))
{
// We want to use two different blending algorithms for enlargement/shrinking.
// Bicubic is better enlarging for whilst Bilinear is better for shrinking.
// http://www.codinghorror.com/blog/2007/07/better-image-resizing.html
if (image.Width < destinationWidth && image.Height < destinationHeight)
{
// We are making it larger.
graphics.SmoothingMode = SmoothingMode.AntiAlias;
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
graphics.CompositingQuality = CompositingQuality.HighQuality;
}
else
{
// We are making it smaller.
graphics.SmoothingMode = SmoothingMode.None;
graphics.InterpolationMode = InterpolationMode.HighQualityBilinear;
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
graphics.CompositingQuality = CompositingQuality.HighQuality;
}
// An unwanted border appears when using InterpolationMode.HighQualityBicubic to resize the image
// as the algorithm appears to be pulling averaging detail from surFlooring pixels beyond the edge
// of the image. Using the ImageAttributes class to specify that the pixels beyond are simply mirror
// images of the pixels within solves this problem.
using (ImageAttributes wrapMode = new ImageAttributes())
{
wrapMode.SetWrapMode(WrapMode.TileFlipXY);
graphics.Clear(backgroundColor);
Rectangle destRect = new Rectangle(destinationX, destinationY, destinationWidth, destinationHeight);
graphics.DrawImage(image, destRect, 0, 0, sourceWidth, sourceHeight, GraphicsUnit.Pixel, wrapMode);
}
// Reassign the image.
image.Dispose();
image = newImage;
}
}
}
catch
{
if (newImage != null)
{
newImage.Dispose();
}
}
return this.ResizeImage(factory, width, height, defaultMaxWidth, defaultMaxHeight, backgroundColor, mode, anchor);
return image;
}
#endregion
/// <summary>
/// Returns the correct <see cref="Size"/> for the given string.
@ -247,8 +459,8 @@ namespace ImageProcessor.Processors
return ResizeMode.Stretch;
case "crop":
return ResizeMode.Crop;
case "constrain":
return ResizeMode.Constrain;
case "max":
return ResizeMode.Max;
default:
return ResizeMode.Pad;
}

274
src/ImageProcessor/Processors/ResizeBase.cs

@ -1,274 +0,0 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ResizeBase.cs" company="James South">
// Copyright (c) James South.
// Licensed under the Apache License, Version 2.0.
// </copyright>
// <summary>
// The resize base for inheriting resizable methods from.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace ImageProcessor.Processors
{
#region Using
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Text.RegularExpressions;
using ImageProcessor.Imaging;
#endregion
/// <summary>
/// The resize base for inheriting resizable methods from.
/// </summary>
public abstract class ResizeBase : IGraphicsProcessor
{
#region IGraphicsProcessor Members
/// <summary>
/// Gets the regular expression to search strings for.
/// </summary>
public abstract Regex RegexPattern { get; }
/// <summary>
/// Gets or sets DynamicParameter.
/// </summary>
public abstract dynamic DynamicParameter { get; set; }
/// <summary>
/// Gets or sets the order in which this processor is to be used in a chain.
/// </summary>
public abstract int SortOrder { get; protected set; }
/// <summary>
/// Gets or sets any additional settings required by the processor.
/// </summary>
public abstract Dictionary<string, string> Settings { get; set; }
/// <summary>
/// The position in the original string where the first character of the captured substring was found.
/// </summary>
/// <param name="queryString">
/// The query string to search.
/// </param>
/// <returns>
/// The zero-based starting position in the original string where the captured substring was found.
/// </returns>
public abstract int MatchRegexIndex(string queryString);
/// <summary>
/// Processes the image.
/// </summary>
/// <param name="factory">
/// The the current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class containing
/// the image to process.
/// </param>
/// <returns>
/// The processed image from the current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class.
/// </returns>
public abstract Image ProcessImage(ImageFactory factory);
/// <summary>
/// The resize image.
/// </summary>
/// <param name="factory">
/// The the current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class containing
/// the image to process.
/// </param>
/// <param name="width">
/// The width to resize the image to.
/// </param>
/// <param name="height">
/// The height to resize the image to.
/// </param>
/// <param name="defaultMaxWidth">
/// The default max width to resize the image to.
/// </param>
/// <param name="defaultMaxHeight">
/// The default max height to resize the image to.
/// </param>
/// <param name="backgroundColor">
/// The background color to pad the image with.
/// </param>
/// <param name="resizeMode">
/// The mode with which to resize the image.
/// </param>
/// <param name="anchorPosition">
/// The anchor position to place the image at.
/// </param>
/// <returns>
/// The processed image from the current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class.
/// </returns>
protected Image ResizeImage(
ImageFactory factory,
int width,
int height,
int defaultMaxWidth,
int defaultMaxHeight,
Color backgroundColor,
ResizeMode resizeMode = ResizeMode.Pad,
AnchorPosition anchorPosition = AnchorPosition.Center)
{
Bitmap newImage = null;
Image image = factory.Image;
try
{
int sourceWidth = image.Width;
int sourceHeight = image.Height;
int destinationWidth = width;
int destinationHeight = height;
int maxWidth = defaultMaxWidth > 0 ? defaultMaxWidth : int.MaxValue;
int maxHeight = defaultMaxHeight > 0 ? defaultMaxHeight : int.MaxValue;
// Fractional variants for preserving aspect ratio.
double percentHeight = Math.Abs(height / (double)sourceHeight);
double percentWidth = Math.Abs(width / (double)sourceWidth);
int destinationX = 0;
int destinationY = 0;
// Change the destination rectangle coordinates if padding and
// there has been a set width and height.
if (resizeMode == ResizeMode.Pad && width > 0 && height > 0)
{
double ratio;
if (percentHeight < percentWidth)
{
ratio = percentHeight;
destinationX = (int)((width - (sourceWidth * ratio)) / 2);
destinationWidth = (int)Math.Floor(sourceWidth * percentHeight);
}
else
{
ratio = percentWidth;
destinationY = (int)((height - (sourceHeight * ratio)) / 2);
destinationHeight = (int)Math.Floor(sourceHeight * percentWidth);
}
}
// Change the destination rectangle coordinates if cropping and
// there has been a set width and height.
if (resizeMode == ResizeMode.Crop && width > 0 && height > 0)
{
double ratio;
if (percentHeight < percentWidth)
{
ratio = percentWidth;
switch (anchorPosition)
{
case AnchorPosition.Top:
destinationY = 0;
break;
case AnchorPosition.Bottom:
destinationY = (int)(height - (sourceHeight * ratio));
break;
default:
destinationY = (int)((height - (sourceHeight * ratio)) / 2);
break;
}
destinationHeight = (int)Math.Floor(sourceHeight * percentWidth);
}
else
{
ratio = percentHeight;
switch (anchorPosition)
{
case AnchorPosition.Left:
destinationX = 0;
break;
case AnchorPosition.Right:
destinationX = (int)(width - (sourceWidth * ratio));
break;
default:
destinationX = (int)((width - (sourceWidth * ratio)) / 2);
break;
}
destinationWidth = (int)Math.Floor(sourceWidth * percentHeight);
}
}
// If height or width is not passed we assume that the standard ratio is to be kept.
if (height == 0)
{
destinationHeight = (int)Math.Floor(sourceHeight * percentWidth);
height = destinationHeight;
}
if (width == 0)
{
destinationWidth = (int)Math.Floor(sourceWidth * percentHeight);
width = destinationWidth;
}
if (width > 0 && height > 0 && width <= maxWidth && height <= maxHeight)
{
// Don't use an object initializer here.
// ReSharper disable once UseObjectOrCollectionInitializer
newImage = new Bitmap(width, height, PixelFormat.Format32bppPArgb);
newImage.Tag = image.Tag;
using (Graphics graphics = Graphics.FromImage(newImage))
{
// We want to use two different blending algorithms for enlargement/shrinking.
// Bicubic is better enlarging for whilst Bilinear is better for shrinking.
// http://www.codinghorror.com/blog/2007/07/better-image-resizing.html
if (image.Width < destinationWidth && image.Height < destinationHeight)
{
// We are making it larger.
graphics.SmoothingMode = SmoothingMode.AntiAlias;
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
graphics.CompositingQuality = CompositingQuality.HighQuality;
}
else
{
// We are making it smaller.
graphics.SmoothingMode = SmoothingMode.None;
graphics.InterpolationMode = InterpolationMode.HighQualityBilinear;
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
graphics.CompositingQuality = CompositingQuality.HighQuality;
}
// An unwanted border appears when using InterpolationMode.HighQualityBicubic to resize the image
// as the algorithm appears to be pulling averaging detail from surFlooring pixels beyond the edge
// of the image. Using the ImageAttributes class to specify that the pixels beyond are simply mirror
// images of the pixels within solves this problem.
using (ImageAttributes wrapMode = new ImageAttributes())
{
wrapMode.SetWrapMode(WrapMode.TileFlipXY);
graphics.Clear(backgroundColor);
Rectangle destRect = new Rectangle(destinationX, destinationY, destinationWidth, destinationHeight);
graphics.DrawImage(image, destRect, 0, 0, sourceWidth, sourceHeight, GraphicsUnit.Pixel, wrapMode);
}
// Reassign the image.
image.Dispose();
image = newImage;
}
}
}
catch
{
if (newImage != null)
{
newImage.Dispose();
}
}
return image;
}
#endregion
}
}

3
src/TestWebsites/NET4/Content/responsive-legacy.min.css

File diff suppressed because one or more lines are too long

3
src/TestWebsites/NET4/Content/responsive.min.css

File diff suppressed because one or more lines are too long

1
src/TestWebsites/NET4/Content/responsive.min.css.REMOVED.git-id

@ -0,0 +1 @@
e0fbb23ec0c6b4a6980ac29f0c71b82ff900eebc

30
src/TestWebsites/NET4/Controllers/HomeController.cs

@ -12,9 +12,39 @@ namespace Test.Controllers
// GET: /Home/
public ActionResult Index()
{
return this.View();
}
public ActionResult Png()
{
return this.View();
}
public ActionResult Png8()
{
return this.View();
}
public ActionResult Gif()
{
return this.View();
}
public ActionResult Bmp()
{
return View();
}
public ActionResult Tiff()
{
return View();
}
public ActionResult External()
{
return this.View();
}
}
}

19
src/TestWebsites/NET4/Test_Website.csproj

@ -84,7 +84,6 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Content\responsive-legacy.min.css" />
<Content Include="Content\responsive.min.css" />
<Content Include="Global.asax" />
<Content Include="Images\1182076_e8c402e938_z.jpg" />
@ -155,6 +154,24 @@
<ItemGroup>
<Content Include="config\imageprocessor\security.config" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Home\Bmp.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Home\External.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Home\Gif.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Home\Png.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Home\Png8.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Home\Tiff.cshtml" />
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>

100
src/TestWebsites/NET4/Views/Home/Bmp.cshtml

@ -0,0 +1,100 @@
@{
ViewBag.Title = "Bmp";
}
<article>
<h1>Bmp</h1>
<section>
<div class="row">
<div class="col-s-6">
<h2>Resized</h2>
<img src="/images/Penguins.bmp?width=300" />
</div>
<div class="col-s-6">
<h2>Cropped </h2>
<img src="/images/Penguins.bmp?crop=0-0-300-225" />
</div>
</div>
</section>
<section>
<h2>Filter</h2>
<div class="row">
<div class="col-s-6">
<h3>blackwhite</h3>
<img src="/images/Penguins.bmp?width=300&filter=blackwhite" />
</div>
<div class="col-s-6">
<h3>comic</h3>
<img src="/images/Penguins.bmp?width=300&filter=comic" />
</div>
</div>
<div class="row">
<div class="col-s-6">
<h3>lomograph</h3>
<img src="/images/Penguins.bmp?width=300&filter=lomograph" />
</div>
<div class="col-s-6">
<h3>greyscale</h3>
<img src="/images/Penguins.bmp?width=300&filter=greyscale" />
</div>
</div>
<div class="row">
<div class="col-s-6">
<h3>polaroid</h3>
<img src="/images/Penguins.bmp?width=300&filter=polaroid" />
</div>
<div class="col-s-6">
<h3>sepia</h3>
<img src="/images/Penguins.bmp?width=300&filter=sepia" />
</div>
</div>
<div class="row">
<div class="col-s-6">
<h3>gotham</h3>
<img src="/images/Penguins.bmp?width=300&filter=gotham" />
</div>
<div class="col-s-6">
<h3>hisatch</h3>
<img src="/images/Penguins.bmp?width=300&filter=hisatch" />
</div>
</div>
<div class="row">
<div class="col-s-6">
<h3>losatch</h3>
<img src="/images/Penguins.bmp?width=300&filter=losatch" />
</div>
</div>
</section>
<section>
<div class="row">
<div class="col-s-6">
<h2>Watermark</h2>
<img src="/images/Penguins.bmp?width=300&watermark=text-test|color-fff|size-48|style-italic|opacity-100|position-100-100|shadow-true|font-arial" />
</div>
<div class="col-s-6">
<h2>Format</h2>
<img src="/images/Penguins.bmp?width=300&format=jpg" />
</div>
</div>
</section>
<section>
<div class="row">
<div class="col-s-6">
<h2>Rotate</h2>
<img src="/images/Penguins.bmp?width=300&rotate=angle-54|bgcolor-fff" />
</div>
<div class="col-s-6">
<h2>Quality</h2>
<img src="/images/Penguins.bmp?width=300&quality=5" />
</div>
</div>
</section>
<section>
<div class="row">
<div class="col-s-6">
<h2>Alpha</h2>
<img src="/images/Penguins.bmp?width=300&alpha=50" />
</div>
</div>
</section>
</article>

14
src/TestWebsites/NET4/Views/Home/External.cshtml

@ -0,0 +1,14 @@
@{
ViewBag.Title = "External";
}
<h1>External</h1>
<section>
<div class="row">
<div class="col-s-6">
<img src="/remote.axd?http://images.mymovies.net/images/film/cin/500x377/fid11707.jpg?width=400" />
</div>
<div class="col-s-6">
<img src="/remote.axd?http://maps.googleapis.com/maps/api/staticmap?center=Albany,+NY&zoom=13&scale=false&size=800x500&maptype=roadmap&sensor=false&format=png&visual_refresh=true?width=400" />
</div>
</div>
</section>

99
src/TestWebsites/NET4/Views/Home/Gif.cshtml

@ -0,0 +1,99 @@
@{
ViewBag.Title = "Gif";
}
<article>
<h1>Gif</h1>
<section>
<div class="row">
<div class="col-s-6">
<h2>Resized</h2>
<img src="/images/Penguins.gif?width=300" />
</div>
<div class="col-s-6">
<h2>Cropped </h2>
<img src="/images/Penguins.gif?crop=0-0-300-225" />
</div>
</div>
</section>
<section>
<h2>Filter</h2>
<div class="row">
<div class="col-s-6">
<h3>blackwhite</h3>
<img src="/images/Penguins.gif?width=300&filter=blackwhite" />
</div>
<div class="col-s-6">
<h3>comic</h3>
<img src="/images/Penguins.gif?width=300&filter=comic" />
</div>
</div>
<div class="row">
<div class="col-s-6">
<h3>lomograph</h3>
<img src="/images/Penguins.gif?width=300&filter=lomograph" />
</div>
<div class="col-s-6">
<h3>greyscale</h3>
<img src="/images/Penguins.gif?width=300&filter=greyscale" />
</div>
</div>
<div class="row">
<div class="col-s-6">
<h3>polaroid</h3>
<img src="/images/Penguins.gif?width=300&filter=polaroid" />
</div>
<div class="col-s-6">
<h3>sepia</h3>
<img src="/images/Penguins.gif?width=300&filter=sepia" />
</div>
</div>
<div class="row">
<div class="col-s-6">
<h3>gotham</h3>
<img src="/images/Penguins.gif?width=300&filter=gotham" />
</div>
<div class="col-s-6">
<h3>hisatch</h3>
<img src="/images/Penguins.gif?width=300&filter=hisatch" />
</div>
</div>
<div class="row">
<div class="col-s-6">
<h3>losatch</h3>
<img src="/images/Penguins.gif?width=300&filter=losatch" />
</div>
</div>
</section>
<section>
<div class="row">
<div class="col-s-6">
<h2>Watermark</h2>
<img src="/images/Penguins.gif?width=300&watermark=text-test|color-fff|size-48|style-italic|opacity-100|position-100-100|shadow-true|font-arial" />
</div>
<div class="col-s-6">
<h2>Format</h2>
<img src="/images/Penguins.gif?width=300&format=png" />
</div>
</div>
</section>
<section>
<div class="row">
<div class="col-s-6">
<h2>Rotate</h2>
<img src="/images/Penguins.gif?width=300&rotate=angle-54|bgcolor-fff" />
</div>
<div class="col-s-6">
<h2>Quality</h2>
<img src="/images/Penguins.gif?width=300&quality=5" />
</div>
</div>
</section>
<section>
<div class="row">
<div class="col-s-6">
<h2>Alpha</h2>
<img src="/images/Penguins.gif?width=300&alpha=50" />
</div>
</div>
</section>
</article>

564
src/TestWebsites/NET4/Views/Home/Index.cshtml

@ -5,594 +5,186 @@
<h1>Jpg</h1>
<section>
<div class="row">
<div class="column-6">
<div class="col-s-6">
<h2>Resized</h2>
<img src="/images/Penguins.jpg?width=300" />
<h3>Foreign language test.</h3>
<img src="/images/udendørs.jpg?width=300" />
<img src="/images/udendørs.jpg?preset=a&filter=comic" />
</div>
<div class="column-6">
<div class="col-s-6">
<h2>Cropped </h2>
<img src="/images/Penguins.jpg?crop=0-0-300-225" />
</div>
</div>
</section>
<section>
<h2>Filter</h2>
<div class="row">
<div class="column-6">
<h3>blackwhite</h3>
<img src="/images/Penguins.jpg?width=300&filter=blackwhite" />
</div>
<div class="column-6">
<h3>comic</h3>
<img src="/images/Penguins.jpg?width=300&filter=comic" />
</div>
</div>
<div class="row">
<div class="column-6">
<h3>lomograph</h3>
<img src="/images/Penguins.jpg?width=300&filter=lomograph" />
</div>
<div class="column-6">
<h3>greyscale</h3>
<img src="/images/Penguins.jpg?width=300&filter=greyscale" />
</div>
</div>
<div class="row">
<div class="column-6">
<h3>polaroid</h3>
<img src="/images/Penguins.jpg?width=300&filter=polaroid" />
</div>
<div class="column-6">
<h3>sepia</h3>
<img src="/images/Penguins.jpg?width=300&filter=sepia" />
</div>
</div>
<div class="row">
<div class="column-6">
<h3>gotham</h3>
<img src="/images/Penguins.jpg?width=300&filter=gotham" />
</div>
<div class="column-6">
<h3>hisatch</h3>
<img src="/images/Penguins.jpg?width=300&filter=hisatch" />
</div>
</div>
<div class="row">
<div class="column-6">
<h3>losatch</h3>
<img src="/images/Penguins.jpg?width=300&filter=losatch" />
</div>
</div>
</section>
<section>
<div class="row">
<div class="column-6">
<h2>Watermark</h2>
<img src="/images/Penguins.jpg?width=300&watermark=text-test|color-fff|size-48|style-italic|opacity-100|position-100-100|shadow-true|font-arial" />
</div>
<div class="column-6">
<h2>Format</h2>
<img src="/images/Penguins.jpg?width=300&format=gif" />
</div>
</div>
</section>
<section>
<div class="row">
<div class="column-6">
<h2>Rotate</h2>
<img src="/images/Penguins.jpg?width=300&rotate=angle-54|bgcolor-fff" />
</div>
<div class="column-6">
<h2>Quality</h2>
<img src="/images/Penguins.jpg?width=300&quality=5" />
</div>
</div>
</section>
<section>
<div class="row">
<div class="column-6">
<h2>Alpha</h2>
<img src="/images/Penguins.jpg?width=300&format=png&alpha=50" />
</div>
<div class="column-6">
<h2>Remote</h2>
<img src="/remote.axd?http://images.mymovies.net/images/film/cin/500x377/fid11707.jpg?width=300" />
@*<img src="/remote.axd?http://www.theworldeffect.com/images/6a00e54fa8abf78833011570697305970b-800wi.jpg?width=300" />*@
<img src="/remote.axd?http://maps.googleapis.com/maps/api/staticmap?center=Albany,+NY&zoom=13&scale=false&size=600x300&maptype=roadmap&sensor=false&format=png&visual_refresh=true?width=300" />
</div>
</div>
</section>
<section>
<div class="row">
<div class="column-6">
<h2>Flip - horizontal</h2>
<img src="/images/Penguins.jpg?width=300&flip=horizontal" />
</div>
<div class="column-6">
<h2>Flip - vertical</h2>
<img src="/images/Penguins.jpg?width=300&flip=vertical" />
</div>
</div>
</section>
</article>
<article>
<h1>Gif</h1>
<section>
<div class="row">
<div class="column-6">
<h2>Resized</h2>
<img src="/images/Penguins.gif?width=300" />
</div>
<div class="column-6">
<h2>Cropped </h2>
<img src="/images/Penguins.gif?crop=0-0-300-225" />
</div>
</div>
</section>
<section>
<h2>Filter</h2>
<div class="row">
<div class="column-6">
<h3>blackwhite</h3>
<img src="/images/Penguins.gif?width=300&filter=blackwhite" />
</div>
<div class="column-6">
<h3>comic</h3>
<img src="/images/Penguins.gif?width=300&filter=comic" />
</div>
</div>
<div class="row">
<div class="column-6">
<h3>lomograph</h3>
<img src="/images/Penguins.gif?width=300&filter=lomograph" />
</div>
<div class="column-6">
<h3>greyscale</h3>
<img src="/images/Penguins.gif?width=300&filter=greyscale" />
</div>
</div>
<div class="row">
<div class="column-6">
<h3>polaroid</h3>
<img src="/images/Penguins.gif?width=300&filter=polaroid" />
</div>
<div class="column-6">
<h3>sepia</h3>
<img src="/images/Penguins.gif?width=300&filter=sepia" />
</div>
</div>
<div class="row">
<div class="column-6">
<h3>gotham</h3>
<img src="/images/Penguins.gif?width=300&filter=gotham" />
</div>
<div class="column-6">
<h3>hisatch</h3>
<img src="/images/Penguins.gif?width=300&filter=hisatch" />
</div>
</div>
<div class="row">
<div class="column-6">
<h3>losatch</h3>
<img src="/images/Penguins.gif?width=300&filter=losatch" />
</div>
</div>
</section>
<section>
<div class="row">
<div class="column-6">
<h2>Watermark</h2>
<img src="/images/Penguins.gif?width=300&watermark=text-test|color-fff|size-48|style-italic|opacity-100|position-100-100|shadow-true|font-arial" />
</div>
<div class="column-6">
<h2>Format</h2>
<img src="/images/Penguins.gif?width=300&format=png" />
</div>
</div>
</section>
<section>
<div class="row">
<div class="column-6">
<h2>Rotate</h2>
<img src="/images/Penguins.gif?width=300&rotate=angle-54|bgcolor-fff" />
</div>
<div class="column-6">
<h2>Quality</h2>
<img src="/images/Penguins.gif?width=300&quality=5" />
</div>
</div>
</section>
<section>
<div class="row">
<div class="column-6">
<h2>Alpha</h2>
<img src="/images/Penguins.gif?width=300&alpha=50" />
</div>
</div>
</section>
</article>
<article>
<h1>Png</h1>
<section>
<div class="row">
<div class="column-6">
<h2>Resized</h2>
<img src="/images/Penguins.png?width=300" />
</div>
<div class="column-6">
<h2>Cropped </h2>
<img src="/images/Penguins.png?crop=0-0-300-225" />
</div>
</div>
</section>
<section>
<h2>Filter</h2>
<div class="row">
<div class="column-6">
<h3>blackwhite</h3>
<img src="/images/Penguins.png?width=300&filter=blackwhite" />
</div>
<div class="column-6">
<h3>comic</h3>
<img src="/images/Penguins.png?width=300&filter=comic" />
</div>
</div>
<div class="row">
<div class="column-6">
<h3>lomograph</h3>
<img src="/images/Penguins.png?width=300&filter=lomograph" />
</div>
<div class="column-6">
<h3>greyscale</h3>
<img src="/images/Penguins.png?width=300&filter=greyscale" />
</div>
</div>
<div class="row">
<div class="column-6">
<h3>polaroid</h3>
<img src="/images/Penguins.png?width=300&filter=polaroid" />
</div>
<div class="column-6">
<h3>sepia</h3>
<img src="/images/Penguins.png?width=300&filter=sepia" />
</div>
</div>
<div class="row">
<div class="column-6">
<h3>gotham</h3>
<img src="/images/Penguins.png?width=300&filter=gotham" />
</div>
<div class="column-6">
<h3>hisatch</h3>
<img src="/images/Penguins.png?width=300&filter=hisatch" />
<h2>Reside Pad</h2>
<div class="col-s-4">
<img src="/images/Penguins.jpg?width=300&height=500" />
</div>
</div>
<div class="row">
<div class="column-6">
<h3>losatch</h3>
<img src="/images/Penguins.png?width=300&filter=losatch" />
<div class="col-s-8">
<img src="/images/udendørs.jpg?width=600&height=250" />
</div>
</div>
</section>
<section>
<div class="row">
<div class="column-6">
<h2>Watermark</h2>
<img src="/images/Penguins.png?width=300&watermark=text-test|color-fff|size-48|style-italic|opacity-100|position-100-100|shadow-true|font-arial" />
<h2>Resize Crop</h2>
<div class="col-s-4">
<img src="/images/Penguins.jpg?width=300&height=500&mode=crop" />
</div>
<div class="column-6">
<h2>Format</h2>
<img src="/images/Penguins.png?width=300&format=bmp" />
<div class="col-s-8">
<img src="/images/udendørs.jpg?width=600&height=250&mode=crop" />
</div>
</div>
</section>
<section>
<div class="row">
<div class="column-6">
<h2>Rotate</h2>
<img src="/images/Penguins.png?width=300&rotate=angle-54|bgcolor-fff" />
</div>
<div class="column-6">
<h2>Quality</h2>
<img src="/images/Penguins.png?width=300&quality=5" />
<h2>Resize Max</h2>
<div class="col-s-4">
<img src="/images/Penguins.jpg?width=300&height=500&mode=max" />
</div>
</div>
</section>
<section>
<div class="row">
<div class="column-6">
<h2>Alpha</h2>
<img src="/images/Penguins.png?width=300&alpha=50" />
<div class="col-s-8">
<img src="/images/udendørs.jpg?width=600&height=250&mode=max" />
</div>
</div>
</section>
</article>
<article>
<h1>Png8</h1>
<section>
<section>
<div class="row">
<div class="column-6">
<h2>Resized</h2>
<img src="/images/Penguins-8.png?width=300" />
<h2>Resize Stretch</h2>
<div class="col-s-4">
<img src="/images/Penguins.jpg?width=300&height=500&mode=stretch" />
</div>
<div class="column-6">
<h2>Cropped </h2>
<img src="/images/Penguins-8.png?crop=0-0-300-225" />
<div class="col-s-8">
<img src="/images/udendørs.jpg?width=600&height=250&mode=stretch" />
</div>
</div>
</section>
<section>
<h2>Filter</h2>
<div class="row">
<div class="column-6">
<div class="col-s-6">
<h3>blackwhite</h3>
<img src="/images/Penguins-8.png?width=300&filter=blackwhite" />
<img src="/images/Penguins.jpg?width=300&filter=blackwhite" />
</div>
<div class="column-6">
<div class="col-s-6">
<h3>comic</h3>
<img src="/images/Penguins-8.png?width=300&filter=comic" />
<img src="/images/Penguins.jpg?width=300&filter=comic" />
</div>
</div>
<div class="row">
<div class="column-6">
<div class="col-s-6">
<h3>lomograph</h3>
<img src="/images/Penguins-8.png?width=300&filter=lomograph" />
<img src="/images/Penguins.jpg?width=300&filter=lomograph" />
</div>
<div class="column-6">
<div class="col-s-6">
<h3>greyscale</h3>
<img src="/images/Penguins-8.png?width=300&filter=greyscale" />
<img src="/images/Penguins.jpg?width=300&filter=greyscale" />
</div>
</div>
<div class="row">
<div class="column-6">
<div class="col-s-6">
<h3>polaroid</h3>
<img src="/images/Penguins-8.png?width=300&filter=polaroid" />
<img src="/images/Penguins.jpg?width=300&filter=polaroid" />
</div>
<div class="column-6">
<div class="col-s-6">
<h3>sepia</h3>
<img src="/images/Penguins-8.png?width=300&filter=sepia" />
<img src="/images/Penguins.jpg?width=300&filter=sepia" />
</div>
</div>
<div class="row">
<div class="column-6">
<div class="col-s-6">
<h3>gotham</h3>
<img src="/images/Penguins-8.png?width=300&filter=gotham" />
<img src="/images/Penguins.jpg?width=300&filter=gotham" />
</div>
<div class="column-6">
<div class="col-s-6">
<h3>hisatch</h3>
<img src="/images/Penguins-8.png?width=300&filter=hisatch" />
<img src="/images/Penguins.jpg?width=300&filter=hisatch" />
</div>
</div>
<div class="row">
<div class="column-6">
<div class="col-s-6">
<h3>losatch</h3>
<img src="/images/Penguins-8.png?width=300&filter=losatch" />
<img src="/images/Penguins.jpg?width=300&filter=losatch" />
</div>
</div>
</section>
<section>
<div class="row">
<div class="column-6">
<div class="col-s-6">
<h2>Watermark</h2>
<img src="/images/Penguins-8.png?width=300&watermark=text-test|color-fff|size-48|style-italic|opacity-100|position-100-100|shadow-true|font-arial" />
<img src="/images/Penguins.jpg?width=300&watermark=text-This+is+a+long+body+of+copy+that+should+wrap|color-fff|size-24|style-italic|opacity-100|position-100-100|shadow-true|font-arial" />
</div>
<div class="column-6">
<div class="col-s-6">
<h2>Format</h2>
<img src="/images/Penguins-8.png?width=300&format=bmp" />
<img src="/images/Penguins.jpg?width=300&format=gif" />
</div>
</div>
</section>
<section>
<div class="row">
<div class="column-6">
<div class="col-s-6">
<h2>Rotate</h2>
<img src="/images/Penguins-8.png?width=300&rotate=angle-54|bgcolor-fff" />
<img src="/images/Penguins.jpg?width=300&rotate=angle-54|bgcolor-fff" />
</div>
<div class="column-6">
<div class="col-s-6">
<h2>Quality</h2>
<img src="/images/Penguins-8.png?width=300&quality=5" />
<img src="/images/Penguins.jpg?width=300&quality=5" />
</div>
</div>
</section>
<section>
<div class="row">
<div class="column-6">
<div class="col-s-6">
<h2>Alpha</h2>
<img src="/images/Penguins-8.png?width=300&alpha=50" />
</div>
</div>
</section>
</article>
<article>
<h1>Bmp</h1>
<section>
<div class="row">
<div class="column-6">
<h2>Resized</h2>
<img src="/images/Penguins.bmp?width=300" />
</div>
<div class="column-6">
<h2>Cropped </h2>
<img src="/images/Penguins.bmp?crop=0-0-300-225" />
</div>
</div>
</section>
<section>
<h2>Filter</h2>
<div class="row">
<div class="column-6">
<h3>blackwhite</h3>
<img src="/images/Penguins.bmp?width=300&filter=blackwhite" />
</div>
<div class="column-6">
<h3>comic</h3>
<img src="/images/Penguins.bmp?width=300&filter=comic" />
</div>
</div>
<div class="row">
<div class="column-6">
<h3>lomograph</h3>
<img src="/images/Penguins.bmp?width=300&filter=lomograph" />
</div>
<div class="column-6">
<h3>greyscale</h3>
<img src="/images/Penguins.bmp?width=300&filter=greyscale" />
</div>
</div>
<div class="row">
<div class="column-6">
<h3>polaroid</h3>
<img src="/images/Penguins.bmp?width=300&filter=polaroid" />
</div>
<div class="column-6">
<h3>sepia</h3>
<img src="/images/Penguins.bmp?width=300&filter=sepia" />
</div>
</div>
<div class="row">
<div class="column-6">
<h3>gotham</h3>
<img src="/images/Penguins.bmp?width=300&filter=gotham" />
</div>
<div class="column-6">
<h3>hisatch</h3>
<img src="/images/Penguins.bmp?width=300&filter=hisatch" />
</div>
</div>
<div class="row">
<div class="column-6">
<h3>losatch</h3>
<img src="/images/Penguins.bmp?width=300&filter=losatch" />
</div>
</div>
</section>
<section>
<div class="row">
<div class="column-6">
<h2>Watermark</h2>
<img src="/images/Penguins.bmp?width=300&watermark=text-test|color-fff|size-48|style-italic|opacity-100|position-100-100|shadow-true|font-arial" />
<img src="/images/Penguins.jpg?width=300&format=png&alpha=50" />
</div>
<div class="column-6">
<h2>Format</h2>
<img src="/images/Penguins.bmp?width=300&format=jpg" />
<div class="col-s-6">
<h2>Remote</h2>
</div>
</div>
</section>
<section>
<div class="row">
<div class="column-6">
<h2>Rotate</h2>
<img src="/images/Penguins.bmp?width=300&rotate=angle-54|bgcolor-fff" />
</div>
<div class="column-6">
<h2>Quality</h2>
<img src="/images/Penguins.bmp?width=300&quality=5" />
<div class="col-s-6">
<h2>Flip - horizontal</h2>
<img src="/images/Penguins.jpg?width=300&flip=horizontal" />
</div>
</div>
</section>
<section>
<div class="row">
<div class="column-6">
<h2>Alpha</h2>
<img src="/images/Penguins.bmp?width=300&alpha=50" />
<div class="col-s-6">
<h2>Flip - vertical</h2>
<img src="/images/Penguins.jpg?width=300&flip=vertical" />
</div>
</div>
</section>
</article>
<article>
<h1>Tiff</h1>
<section>
<h1>Color Profiles</h1>
@* <section>
<div class="row">
<div class="column-6">
<h2>Resized</h2>
<img src="/images/Penguins.tif?width=300" />
<div class="col-s-6">
<h2>CMYK original jpg</h2>
<img src="/images/cmyk.jpg?" width="400" />
</div>
<div class="column-6">
<h2>Cropped </h2>
<img src="/images/Penguins.tif?crop=0-0-300-225" />
<div class="col-s-6">
<h2>sRGB original jpg</h2>
<img src="/images/srgb.jpg?" width="400" />
</div>
</div>
</section>
</section>*@
<section>
<h2>Filter</h2>
<div class="row">
<div class="column-6">
<h3>blackwhite</h3>
<img src="/images/Penguins.tif?width=300&filter=blackwhite" />
</div>
<div class="column-6">
<h3>comic</h3>
<img src="/images/Penguins.tif?width=300&filter=comic" />
</div>
</div>
<div class="row">
<div class="column-6">
<h3>lomograph</h3>
<img src="/images/Penguins.tif?width=300&filter=lomograph" />
<div class="col-s-6">
<h2>CMYK resized jpg</h2>
<img src="/images/cmyk.jpg?width=400" />
</div>
<div class="column-6">
<h3>greyscale</h3>
<img src="/images/Penguins.tif?width=300&filter=greyscale" />
</div>
</div>
<div class="row">
<div class="column-6">
<h3>polaroid</h3>
<img src="/images/Penguins.tif?width=300&filter=polaroid" />
</div>
<div class="column-6">
<h3>sepia</h3>
<img src="/images/Penguins.tif?width=300&filter=sepia" />
</div>
</div>
<div class="row">
<div class="column-6">
<h3>gotham</h3>
<img src="/images/Penguins.tif?width=300&filter=gotham" />
</div>
<div class="column-6">
<h3>hisatch</h3>
<img src="/images/Penguins.tif?width=300&filter=hisatch" />
</div>
</div>
<div class="row">
<div class="column-6">
<h3>losatch</h3>
<img src="/images/Penguins.tif?width=300&filter=losatch" />
</div>
</div>
</section>
<section>
<div class="row">
<div class="column-6">
<h2>Watermark</h2>
<img src="/images/Penguins.tif?width=300&watermark=text-test|color-fff|size-48|style-italic|opacity-100|position-100-100|shadow-true|font-arial" />
</div>
<div class="column-6">
<h2>Format</h2>
<img src="/images/Penguins.tif?width=300&format=bmp" />
</div>
</div>
</section>
<section>
<div class="row">
<div class="column-6">
<h2>Rotate</h2>
<img src="/images/Penguins.tif?width=300&rotate=angle-54|bgcolor-fff" />
</div>
<div class="column-6">
<h2>Quality</h2>
<img src="/images/Penguins.tif?width=300&quality=5" />
</div>
</div>
</section>
<section>
<div class="row">
<div class="column-6">
<h2>Alpha</h2>
<img src="/images/Penguins.tif?width=300&alpha=50" />
<div class="col-s-6">
<h2>sRGB resized jpg</h2>
<img src="/images/srgb.jpg?width=400" />
</div>
</div>
</section>

99
src/TestWebsites/NET4/Views/Home/Png.cshtml

@ -0,0 +1,99 @@
@{
ViewBag.Title = "Png";
}
<article>
<h1>Png</h1>
<section>
<div class="row">
<div class="col-s-6">
<h2>Resized</h2>
<img src="/images/Penguins.png?width=300" />
</div>
<div class="col-s-6">
<h2>Cropped </h2>
<img src="/images/Penguins.png?crop=0-0-300-225" />
</div>
</div>
</section>
<section>
<h2>Filter</h2>
<div class="row">
<div class="col-s-6">
<h3>blackwhite</h3>
<img src="/images/Penguins.png?width=300&filter=blackwhite" />
</div>
<div class="col-s-6">
<h3>comic</h3>
<img src="/images/Penguins.png?width=300&filter=comic" />
</div>
</div>
<div class="row">
<div class="col-s-6">
<h3>lomograph</h3>
<img src="/images/Penguins.png?width=300&filter=lomograph" />
</div>
<div class="col-s-6">
<h3>greyscale</h3>
<img src="/images/Penguins.png?width=300&filter=greyscale" />
</div>
</div>
<div class="row">
<div class="col-s-6">
<h3>polaroid</h3>
<img src="/images/Penguins.png?width=300&filter=polaroid" />
</div>
<div class="col-s-6">
<h3>sepia</h3>
<img src="/images/Penguins.png?width=300&filter=sepia" />
</div>
</div>
<div class="row">
<div class="col-s-6">
<h3>gotham</h3>
<img src="/images/Penguins.png?width=300&filter=gotham" />
</div>
<div class="col-s-6">
<h3>hisatch</h3>
<img src="/images/Penguins.png?width=300&filter=hisatch" />
</div>
</div>
<div class="row">
<div class="col-s-6">
<h3>losatch</h3>
<img src="/images/Penguins.png?width=300&filter=losatch" />
</div>
</div>
</section>
<section>
<div class="row">
<div class="col-s-6">
<h2>Watermark</h2>
<img src="/images/Penguins.png?width=300&watermark=text-test|color-fff|size-48|style-italic|opacity-100|position-100-100|shadow-true|font-arial" />
</div>
<div class="col-s-6">
<h2>Format</h2>
<img src="/images/Penguins.png?width=300&format=bmp" />
</div>
</div>
</section>
<section>
<div class="row">
<div class="col-s-6">
<h2>Rotate</h2>
<img src="/images/Penguins.png?width=300&rotate=angle-54|bgcolor-fff" />
</div>
<div class="col-s-6">
<h2>Quality</h2>
<img src="/images/Penguins.png?width=300&quality=5" />
</div>
</div>
</section>
<section>
<div class="row">
<div class="col-s-6">
<h2>Alpha</h2>
<img src="/images/Penguins.png?width=300&alpha=50" />
</div>
</div>
</section>
</article>

100
src/TestWebsites/NET4/Views/Home/Png8.cshtml

@ -0,0 +1,100 @@
@{
ViewBag.Title = "Png8";
}
<article>
<h1>Png8</h1>
<section>
<div class="row">
<div class="col-s-6">
<h2>Resized</h2>
<img src="/images/Penguins-8.png?width=300" />
</div>
<div class="col-s-6">
<h2>Cropped </h2>
<img src="/images/Penguins-8.png?crop=0-0-300-225" />
</div>
</div>
</section>
<section>
<h2>Filter</h2>
<div class="row">
<div class="col-s-6">
<h3>blackwhite</h3>
<img src="/images/Penguins-8.png?width=300&filter=blackwhite" />
</div>
<div class="col-s-6">
<h3>comic</h3>
<img src="/images/Penguins-8.png?width=300&filter=comic" />
</div>
</div>
<div class="row">
<div class="col-s-6">
<h3>lomograph</h3>
<img src="/images/Penguins-8.png?width=300&filter=lomograph" />
</div>
<div class="col-s-6">
<h3>greyscale</h3>
<img src="/images/Penguins-8.png?width=300&filter=greyscale" />
</div>
</div>
<div class="row">
<div class="col-s-6">
<h3>polaroid</h3>
<img src="/images/Penguins-8.png?width=300&filter=polaroid" />
</div>
<div class="col-s-6">
<h3>sepia</h3>
<img src="/images/Penguins-8.png?width=300&filter=sepia" />
</div>
</div>
<div class="row">
<div class="col-s-6">
<h3>gotham</h3>
<img src="/images/Penguins-8.png?width=300&filter=gotham" />
</div>
<div class="col-s-6">
<h3>hisatch</h3>
<img src="/images/Penguins-8.png?width=300&filter=hisatch" />
</div>
</div>
<div class="row">
<div class="col-s-6">
<h3>losatch</h3>
<img src="/images/Penguins-8.png?width=300&filter=losatch" />
</div>
</div>
</section>
<section>
<div class="row">
<div class="col-s-6">
<h2>Watermark</h2>
<img src="/images/Penguins-8.png?width=300&watermark=text-test|color-fff|size-48|style-italic|opacity-100|position-100-100|shadow-true|font-arial" />
</div>
<div class="col-s-6">
<h2>Format</h2>
<img src="/images/Penguins-8.png?width=300&format=bmp" />
</div>
</div>
</section>
<section>
<div class="row">
<div class="col-s-6">
<h2>Rotate</h2>
<img src="/images/Penguins-8.png?width=300&rotate=angle-54|bgcolor-fff" />
</div>
<div class="col-s-6">
<h2>Quality</h2>
<img src="/images/Penguins-8.png?width=300&quality=5" />
</div>
</div>
</section>
<section>
<div class="row">
<div class="col-s-6">
<h2>Alpha</h2>
<img src="/images/Penguins-8.png?width=300&alpha=50" />
</div>
</div>
</section>
</article>

99
src/TestWebsites/NET4/Views/Home/Tiff.cshtml

@ -0,0 +1,99 @@
@{
ViewBag.Title = "Tiff";
}
<article>
<h1>Tiff</h1>
<section>
<div class="row">
<div class="col-s-6">
<h2>Resized</h2>
<img src="/images/Penguins.tif?width=300" />
</div>
<div class="col-s-6">
<h2>Cropped </h2>
<img src="/images/Penguins.tif?crop=0-0-300-225" />
</div>
</div>
</section>
<section>
<h2>Filter</h2>
<div class="row">
<div class="col-s-6">
<h3>blackwhite</h3>
<img src="/images/Penguins.tif?width=300&filter=blackwhite" />
</div>
<div class="col-s-6">
<h3>comic</h3>
<img src="/images/Penguins.tif?width=300&filter=comic" />
</div>
</div>
<div class="row">
<div class="col-s-6">
<h3>lomograph</h3>
<img src="/images/Penguins.tif?width=300&filter=lomograph" />
</div>
<div class="col-s-6">
<h3>greyscale</h3>
<img src="/images/Penguins.tif?width=300&filter=greyscale" />
</div>
</div>
<div class="row">
<div class="col-s-6">
<h3>polaroid</h3>
<img src="/images/Penguins.tif?width=300&filter=polaroid" />
</div>
<div class="col-s-6">
<h3>sepia</h3>
<img src="/images/Penguins.tif?width=300&filter=sepia" />
</div>
</div>
<div class="row">
<div class="col-s-6">
<h3>gotham</h3>
<img src="/images/Penguins.tif?width=300&filter=gotham" />
</div>
<div class="col-s-6">
<h3>hisatch</h3>
<img src="/images/Penguins.tif?width=300&filter=hisatch" />
</div>
</div>
<div class="row">
<div class="col-s-6">
<h3>losatch</h3>
<img src="/images/Penguins.tif?width=300&filter=losatch" />
</div>
</div>
</section>
<section>
<div class="row">
<div class="col-s-6">
<h2>Watermark</h2>
<img src="/images/Penguins.tif?width=300&watermark=text-test|color-fff|size-48|style-italic|opacity-100|position-100-100|shadow-true|font-arial" />
</div>
<div class="col-s-6">
<h2>Format</h2>
<img src="/images/Penguins.tif?width=300&format=bmp" />
</div>
</div>
</section>
<section>
<div class="row">
<div class="col-s-6">
<h2>Rotate</h2>
<img src="/images/Penguins.tif?width=300&rotate=angle-54|bgcolor-fff" />
</div>
<div class="col-s-6">
<h2>Quality</h2>
<img src="/images/Penguins.tif?width=300&quality=5" />
</div>
</div>
</section>
<section>
<div class="row">
<div class="col-s-6">
<h2>Alpha</h2>
<img src="/images/Penguins.tif?width=300&alpha=50" />
</div>
</div>
</section>
</article>

41
src/TestWebsites/NET4/Views/Shared/_Layout.cshtml

@ -3,17 +3,38 @@
<head>
<meta charset="utf-8" />
<title>@ViewBag.Title</title>
<link href="@Url.Content("~/Content/responsive.min.css")" rel="stylesheet" type="text/css" media="all and (min-width: 1em)" />
<!--[if lt IE 9 &!(IEMobile)]>
<link href="@Url.Content("~/Content/responsive-legacy.min.css")" rel="stylesheet" type="text/css" />
<![endif]-->
<link href="@Url.Content("~/Content/responsive.min.css")" rel="stylesheet" type="text/css" />
<style type="text/css">
nav[role="navigation"] ul {
padding: 0;
}
nav[role="navigation"] li {
display: inline-block;
font-size: 2em;
margin-right: 1em;
}
</style>
</head>
<body>
<header class="container">
<h1>ImageProcessor NET4</h1>
</header>
<section class="container">
@RenderBody()
</section>
<div class="container">
<header>
<h1>ImageProcessor NET4</h1>
</header>
<nav role="navigation">
<ul>
<li>@Html.ActionLink("Jpeg", "Index")</li>
<li>@Html.ActionLink("Gif", "Gif")</li>
<li>@Html.ActionLink("Png", "Png")</li>
<li>@Html.ActionLink("Png8", "Png8")</li>
<li>@Html.ActionLink("Bmp", "Bmp")</li>
<li>@Html.ActionLink("Tiff", "Tiff")</li>
<li>@Html.ActionLink("External", "External")</li>
</ul>
</nav>
<section>
@RenderBody()
</section>
</div>
</body>
</html>

31
src/TestWebsites/NET4/config/imageprocessor/processing.config

@ -1,18 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<processing>
<plugins>
<plugin name="Resize">
<settings>
<setting key="MaxWidth" value="3000"/>
<setting key="MaxHeight" value="3000"/>
</settings>
</plugin>
<plugin name="Constrain">
<settings>
<setting key="MaxWidth" value="3000"/>
<setting key="MaxHeight" value="3000"/>
</settings>
</plugin>
</plugins>
</processing>
<processing>
<plugins>
<plugin name="Resize">
<settings>
<setting key="MaxWidth" value="3000"/>
<setting key="MaxHeight" value="3000"/>
</settings>
</plugin>
<plugin name="Preset">
<settings>
<setting key="a" value="width=300&#038;height=150"/>
</settings>
</plugin>
</plugins>
</processing>

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

@ -40,6 +40,28 @@
</div>
</div>
</section>
<section>
<div class="row">
<h2>Resize Max</h2>
<div class="col-s-4">
<img src="/images/Penguins.jpg?width=300&height=500&mode=max" />
</div>
<div class="col-s-8">
<img src="/images/udendørs.jpg?width=600&height=250&mode=max" />
</div>
</div>
</section>
<section>
<div class="row">
<h2>Resize Stretch</h2>
<div class="col-s-4">
<img src="/images/Penguins.jpg?width=300&height=500&mode=stretch" />
</div>
<div class="col-s-8">
<img src="/images/udendørs.jpg?width=600&height=250&mode=stretch" />
</div>
</div>
</section>
<section>
<h2>Filter</h2>
<div class="row">
@ -121,7 +143,7 @@
</div>
<div class="col-s-6">
<h2>Remote</h2>
</div>
</div>
</div>
</section>
<section>
@ -141,7 +163,7 @@
<article>
<h1>Color Profiles</h1>
@* <section>
@* <section>
<div class="row">
<div class="col-s-6">
<h2>CMYK original jpg</h2>

6
src/TestWebsites/NET45/Test_Website_NET45/config/imageprocessor/processing.config

@ -7,12 +7,6 @@
<setting key="MaxHeight" value="3000"/>
</settings>
</plugin>
<plugin name="Constrain">
<settings>
<setting key="MaxWidth" value="3000"/>
<setting key="MaxHeight" value="3000"/>
</settings>
</plugin>
<plugin name="Preset">
<settings>
<setting key="a" value="width=300&#038;height=150"/>

Loading…
Cancel
Save