How to use the blueimp-load-image.scale function in blueimp-load-image

To help you get started, we’ve selected a few blueimp-load-image 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 bhj / karaoke-forever / src / routes / Account / components / Account / AccountForm / UserImage / UserImage.js View on Github external
loadImage(file, canvas => {
        if (canvas.type === 'error') {
          return alert('The image could not be loaded.')
        }

        const scaled = loadImage.scale(canvas, {
          maxWidth: 400,
          maxHeight: 300,
          crop: true,
          downsamplingRatio: 0.5,
        })

        scaled.toBlob(blob => {
          this.setState({
            imageURL: URL.createObjectURL(blob)
          })

          this.props.onSelect(blob)
        }, 'image/jpeg')
      }, {
        // loadImage options
github signalapp / Signal-Desktop / js / modules / types / visual_attachment.js View on Github external
image.addEventListener('load', () => {
      // using components/blueimp-load-image

      // first, make the correct size
      let canvas = loadImage.scale(image, {
        canvas: true,
        cover: true,
        maxWidth: size,
        maxHeight: size,
        minWidth: size,
        minHeight: size,
      });

      // then crop
      canvas = loadImage.scale(canvas, {
        canvas: true,
        crop: true,
        maxWidth: size,
        maxHeight: size,
        minWidth: size,
        minHeight: size,
      });

      const blob = dataURLToBlobSync(canvas.toDataURL(contentType));

      resolve(blob);
    });
github transcranial / keras-js / demos / src / components / models / ImageSuperResolution.vue View on Github external
this.inputImageShape = [img.height, img.width]
            const outputCanvas = document.getElementById('output-canvas')
            outputCanvas.width = img.width * 2
            outputCanvas.height = img.height * 2
            this.outputImageShape = [img.height * 2, img.width * 2]
            const scaledInputCanvas = document.getElementById('scaled-input-canvas')
            scaledInputCanvas.width = img.width * 2
            scaledInputCanvas.height = img.height * 2

            // load image data onto input canvas
            inputCanvas.getContext('2d').drawImage(img, 0, 0)
            this.imageLoadingError = false
            this.imageLoading = false

            // bilinear scale input image to compare to
            const scaledImg = loadImage.scale(img, { minWidth: img.width * 2, maxWidth: img.width * 2 })
            scaledInputCanvas.getContext('2d').drawImage(scaledImg, 0, 0)

            // run model
            this.modelRunning = true
            this.modelRunningError = false
            this.$nextTick(function() {
              setTimeout(() => {
                this.runModel()
              }, 10)
            })
          }
        },
        { maxWidth: this.srcMaxWidth, canvas: true, crossOrigin: 'Anonymous' }
github signalapp / Signal-Desktop / js / modules / types / visual_attachment.js View on Github external
image.addEventListener('load', () => {
      // using components/blueimp-load-image

      // first, make the correct size
      let canvas = loadImage.scale(image, {
        canvas: true,
        cover: true,
        maxWidth: size,
        maxHeight: size,
        minWidth: size,
        minHeight: size,
      });

      // then crop
      canvas = loadImage.scale(canvas, {
        canvas: true,
        crop: true,
        maxWidth: size,
        maxHeight: size,
        minWidth: size,
        minHeight: size,

blueimp-load-image

JavaScript Load Image is a library to load images provided as File or Blob objects or via URL. It returns an optionally scaled, cropped or rotated HTML img or canvas element. It also provides methods to parse image metadata to extract IPTC and Exif tags a

MIT
Latest version published 3 years ago

Package Health Score

61 / 100
Full package analysis