Skip to content

API reference ​

This page documents the v1.3.8 Vue 2 API. For Vue 3, use the v2 API and migration guide.

Props ​

PropTypeDefaultNotes
valueObject—v-model target; receives the Croppa instance
widthNumber200Display width in v1
heightNumber200Display height in v1
qualityNumber2Backing canvas multiplier
placeholderStringChoose an imageEmpty-state text
placeholder-colorCSS color#606060Placeholder text color
placeholder-font-sizeNumber00 means automatic sizing
canvas-colorCSS colortransparentCanvas background / whitespace color
zoom-speedNumber3Wheel zoom sensitivity
acceptString—Passed to and validated like a file input accept value
file-size-limitNumber0Maximum file bytes; 0 disables the limit
disabledBooleanfalseDisables user interaction
disable-drag-and-dropBooleanfalseDisables dropping files
disable-click-to-chooseBooleanfalseDisables click/tap file selection
disable-drag-to-moveBooleanfalseDisables image panning
disable-scroll-to-zoomBooleanfalseDisables wheel zoom
disable-pinch-to-zoomBooleanfalseDisables touch pinch zoom
disable-rotationBooleanfalseDisables rotate and flip methods
reverse-scroll-to-zoomBooleanfalseReverses wheel zoom direction
prevent-white-spaceBooleanfalseConstrains image to keep the canvas covered
show-remove-buttonBooleantrueShows the built-in remove control
remove-button-colorStringredBuilt-in remove icon color
remove-button-sizeNumberautomaticRemove control width / height
initial-imageString or Image—URL or HTMLImageElement
initial-sizecover, contain, naturalcoverInitial image fitting mode
initial-positionStringcenterCSS-like initial alignment / percentages
input-attrsObject—Extra attributes for the hidden file input
show-loadingBooleanfalseShows the built-in loading spinner
loading-sizeNumber20Spinner size in px
loading-colorString#606060Spinner color
replace-dropBooleanfalseAllow a dropped file to replace the current image
passiveBooleanfalseRead-only synchronized preview mode
image-border-radiusNumber or String0Clips rendered output when prevent-white-space is enabled
auto-sizingBooleanfalseSize from the container instead of width / height props
video-enabledBooleanfalseExperimental v1 video-frame support

Methods ​

Image and input ​

MethodPurpose
chooseFile()Open the hidden file input
setFile(file)Load a File programmatically
getChosenFile()Return the currently chosen File
remove()Remove the current image
refresh()Reinitialize, including the current initial-image
hasImage()Whether an image is currently set

Movement and transforms ​

MethodPurpose
move({ x, y })Move by canvas pixels
moveUpwards(amount)Move vertically up
moveDownwards(amount)Move vertically down
moveLeftwards(amount)Move horizontally left
moveRightwards(amount)Move horizontally right
zoomIn()Zoom in one step
zoomOut()Zoom out one step
zoom(zoomIn, acceleration)Lower-level zoom operation
rotate(step)Rotate in 90° steps; negative values rotate the other direction
flipX()Flip horizontally
flipY()Flip vertically

Output and state ​

MethodPurpose
generateDataUrl(type, quality)Return canvas output as a data URL
generateBlob(callback, type, quality)Generate a Blob with a callback
promisedBlob(type, quality)Promise-based Blob output
getCanvas()Return HTMLCanvasElement
getContext()Return CanvasRenderingContext2D
getMetadata()Return startX, startY, scale, orientation
applyMetadata(metadata)Reapply v1 transform metadata
addClipPlugin(fn)Add a canvas clip path callback
supportDetection()Return basic browser / drag-and-drop support flags

Events ​

EventPayload / timing
initCroppa instance after initialization
file-chooseSelected File
file-size-exceedFile that exceeded file-size-limit
file-type-mismatchFile that failed type validation
new-imageA valid new image was read
new-image-drawnNew image was drawn for the first time
image-removeCurrent image was removed
moveImage position changed
zoomImage scale changed
drawCanvasRenderingContext2D after each image draw
initial-image-loadedInitial image finished loading
loading-startImage loading begins
loading-endImage loading finishes

Slots ​

initial ​

Provide an img element as the initial image. If both the slot and initial-image prop are provided, the slot takes precedence.

placeholder ​

Provide an img element drawn behind the placeholder text while the cropper is empty.

default ​

Default slot content is appended inside the cropper container and can be used for custom overlay controls. Positioned overlays should normally use absolute positioning.

State access ​

v1 exposes internal component state through the model instance. Treat undocumented internal fields as unstable even if they are visible in Vue Devtools.

Prefer documented methods and metadata rather than mutating canvas, img, ctx, imgData, or other internal fields directly.

Deprecated v1 API ​

reset() was replaced by remove(). getActualImageSize() was replaced by the outputWidth and outputHeight state values.

For new code, avoid adding dependencies on deprecated or undocumented v1 internals because the v2 state model is intentionally different.

Released under the ISC License.