Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-advanced-cropper

Package Overview
Dependencies
Maintainers
1
Versions
117
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-advanced-cropper

The advanced library to create your own croppers suited for any website design

  • 1.11.2
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Vue Advanced Cropper logo


Downloads Version
Documentation / Examples / Sandbox


:fire: HEADS UP! You're currently looking at the branch for Vue 2. If you're looking for the branch for Vue 3, please check out vue-next branch.


Vue Advanced Cropper is the advanced library that gives you opportunity to create your own croppers suited for any website design. It means that you are able to change not only the cropper appearance, you area able to customize its behavior also.

Features:

  • full mobile / desktop support
  • support all three main types of croppers right out of the box
  • support both canvas and coordinates modes, minimum and maximum aspect ratios, custom size restrictions
  • zoom, rotate, resize image
  • auto-zoom, transitions

The codesandbox for mobile / desktop examples above.

Install

npm install --save vue-advanced-cropper
yarn add vue-advanced-cropper

If you would to use CDN read the corresponding documentation section

Usage

import Vue from 'vue'
import { Cropper } from 'vue-advanced-cropper'
import 'vue-advanced-cropper/dist/style.css';

new Vue({
  el: '#app',
  data: {
    img: 'https://images.pexels.com/photos/226746/pexels-photo-226746.jpeg'
  },
  methods: {
    change({coordinates, canvas}) {
      console.log(coordinates, canvas)
    }
  },
  components: {
    Cropper
  }
})
<div id="app">
  <cropper
    class="cropper"
    :src="img"
    :stencil-props="{
      aspectRatio: 10/12
    }"
    @change="change"
  ></cropper>
</div>
/*
  Maybe you need to set the limits for the cropper sizes or its container sizes
  otherwise a cropping image will try to fill all available space
*/
.cropper {
  height: 600px;
  background: #DDD;
}

Cropper

PropTypeDescriptionDefault
srcStringThe cropping image (link / base64)
stencilComponentString, ObjectThe stencil componentRectangleStencil
stencilPropsObjectThe props for the stencil component{}
classStringThe optional class for the root cropper block
imageClassStringThe optional class for the cropping image
boundariesClassStringThe optional class for the area.
backgroundClassStringThe optional class for the background under the image
autoZoomBooleanEnable / disable transitionsfalse
transitionsBooleanEnable / disable auto zoomtrue
stencilSizeObject The size of the stencil in pixels
debounceString, NumberThe time before change event will be emitted after changes (ms)500
canvasBooleanThe flag that indicates if canvas should be usedtrue
minWidthString, NumberThe minimum width of the stencil (percents)
minHeightString, NumberThe minimum height of the stencil (percents)
maxWidthString, NumberThe maximum width of the stencil (percents)
maxHeightString, NumberThe maximum height of the stencil (percents)
checkOrientationBooleanCheck if EXIF orientation should be checkedtrue
resizeImageBoolean, ObjectThe options for the image resizing (details)true
moveImageBoolean, ObjectThe options for the image moving (details)true
imageRestrictionStringSet restrictions for image position ('fill-area' 'fit-area', 'stencil', 'none')'fill-area'
defaultSizeObject, FunctionThe function that returns the default size of the stencil or objectcore.defaultSize
defaultPositionObject, FunctionThe function that returns the default position of the stencil or objectcore.defaultPosition
defaultBoundariesString, FunctionThe function that determines the boundaries size or string ('fill', 'fit')'fill'
sizeRestrictionsAlgorithmFunctionThe function that returns the restrictions object
EventDescription
changeInvoked on changing of a stencil position / size, after mounting the component and on an image changing
readyInvoked on success of an image loading
errorInvoked on error of an image loading

RectangleStencil

PropTypeDescriptionDefault
aspectRatioNumberThe aspect ratio
minAspectRatioNumberThe minimum aspect ratio
maxAspectRatioNumberThe maximum aspect ratio
classStringThe class for root block of the stencil component
previewClassStringThe class for the preview component
movingClassStringThe class applied when user drag the stencil
resizingClassStringThe class applied when user resize the stencil
boundingBoxClassStringThe class for the bounding box component
handlerComponentString,ObjectThe handler component
handlersObjectThe object of handlers that should be visible or hidden.
handlersClassesObjectThe object of custom handler classes
handlersWrappersClassesObjectThe object of custom handler wrapper classes
lineComponentString,ObjectThe handler component
linesObjectThe object of lines that should be visible or hidden.
linesClassesObjectThe object of custom line classes
linesWrappersClassesObjectThe object of custom line wrapper classes

License

The source code of this library is licensed under MIT, the documentation and photos are belong to their respective owners.

Keywords

FAQs

Package last updated on 30 Jul 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc