How to use cropperjs - 10 common examples

To help you get started, we’ve selected a few cropperjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github matheusdavidson / angular-cropperjs / projects / angular-cropperjs / src / lib / cropper / cropper.component.ts View on Github external
//
        // Set crop options
        // extend default with custom config
        this.cropperOptions = Object.assign({
            aspectRatio,
            movable: false,
            scalable: false,
            zoomable: false,
            viewMode: 1,
            checkCrossOrigin: true
        }, this.cropperOptions);

        //
        // Set cropperjs
        this.cropper = new Cropper(image, this.cropperOptions);
    }
github paperbits / paperbits-core / src / workshops / cropper / cropper.ts View on Github external
init: (imageElement: HTMLImageElement, valueAccessor) => {
                const observable = valueAccessor();
                const cropperInstance = new Cropper.default(imageElement, {
                    // aspectRatio: 1,
                    viewMode: 1,
                    responsive: true,
                    ready: () => {
                        this["croppable"] = true;
                    }
                });

                observable(cropperInstance);

                const onResize = () => {
                    cropperInstance["resize"]();
                };

                eventManager.addEventListener("onEditorResize", onResize);
github Hughp135 / angular-5-chat-app / src / app / components / image-cropper / image-cropper.component.ts View on Github external
ngAfterViewInit() {
    this.cropper = new Cropper(this.cropperContainer.nativeElement, {
      responsive: true,
      aspectRatio: 1,
      minContainerWidth: 128,
      minContainerHeight: 128,
      minCropBoxWidth: 50,
      minCropBoxHeight: 50,
      guides: false,
      autoCropArea: 1,
      background: true,
      modal: false,
      viewMode: 1,
      cropend: this.getCanvasData.bind(this),
      zoom: this.getCanvasData.bind(this),
      ready: this.getCanvasData.bind(this),
    });
  }
github area17 / twill / frontend / js / components / Cropper.vue View on Github external
img.addEventListener('load', () => {
        imageWrapper.style.maxWidth = imageWrapper.getBoundingClientRect().width + 'px'
        imageWrapper.style.minHeight = imageWrapper.getBoundingClientRect().height + 'px'

        this.cropper = new CropperJs(imageBox, opts)
      }, {
        once: true,
github scaleflex / filerobot-image-editor / projects / react / components / Preview / ImageManipulator.js View on Github external
() => {
        const canvas = getCanvasNode();
        const rect = canvas.getBoundingClientRect();
        const zoom = canvas.width / rect.width;

        this.cropper = new Cropper(canvas, {
          viewMode: 1,
          modal: false,
          background: false,
          rotatable: false,
          scalable: false,
          zoomable: false,
          movable: false,
          crop: event => {
            this.props.updateState({ cropDetails: event.detail });
          }
        });

        window.scaleflexPlugins = window.scaleflexPlugins || {};
        window.scaleflexPlugins.zoom = zoom;
        window.scaleflexPlugins.cropperjs = this.cropper;
github dreamnettech / dreamtime / src / pages / nudify / crop.backup.vue View on Github external
async createCropper() {
      this.cropper = new Cropper(this.$refs.photoCanvas, {
        viewMode: 0,
        dragMode: 'move',
        cropBoxMovable: false,
        cropBoxResizable: false,
        toggleDragModeOnDblclick: false,
        minCropBoxWidth: 512,
        minCropBoxHeight: 512,
        maxCropBoxWidth: 512,
        maxCropBoxHeight: 512,
        aspectRatio: 1,
        modal: true,
        guides: false,
        highlight: false,
        autoCropArea: 0.1,
        wheelZoomRatio: 0.03,
      })
github gamejolt / frontend-lib / components / img / crop / crop.ts View on Github external
mounted() {
		const useAspectRatio =
			this.minAspectRatio && this.maxAspectRatio ? undefined : this.aspectRatio;

		this.cropper = new Cropper(this.$refs.img, {
			aspectRatio: useAspectRatio,
			viewMode: 1,
			guides: false,
			rotatable: false,
			zoomable: false,
			autoCropArea: 1,
			checkCrossOrigin: false,
			ready: () => {
				if (this.disabled) {
					this.onDisabledChange();
				}

				if (this.value) {
					this.onValueChange();
				}
github webiny / webiny-js / packages / webiny-ui / src / ImageEditor / toolbar / crop.js View on Github external
onActivate: ({ canvas, options }) => {
        cropper = new Cropper(canvas.current, options);
    },
    cancel: () => cropper && cropper.destroy(),
github fengyuanchen / jquery-cropper / src / index.js View on Github external
this.each((i, element) => {
      const $element = $(element);
      const isDestroy = option === 'destroy';
      let cropper = $element.data(NAMESPACE);

      if (!cropper) {
        if (isDestroy) {
          return;
        }

        const options = $.extend({}, $element.data(), $.isPlainObject(option) && option);

        cropper = new Cropper(element, options);
        $element.data(NAMESPACE, cropper);
      }

      if (typeof option === 'string') {
        const fn = cropper[option];

        if ($.isFunction(fn)) {
          result = fn.apply(cropper, args);

          if (result === cropper) {
            result = undefined;
          }

          if (isDestroy) {
            $element.removeData(NAMESPACE);
          }
github kiraka / annict-web / app / frontend / javascripts / pc / components / imageAttachModal.js View on Github external
this.$nextTick(function() {
          const $preview = $(this.$el).find('.c-image-attach-modal__preview')
          return (this.cropper = new Cropper($preview.find('img')[0], {
            setDragMode: 'crop',
            aspectRatio: 3 / 4,
            cropBoxResizable: true,
            ready() {
              return this.cropper.crop()
            },
          }))
        })
        return callback()

cropperjs

JavaScript image cropper.

MIT
Latest version published 5 months ago

Package Health Score

81 / 100
Full package analysis