-
Notifications
You must be signed in to change notification settings - Fork 135
moxie.image.Image
Important! This page is auto-generated from the comments in the source files. All changes will be overwritten! If you are looking to contribute, modify the comment in the corresponding source file instead.
- Constructor
- Properties
-
Methods
- clone(src, [exact=false])
- load(src, [mixed])
- resize(options)
- downsize() (deprecated: use resize())
- crop(width, [height=width], [preserveHeaders=true])
- getAsBlob([type="image/jpeg"], [quality=90])
- getAsDataURL([type="image/jpeg"], [quality=90])
- getAsBinaryString([type="image/jpeg"], [quality=90])
- embed(el, [options])
- destroy()
- Events
Image preloading and manipulation utility. Additionally it provides access to image meta info (Exif, GPS) and raw binary data.
Unique id of the component
Unique id of the connected runtime, if any.
Name of the file, that was used to create an image, if available. If not equals to empty string.
Size of the image in bytes. Actual value is set only after image is preloaded.
Width of the image. Actual value is set only after image is preloaded.
Height of the image. Actual value is set only after image is preloaded.
Mime type of the image. Currently only image/jpeg and image/png are supported. Actual value is set only after image is preloaded.
Holds meta info (Exif, GPS). Is populated only for image/jpeg. Actual value is set only after image is preloaded.
Alias for load method, that takes another mOxie.Image object as a source (see load).
Arguments
-
src
Image
Source for the image -
[exact=false]
Boolean
Whether to activate in-depth clone mode
Loads image from various sources. Currently the source for new image can be: mOxie.Image, mOxie.Blob/mOxie.File, native Blob/File, dataUrl or URL. Depending on the type of the source, arguments - differ. When source is URL, Image will be downloaded from remote destination and loaded in memory.
Arguments
-
src
Image|Blob|File|String
Source for the image -
[mixed]
Boolean|Object
Example
var img = new mOxie.Image();
img.onload = function() {
var blob = img.getAsBlob();
var formData = new mOxie.FormData();
formData.append('file', blob);
var xhr = new mOxie.XMLHttpRequest();
xhr.onload = function() {
// upload complete
};
xhr.open('post', 'upload.php');
xhr.send(formData);
};
img.load("http://www.moxiecode.com/images/mox-logo.jpg"); // notice file extension (.jpg)
Resizes the image to fit the specified width/height. If crop is specified, image will also be cropped to the exact dimensions.
Arguments
-
options
Object
-
width
Number
Resulting width -
[height=width]
Number
Resulting height (optional, if not supplied will default to width) -
[type='image/jpeg']
String
MIME type of the resulting image -
[quality=90]
Number
In the case of JPEG, controls the quality of resulting image -
[crop='cc']
Boolean
If not falsy, image will be cropped, by default from center -
[fit=true]
Boolean
In case of crop whether to upscale the image to fit the exact dimensions -
[preserveHeaders=true]
Boolean
Whether to preserve meta headers (on JPEGs after resize) -
[resample='default']
String
Resampling algorithm to use during resize -
[multipass=true]
Boolean
Whether to scale the image in steps (results in better quality)
-
width
Downsizes the image to fit the specified width/height. If crop is supplied, image will be cropped to exact dimensions.
Alias for downsize(width, height, true). (see downsize)
Arguments
-
width
Number
Resulting width -
[height=width]
Number
Resulting height (optional, if not supplied will default to width) -
[preserveHeaders=true]
Boolean
Whether to preserve meta headers (on JPEGs after resize)
Retrieves image in it's current state as mOxie.Blob object. Cannot be run on empty or image in progress (throws DOMException.INVALID_STATE_ERR).
Arguments
-
[type="image/jpeg"]
String
Mime type of resulting blob. Can either be image/jpeg or image/png -
[quality=90]
Number
Applicable only together with mime type image/jpeg
Retrieves image in it's current state as dataURL string. Cannot be run on empty or image in progress (throws DOMException.INVALID_STATE_ERR).
Arguments
-
[type="image/jpeg"]
String
Mime type of resulting blob. Can either be image/jpeg or image/png -
[quality=90]
Number
Applicable only together with mime type image/jpeg
Retrieves image in it's current state as binary string. Cannot be run on empty or image in progress (throws DOMException.INVALID_STATE_ERR).
Arguments
-
[type="image/jpeg"]
String
Mime type of resulting blob. Can either be image/jpeg or image/png -
[quality=90]
Number
Applicable only together with mime type image/jpeg
Embeds a visual representation of the image into the specified node. Depending on the runtime, it might be a canvas, an img node or a thrid party shim object (Flash or SilverLight - very rare, can be used in legacy browsers that do not have canvas or proper dataURI support).
Arguments
-
el
DOMElement
DOM element to insert the image object into -
[options]
Object
-
[width]
Number
The width of an embed (defaults to the image width) -
[height]
Number
The height of an embed (defaults to the image height) -
[type="image/jpeg"]
String
Mime type -
[quality=90]
Number
Quality of an embed, if mime type is image/jpeg -
[crop=false]
Boolean
Whether to crop an embed to the specified dimensions
-
[width]
Properly destroys the image and frees resources in use. If any. Recommended way to dispose mOxie.Image object.
Dispatched when loading is complete.
Arguments
-
event
Object
Dispatched when resize operation is complete.
Arguments
-
event
Object
Dispatched when visual representation of the image is successfully embedded into the corresponsing container.
Arguments
-
event
Object