0

Earlier I have used version 0.22.0 but my build failed to deployed, so i have tried with 0.21.0 then it throwing run-time exception "Expected positive integer for width but received [object Object] of type object at

4

1 回答 1

2

Based on your comment this is your code:

sharp(inputPhotoUrl)
  .resize({ height: 230, width: 534 })
  .toFile(propotionOutPhoto)
  .then(function(newFileInfo) {
    console.log("Success");
  })
  .catch(function(err) {
    console.log("Error occured ", err);
  });

Your argument for resize is looks valid, however I never give the width and height that way because that is just an alternative way (altough, that should work based on the documentation).

I suggest you to pass the width and height as first and secon parameter and then if you got any other option pass them as an object. This is always works for me (width, height, {options}):

sharp(inputPhotoUrl)
  .resize(534, 230)
  .toFile(propotionOutPhoto)
  .then(() => console.log("Success"))
  .catch((error) => console.log("Error occured", error));
于 2019-03-28T09:46:38.000 回答