Scale, Rotate, Crop and Process image with Canvas
<script src="[Path to scripts]/imageEditor.min.js"></script>
var imageEditorInstance = new ImageEditor({
elt: (DOM Element),
... optional settings ...
});
- Container of the input file, canvas and button
- Mandatory
- Type :
DOM Element
- Input File Element
- Optional
- Default value :
elt.querySelector('input[type=file]')
- Type :
DOM Element
- Canvas Element
- Optional
- Default value :
elt.querySelector('canvas')
- Type :
DOM Element
- Button Element to Turn Counterclockwise
- Optional
- Default value :
elt.querySelector('.bt-left')
- Type :
DOM Element
- Button Element to Turn Clockwise
- Optional
- Default value :
elt.querySelector('.bt-right')
- Type :
DOM Element
- Button Element to Zoom Out
- Optional
- Default value :
elt.querySelector('.bt-less')
- Type :
DOM Element
- Button Element to Zoom In
- Optional
- Default value :
elt.querySelector('.bt-more')
- Type :
DOM Element
- Button Element to Save the Image
- Optional
- Default value :
elt.querySelector('.bt-save')
- Type :
DOM Element
- Zoom Ratio (Between 1.1 and 2)
- Optional
- Default value :
1.1
- Type :
Number
- Max Zoom Level (Between 1 and 25)
- Optional
- Default value :
20
- Type :
Number
- Max File Size (in Mo)
- Optional
- Default value :
5
- Type :
Number
- Function invoked when the editor is initalized
- Optional
- Default value :
undefined
- Type :
Function
- No argument
- Function invoked when the image is updated
- Optional
- Default value :
undefined
- Type :
Function
- No argument
- Function invoked when the image is rotated (counterclockwise)
- Optional
- Default value :
undefined
- Type :
Function
- Arguments : [0] New Angle in degrees (
Number
)
- Function invoked when the image is rotated (clockwise)
- Optional
- Default value :
undefined
- Type :
Function
- Arguments : [0] New Angle in degrees (
Number
)
- Function invoked when the image is zoomed out
- Optional
- Default value :
undefined
- Type :
Function
- Arguments : [0] New Zoom Level (
Number
)
- Function invoked when the image is zoomed in
- Optional
- Default value :
undefined
- Type :
Function
- Arguments : [0] New Zoom Level (
Number
)
- Function invoked when the drag begins
- Optional
- Default value :
undefined
- Type :
Function
- Arguments : [0] Position on X in px (
Number
), [1] Position on Y in px (Number
)
- Function invoked while dragging
- Optional
- Default value :
undefined
- Type :
Function
- Arguments : [0] Position on X in px (
Number
), [1] Position on Y in px (Number
)
- Function invoked when the drag stops
- Optional
- Default value :
undefined
- Type :
Function
- Arguments : [0] Position on X in px (
Number
), [1] Position on Y in px (Number
)
- Function invoked when save method is called
- Optional
- Default value :
undefined
- Type :
Function
- Arguments : [0]
Object
with properties base64 that contains the 64-encoded data URI (String
) and blob that contains the Blob file (Blob
)
- Function invoked when the File reading is aborted
- Optional
- Default value :
undefined
- Type :
Function
- Arguments : [0] Error Message (
String
)
- Function invoked when an error occured during the File reading
- Optional
- Default value :
undefined
- Type :
Function
- Arguments : [0] Error Message (
String
)
- Function invoked when the FileReader starts loading the file
- Optional
- Default value :
undefined
- Type :
Function
- No argument
- Function invoked while the FileReader is loading the file
- Optional
- Default value :
undefined
- Type :
Function
- Arguments : [0] Percentage Loaded (
Number
)
- Function invoked when the FileReader ends loading the file
- Optional
- Default value :
undefined
- Type :
Function
- No argument
- Function invoked when the file loaded is bigger than maxSize
- Optional
- Default value :
undefined
- Type :
Function
- Arguments : [0] File size (in octets) (
Number
), [1] Max size (in octets) (Number
)
- Function invoked when the file loaded is not an image
- Optional
- Default value :
undefined
- Type :
Function
- Arguments : [0] File (64-encoded data URI) (
String
), [1] Allowed formats (Array
)