Giter Site home page Giter Site logo

imageTransformVariants resize issue: Uncaught (in promise) TypeError: Cannot set property 'size' of undefined about filepond-plugin-image-transform HOT 10 OPEN

willwilson avatar willwilson commented on May 29, 2024
imageTransformVariants resize issue: Uncaught (in promise) TypeError: Cannot set property 'size' of undefined

from filepond-plugin-image-transform.

Comments (10)

rikschennink avatar rikschennink commented on May 29, 2024 2

Something like this should work:

  imageTransformVariants: {
    thumb_medium_: (transforms) => {
      console.log(transforms);
      transforms.resize = {
        size: {
          width: 400,
          height: 400,
        }
      }
      return transforms;
    },
    thumb_small_: (transforms) => {
      transforms.resize = {
        size: {
          width: 200,
          height: 200,
        }
      }
      return transforms;
    }
  }

from filepond-plugin-image-transform.

rikschennink avatar rikschennink commented on May 29, 2024

I'm sorry but I'm not sure I understand the issue, can you elaborate?

from filepond-plugin-image-transform.

willwilson avatar willwilson commented on May 29, 2024

Sure, using the code above, if I try to upload an image that is 800px by 800px (it's less than 1280), it will error on the transforms.resize.size.width = 640; line saying the resize transform doesn't exist. BUT if I change the imageResizeUpscale to true, then it will work, but it's not the outcome I want since the image will be upscaled to 1280.

from filepond-plugin-image-transform.

rikschennink avatar rikschennink commented on May 29, 2024

Can you try something like:

transforms.resize = {
    size: { width: 640 }
}

from filepond-plugin-image-transform.

xcrap avatar xcrap commented on May 29, 2024

I don't understand where to add this, and also If I should leave imageResizeUpscale true or false.

from filepond-plugin-image-transform.

rikschennink avatar rikschennink commented on May 29, 2024

@xcrap inside a imageTransformVariants function.

from filepond-plugin-image-transform.

xcrap avatar xcrap commented on May 29, 2024

Well I already had that

'thumb_medium_': transforms => {
			transforms.resize.size.width = 500
			// transforms.resize = { size: { width: 500 }}
            return transforms;
		},

This has no effect, the original image is scaled to the full size or gives an error if upscale is set to false.

Adding transforms.resize = { size: { width: 500 }} inside imageTransformVariants I get this.

custom.min.js:1 Uncaught TypeError: Failed to execute 'createImageData' on 'CanvasRenderingContext2D': Value is not of type 'long'.

from filepond-plugin-image-transform.

xcrap avatar xcrap commented on May 29, 2024

It worked, actually, the problem was the lack of height, without it I get this error.

custom.min.js:formatted:8915 Uncaught TypeError: Failed to execute 'createImageData' on 'CanvasRenderingContext2D': Value is not of type 'long'.

Setting the height works perfectly. I wonder if a height it's really necessary.

from filepond-plugin-image-transform.

tomdav999 avatar tomdav999 commented on May 29, 2024

Something like this should work:

  imageTransformVariants: {
    thumb_medium_: (transforms) => {
      console.log(transforms);
      transforms.resize = {
        size: {
          width: 400,
          height: 400,
        }
      }
      return transforms;
    },
    thumb_small_: (transforms) => {
      transforms.resize = {
        size: {
          width: 200,
          height: 200,
        }
      }
      return transforms;
    }
  }

Hi @rikschennink could you update the imageTransformVariants example in the documentation with the proposed solution? I think a lot of these problems (including my own) arise from using the example in the documentation which sets transforms.resize.size.width. At first blush I thought that was equivalent to the solution above, but it isn't. The current documentation is the problem not the solution. ;)

from filepond-plugin-image-transform.

rikschennink avatar rikschennink commented on May 29, 2024

@tomdav999 Good point, done.

from filepond-plugin-image-transform.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.