ImageResizer
3.4.0
|
Public Member Functions | |
ImageUploadHelper (Config c) | |
string | GetExtension (string path) |
Parses the file extension from the path and returns it. If it contains a multi-segment extension like .txt.zip, only "zip" will be returned. More... | |
string | NormalizeExtension (string extension) |
Lowercases and normalizes some common extension aliases (jpeg->jpg, tiff-tif). Does not filter out non-image extensions! More... | |
bool | IsExtensionWhitelisted (string ext, string[] whitelistedFormats=null) |
Returns true if the given extension is whitelisted. More... | |
string | GetWhitelistedExtension (Stream image=null, string originalPath=null, string[] whitelistedFormats=null) |
Uses stream signatures first, then the original path, to detect the appropriate normalized image extension. Returns null if extension (or no whitelisted extension) is found. More... | |
bool | IsUploadedFileAnImage (object uploadFile, string[] whitelistedFormats=null) |
Returns true if the uploaded file is identified as an image (looks for the image signature, falling back to the user-provided filename). More... | |
int[] | GetImageSize (object s) |
Returns the [width,height] of the first frame/page of the image. May return null or throw exceptions. More... | |
string | SaveUploadedFileSafely (string baseDir, object uploadFile, string unrecognizedImageExtension=".unknown", string[] whitelistedFormats=null) |
Returns the name used for the file, without any path information. Name will be in "guid.ext" form. Will create any intermediate directories required. More... | |
string | GenerateSafeImageName (Stream image=null, string originalPath=null, string unrecognizedImageExtension=".unknown", string[] whitelistedFormats=null) |
Generates a safe name for your image in the form "guid.ext". Uses stream signatures first, then the path to determine the appropriate image extension. You can provide your own whitelist of extensions if desired; this defaults to the extensions supported by the currently installed set of plugins. More... | |
FileSignature | GuessFileTypeBySignature (Stream s) |
Tries to guess the file type of the given stream by the byte signature. Typically more reliable than file extensions - users constantly rename file extensions expecting it to change the actual encoding. Throws Argument exception if stream isn't seekable and readable. Returns null if there were no matches. Make sure the current position of the stream is at the beginning of the file, or you will get no results. Returns the stream to its original position More... | |
Properties | |
static ImageUploadHelper | Current [get] |
Definition at line 13 of file ImageUploadHelper.cs.
|
inline |
Generates a safe name for your image in the form "guid.ext". Uses stream signatures first, then the path to determine the appropriate image extension. You can provide your own whitelist of extensions if desired; this defaults to the extensions supported by the currently installed set of plugins.
unrecognizedImageExtension | Pass null to have an ArgumentException thrown if the image type is not recognized as a whitelisted format |
Definition at line 188 of file ImageUploadHelper.cs.
Referenced by ImageResizer.ImageUploadHelper.SaveUploadedFileSafely().
|
inline |
Parses the file extension from the path and returns it. If it contains a multi-segment extension like .txt.zip, only "zip" will be returned.
path |
Definition at line 30 of file ImageUploadHelper.cs.
Referenced by ImageResizer.ImageUploadHelper.GetWhitelistedExtension().
|
inline |
Returns the [width,height] of the first frame/page of the image. May return null or throw exceptions.
s | May be an UploadFile, a seekable Stream, a physical path, or a virtual path to the image. |
Definition at line 139 of file ImageUploadHelper.cs.
|
inline |
Uses stream signatures first, then the original path, to detect the appropriate normalized image extension. Returns null if extension (or no whitelisted extension) is found.
image | |
originalPath | |
whitelistedFormats | You can provide your own whitelist of extensions if desired (new string[]{"jpg","png"}). This defaults to the extensions supported by the currently installed set of plugins. |
Definition at line 90 of file ImageUploadHelper.cs.
Referenced by ImageResizer.ImageUploadHelper.GenerateSafeImageName(), and ImageResizer.ImageUploadHelper.IsUploadedFileAnImage().
|
inline |
Tries to guess the file type of the given stream by the byte signature. Typically more reliable than file extensions - users constantly rename file extensions expecting it to change the actual encoding. Throws Argument exception if stream isn't seekable and readable. Returns null if there were no matches. Make sure the current position of the stream is at the beginning of the file, or you will get no results. Returns the stream to its original position
s |
Definition at line 203 of file ImageUploadHelper.cs.
Referenced by ImageResizer.ImageUploadHelper.GetWhitelistedExtension().
|
inline |
Returns true if the given extension is whitelisted.
ext | |
whitelistedFormats | You can provide your own whitelist of extensions if desired (new string[]{"jpg","png"}). This defaults to the extensions supported by the currently installed set of plugins. |
Definition at line 68 of file ImageUploadHelper.cs.
Referenced by ImageResizer.ImageUploadHelper.GetWhitelistedExtension().
|
inline |
Returns true if the uploaded file is identified as an image (looks for the image signature, falling back to the user-provided filename).
uploadFile | Must be an HttpPostedFile or another class with both FileName and InputStream members |
whitelistedFormats | You can provide your own whitelist of extensions if desired (new string[]{"jpg","png"}). This defaults to the extensions supported by the currently installed set of plugins. |
Definition at line 116 of file ImageUploadHelper.cs.
|
inline |
Lowercases and normalizes some common extension aliases (jpeg->jpg, tiff-tif). Does not filter out non-image extensions!
path |
Definition at line 42 of file ImageUploadHelper.cs.
Referenced by ImageResizer.ImageUploadHelper.GetWhitelistedExtension().
|
inline |
Returns the name used for the file, without any path information. Name will be in "guid.ext" form. Will create any intermediate directories required.
baseDir | |
uploadFile | |
unrecognizedImageExtension | |
whitelistedFormats |
Definition at line 155 of file ImageUploadHelper.cs.