Sharp: PNG Input + withMetadata() + .webp() = Input file is missing or of an unsupported image format

Created on 30 May 2018  路  9Comments  路  Source: lovell/sharp

Hi!

I'm trying to convert a png file to webp but seems like when I add the withMetadata to the mix I get the Input file is missing or of an unsupported image format. Any idea why it happens?

To reproduce:

// use a PNG image
sharp(image)
  .web()
  .resize(100)
  .withMetadata()
  .toBuffer()
  .then(...)

If I remove the withMetadata() it works fine.

Worth mentioning that If I don't call .resize or any other operation... no error is raised but it output is a blank image.

PS: JPEG Images works fine.
PS: Tested on sharp 0.20.2 and 0.20.3.

bug ready-to-ship

Most helpful comment

This was due to a bug in libvips - see https://github.com/jcupitt/libvips/pull/989

I expect v0.21.0 of sharp to provide an updated version of libvips that will include this fix.

All 9 comments

Hello, thanks for the report. It seems to only affect WebP+metadata output where pre-multiplication occurred, e.g. resizing an image with an alpha channel. I'll be able to take a closer look in a few days.

This was due to a bug in libvips - see https://github.com/jcupitt/libvips/pull/989

I expect v0.21.0 of sharp to provide an updated version of libvips that will include this fix.

@lovell thanks so much for your help and for quickly fix the problem on the libvips project.

@lovell You guys have an estimative on the release date of this fix?

@igorescobar libvips can be compiled from source and then sharp compiled against that if you need bleeding edge features/fixes such as this.

@lovell Sure, that's fine, I was just wondering... Thanks.

@lovell I'm assuming you don't bump the libvips build with patch versions of sharp? This bug has existed for just over 3 months, so wondering what the approach is to rolling libvips updates? Does it require that there's other functionality in sharp to warrant a minor version bump?

sharp v0.20.x all require libvips v8.6.1+

The next bump of the prebuilt libvips will occur with the forthcoming sharp v0.21.0, probably the forthcoming libvips v8.7.0.

sharp v0.21.0 is now available with a prebuilt libvips v8.7.0 that contains the upstream fix.

Was this page helpful?
0 / 5 - 0 ratings