Image Uploader can resize and compress images before the upload as well as send any files as ZIP archives. This feature is very convenient for mixed upload handling. Suppose that your application receives image files and documents, and you want to decrease the size of files selected for upload. Image Uploader gives you the ability to implement the needed functionality: you can resize all the images to the predefined dimensions before the upload, and upload them as JPEG files, and also compress documents to ZIP archives and upload them too.
Image Uploader can send two kinds of files to a server:
Image Uploader supports the following compression modes for the uploading thumbnails:
If a file selected for upload is an image, Image Uploader resizes this image to the specified dimensions and uploads it as JPEG file. Otherwise, if a file is non-image, Image Uploader uploads a system icon associated with the file. By default, this mode is applied to any file regardless of its extension. More information about image resizing before upload you can read in the Resizing and Rotating Images topic.
Image Uploader sends a ZIP archive of the original file.
Image Uploader sends a system icon associated with a file selected for the upload.
Image Uploader sends the original file.
To specify the compression modes for particular file types use these properties:
The value of these properties is the compression mode format string which consists of file masks=compression modes
pairs separated by semicolon. Each pair includes the set of file masks and the set of compression modes separated by comma.
In general, this string has the following syntax:
mask11,mask12,...=mode1,mode2,...;mask21,mask22,...=mode1,mode2,...;...
When Image Uploader prepares a POST request it parses the compression mode format
string from the beginning to the end and extracts file masks=compression modes
pairs. For each file selected for upload
Image Uploader gives the first pair. If it finds the file mask in this pair corresponded
to extension of the file, it applies the first appropriate compression mode from the compression set of this pair. Otherwise,
if no appropriate file mask or compression mode found, Image Uploader checks the next
pairs in the same manner.
If there is no file mask corresponded to the original file extension or no appropriate compression mode Image Uploader sends an icon.
The following examples demonstrate how to configure the compression mode format string.
iu.addParam("UploadThumbnail1CompressionMode", "*.jpeg,*.jpg,*.tif,*.bmp,*.wbmp,*.png=Jpeg;*.doc=Zip;*.*=SourceFile");
If the string above is specified Image Uploader sends:
iu.addParam("UploadThumbnail1CompressionMode", "*.*=Jpeg,Zip");
In this sample, Image Uploader sends either JPEG thumbnail or ZIP archive in the case when it is unable to create JPEG thumbnail for a uploading file (when the uploading file is non-image).
Image Uploader sends thumbnails and compressed files in the ThumbnailX_N POST fields. Depending on the applied compression mode names of these thumbnails can be:
To determine the actually applied compression mode on the server side use the UploadFileXCompressionMode_N POST field which contains the compression mode of the Xth thumbnail of the Nth uploaded file.
The following example (in pseudocode) demonstrates how to save thumbnails and compressed files on the server side:
iterate through each file (i) { //This value is taken from the Thumbnail1_i POST field file thumbnail1File //This value is taken from the UploadFile1CompressionMode_i POST field string compressionMode if (compressionMode == "Jpeg" || compressionMode == "Icon") { //...Process thumbnail1File as an image file... } if (compressionMode == "Zip") { //...Process thumbnail1File as a ZIP file... } if (compressionMode == "SourceFile") { //...Process thumbnail1File as a source file... } }