node-im-resize icon indicating copy to clipboard operation
node-im-resize copied to clipboard

Support for webp?

Open fcosrno opened this issue 8 years ago • 3 comments

Any chance of quickly adding webp support? ImageMagick seems to allow webp (See here).

I tried the README example using webp:

var resize = require('im-resize');

var image = {
  path: 'cute-cat.jpg',
  width: 5184,
  height: 2623
};

var output = {
  versions: [{
    suffix: '-square',
    maxWidth: 200,
    aspect: "1:1",
    format:"webp"
  }]
};

resize(image, output, function(error, versions) {
  if (error) { console.error(error); }
  console.log(versions[0].path);   // /path/to/image-thumb.jpg
  console.log(versions[0].width);  // 150
  console.log(versions[0].height); // 100

  console.log(versions[1].path);   // /path/to/image-square.jpg
  console.log(versions[1].width);  // 200
  console.log(versions[1].height); // 200
});

But got the following error:

Error: Command failed: convert cute-cat.jpg -auto-orient -strip -write mpr:cute-cat.jpg +delete mpr:cute-cat.jpg -quality 80 -crop "2624x2623+1280+0" -resize "200" cute-cat-square.webp

fcosrno avatar Feb 01 '17 22:02 fcosrno

Are you sure that your version of ImageMagic have support for webp? If this is optionally supported you may have to compile ImageMagic from source to enable webp support.

Starefossen avatar Feb 04 '17 21:02 Starefossen

Does the following command work with your installation of ImageMagic:

convert cute-cat.jpg -quality 50 -define webp:lossless=true cute-cat.webp

Starefossen avatar Feb 04 '17 21:02 Starefossen

The command does not work. Perhaps this is good news? I get the following:

convert: delegate failed `'cwebp' -quiet %Q '%i' -o '%o'' @ error/delegate.c/InvokeDelegate/1845

fcosrno avatar Feb 07 '17 02:02 fcosrno