Image Resizer : API Documentation

Type PathUtils

Namespace ImageResizer.Util

Public static methods

string AddExtension(string path, string newExtension)

Adds the specified extension to path, returning the result. Multiple calls will result in "path.ext.ext.ext.ext". The querystring and fragment is maintained as-is. Semicolon syntax not supported.

string AddQueryString(string virtualPath, string querystring)

Joins the path and querystring. If the path already contains a querystring, they are 'append joined' with the correct character. Fragment is maintained as-is. Does not support the semicolon syntax.

string BuildQueryString(NameValueCollection QueryString, bool urlEncode, bool skipNullValues, Char firstSeparator, Char laterSeparators, Char equals)

Build a customized querystring from a NameValueCollection
Parameters
NameValueCollection QueryString
bool urlEncode
True to URL encode all values
bool skipNullValues
If true, null-valued keys will be skipped
Char firstSeparator
Usually ? or ;
Char laterSeparators
Usually & or ;
Char equals
Always =

string BuildQueryString(NameValueCollection QueryString)

Returns a string querystring in the form "?key=value&key=value". Keys and values are UrlEncoded as they should be.

string BuildQueryString(NameValueCollection QueryString, bool urlEncode)

Returns a string querystring in the form "?key=value&key=value". Keys and values are UrlEncoded if urlEncode=true.

string BuildSemicolonQueryString(NameValueCollection QueryString, bool urlEncode)

Returns a string querystring in the form ";key=value;key=value". Keys and values are UrlEncoded if urlEncode=true.

NameValueCollection FilterQueryString(ResizeSettings query, String[] keepKeys)

Returns a new collection containing only the specified keys from the old one

Byte[] FromBase64UToBytes(string data)

Converts a URL-safe version of base64 to a byte array. (no = padding, with - instead of + and _ instead of /)

string FromBase64UToString(string data)

Converts a URL-safe version of base64 to a string. 64U is (no = padding, with - instead of + and _ instead of /)

string GenerateImageUrl(string path, NameValueCollection query)

Generates a resized image url for the specified physical or virtual path. Not CloudFront compatible. Does not support remote URLs, use RemoteReader for that. If you're running in IIS classic, add ".ashx" to the 'path' parameter.

string GetExtension(string path)

Grabs the last segment of the filename extension. Returns an empty string if there is no extension, or if the extension contains a space. Includes the leading '.' The querystring and fragment is ignored. Semicolon syntax not supported.

string GetFullExtension(string path)

Will return the full extension, like ".jpg.ashx", not just the last bit. Excludes extensions containing spaces or slashes. The querystring and fragment is ignored. Semicolon syntax not supported.

string GuessVirtualPath(string path)

Attempts to guess the virtual path from physical path. Will be thrwarted if the path is mapped as a virtual folder inside the application. If the path is a non-physical path, it will be returned as is. Returns null if the physical path isn't a subfolder of the application's physical path.

string MapPathIfAppRelative(string path)

Returns the physcial mapped path for the specified virtual path if it starts with ~, otherwise retuns the original path.

string MergeOverwriteQueryString(string path, NameValueCollection newQuerystring)

Overwrites exisisting querystring values in 'path' with the values in 'newQuerystring'. Does not support the semicolon syntax.

string MergeQueryString(string path, NameValueCollection newQuerystring)

Adds the querystring values in 'newQuerystring' to the querystring in Path, but does not overwrite values. Does not support the semicolon syntax.

NameValueCollection ParseQueryOnly(string query, bool allowSemicolons, bool urlDecode)

Parses a querystring into a name/value collection. The given string cannot include path or fragment information - it must be *just* the querystring.

NameValueCollection ParseQueryString(string path, bool allowSemicolons, String& beforeQuery, String& fragment)

NameValueCollection ParseQueryString(string path)

Parses the querystring from the given path into a NameValueCollection. accepts "file?key=value" and "?key=value&key2=value2" formats. (no path is required) UrlDecodes keys and values.

NameValueCollection ParseQueryString(string path, bool allowSemicolons)

NameValueCollection ParseQueryStringFriendly(string path)

Like ParseQueryString, but permits the leading '?' to be omitted. Does not support the semicolon syntax.

NameValueCollection ParseQueryStringFriendlyAllowSemicolons(string path)

Like ParseQueryString, but permits the leading '?' to be omitted, and semicolons can be substituted for '&'

string RemoveExtension(string path)

Removes the extension from the filename or URL, leaving the querystring intact, where the extension is only the last extension segment. I.e, image.jpg.bmp.tiff?hi would be image.jpg.bmp?hi after this call. The querystring and fragment is maintained as-is. Semicolon syntax not supported.

string RemoveFullExtension(string path)

Removes all extension segments from the filename or URL, leaving the querystring intact. I.e, image.jpg.bmp.tiff?hi would be image?hi The querystring and fragment is maintained as-is. Semicolon syntax not supported.

string RemoveNonMatchingChars(string text, string chars)

Allows a string to be filtered using the specified whitelisting expression (regex style). I.e, "hi YOU 3", "a-z3" will produce "hi3".

string RemoveQueryString(string path)

Removes the query string from the specifed path. If the path is only a querystring, an empty string is returned. Does not support the semicolon syntax. Fragment is maintained as-is.

string ResolveAppRelative(string virtualPath)

Resolves app-relative paths to virtual paths. Does nothing with virtual or relative paths.

string ResolveAppRelativeAssumeAppRelative(string virtualPath)

Turns relative paths into domain-relative paths. Turns app-relative paths into domain relative paths.

string ResolveVariablesInPath(string pathWithVars, VariableResolverCallback resolver)

string SetExtension(string path, string newExtension)

Should be called SetFullExtension. Sets the file extension of the specified path to the specified value, returning the result. If an extension has multiple parts, it will replace all of them. Leading dots will be stripped from 'newExtension' and re-addd as required. The querystring and fragment is maintained as-is. Semicolon syntax not supported.

string ToBase64U(string data)

Converts aribtrary strings to a URL-safe version of base64 (no = padding, with - instead of + and _ instead of /)

string ToBase64U(Byte[] data)

Converts aribtrary bytes to a URL-safe version of base64 (no = padding, with - instead of + and _ instead of /)

Public properties

string AppPhysicalPath get;

If not running in ASP.NET, returns the folder containing the DLL.

string AppVirtualPath get;

Returns HostingEnvironment.ApplicationVirtualPath or "/", if asp.net is not running