本文整理汇总了C#中ResizeSettings.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# ResizeSettings.Remove方法的具体用法?C# ResizeSettings.Remove怎么用?C# ResizeSettings.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ResizeSettings
的用法示例。
在下文中一共展示了ResizeSettings.Remove方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Pipeline_ImageMissing
void Pipeline_ImageMissing(System.Web.IHttpModule sender, System.Web.HttpContext context, Configuration.IUrlEventArgs e)
{
if (!string.IsNullOrEmpty(e.QueryString["404"])) {
//Resolve the path to virtual or app-relative for
string path = resolve404Path(e.QueryString["404"]);
//Resolve to virtual path
path = Util.PathUtils.ResolveAppRelative(path);
//Merge commands from the 404 querystring with ones from the original image.
ResizeSettings imageQuery = new ResizeSettings(e.QueryString);
imageQuery.Normalize();
imageQuery.Remove("404"); //Remove the 404 ref
ResizeSettings i404Query = new ResizeSettings(Util.PathUtils.ParseQueryString(path));
i404Query.Normalize();
//Overwrite new with old
foreach (string key in i404Query.Keys)
if (key != null) imageQuery[key] = i404Query[key];
path = PathUtils.AddQueryString(PathUtils.RemoveQueryString(path), PathUtils.BuildQueryString(imageQuery));
//Redirect
context.Response.Redirect(path, true);
}
}
示例2: Pipeline_ImageMissing
void Pipeline_ImageMissing(System.Web.IHttpModule sender, System.Web.HttpContext context, Configuration.IUrlEventArgs e) {
if (!string.IsNullOrEmpty(e.QueryString["404"])) {
//Resolve the path to virtual or app-relative for
string path = resolve404Path(e.QueryString["404"]);
//Resolve to virtual path
path = Util.PathUtils.ResolveAppRelative(path);
// Merge commands from the 404 querystring with ones from the
// original image. We start by sanitizing the querystring from
// the image.
ResizeSettings imageQuery = new ResizeSettings(e.QueryString);
imageQuery.Normalize();
// Use the configured settings by default.
var filterMode = this.filterMode;
var except = this.except;
// To support querystring-specifiable filter mode and exceptions,
// uncomment the if block below.
////// If the imageQuery includes specific 404 command-filtering,
////// (*either* of the values), use those instead of the
////// configured defaults.
////if (!string.IsNullOrEmpty(e.QueryString["404.filterMode"]) ||
//// !string.IsNullOrEmpty(e.QueryString["404.except"]))
////{
//// filterMode = NameValueCollectionExtensions.Get(e.QueryString, "404.filterMode", FilterMode.ExcludeUnknownCommands);
//// except = MatcherCollection.Parse(e.QueryString["404.except"]);
////}
// remove all of the commands we're supposed to remove... we
// clone the list of keys so that we're not modifying the collection
// while we enumerate it.
var shouldRemove = CreateRemovalMatcher(filterMode, except);
var names = new List<string>(imageQuery.AllKeys);
foreach (var name in names)
{
if (shouldRemove(name, imageQuery[name]))
{
imageQuery.Remove(name);
}
}
// Always remove the '404', '404.filterMode', and '404.except' settings.
imageQuery.Remove("404");
imageQuery.Remove("404.filterMode");
imageQuery.Remove("404.except");
ResizeSettings i404Query = new ResizeSettings(Util.PathUtils.ParseQueryString(path));
i404Query.Normalize();
//Overwrite new with old
foreach (string key in i404Query.Keys)
if (key != null) imageQuery[key] = i404Query[key];
path = PathUtils.AddQueryString(PathUtils.RemoveQueryString(path), PathUtils.BuildQueryString(imageQuery));
//Redirect
context.Response.Redirect(path, true);
}
}
示例3: ScaleAndSavePhotos
private void ScaleAndSavePhotos(PhotoModel model, HttpRequestBase request)
{
var file = request.Files[0];
string extension = Path.GetExtension(file.FileName);
string filename = file.FileName;
//Copied Image and add watermark.
ResizeSettings settings = new ResizeSettings();
settings.Add("format", "jpg");
settings.Add("quality", "90");
settings.Add("carve", "true");
settings.Add("scale", "down");
settings.Add("mode", "carve");
if (model.Watermark)
{
settings.Add("watermark", "wm");
}
var path = Path.Combine(HttpContext.Current.Server.MapPath(string.Format("~/Albums/{0}", model.AlbumId)));
if (Directory.Exists(path))
{
//thumb is 75x75
//small is 240x159
//medium is 500 x 332
//large is 1024 x 680
Image img = Image.FromStream(file.InputStream);
//PropertyItem[] properties = img.PropertyItems;
//foreach (PropertyItem prop in properties)
//{
//}
bool vert = img.Height > img.Width;
settings.Add("maxwidth", vert ? "680" : "1024");
//settings.Add("maxheight", vert ? "1024" : "680");
Bitmap copy = ImageResizer.ImageBuilder.Current.Build(img, settings, false);
copy.Save(Path.Combine(path, "Large\\" + filename));
settings.Remove("maxwidth");
//settings.Remove("maxheight");
settings.Remove("watermark");
settings.Add("maxwidth", vert ? "332" : "500");
//settings.Add("maxheight", vert ? "500" : "332");
copy = ImageResizer.ImageBuilder.Current.Build(img, settings, false);
copy.Save(Path.Combine(path, "Medium\\" + filename));
settings.Remove("maxwidth");
//settings.Remove("maxheight");
settings.Remove("watermark");
settings.Add("maxwidth", vert ? "200" : "301");
//settings.Add("maxheight", vert ? "301" : "200");
copy = ImageResizer.ImageBuilder.Current.Build(img, settings, false);
copy.Save(Path.Combine(path, "Small\\" + filename));
settings.Remove("maxwidth");
settings.Remove("maxwidth");
settings.Remove("watermark");
settings.Add("maxwidth", "75");
settings.Add("maxheight", "75");
copy = ImageResizer.ImageBuilder.Current.Build(img, settings, false);
copy.Save(Path.Combine(path, "Thumb\\" + filename));
file.SaveAs(Path.Combine(path, "Original\\" + filename));
}
}
示例4: Modify
public ResizeSettings Modify(ResizeSettings s)
{
if (!string.IsNullOrEmpty(s["preset"])) {
string[] presets = s["preset"].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
foreach (string p in presets) {
//Apply defaults
if (defaults.ContainsKey(p)) {
ResizeSettings dq = defaults[p];
foreach (string key in dq.Keys) {
if (s[key] == null) s[key] = dq[key]; //Overwrite null and missing values on defaults.
}
}
//Apply overrides
if (settings.ContainsKey(p)) {
ResizeSettings sq = settings[p];
foreach (string key in sq.Keys) {
s[key] = sq[key]; //Overwrite null and missing values on defaults.
}
}
}
s.Remove("preset");
}
return s;
}