Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Input buffer contains unsupported image format #64

Closed
stathischaritos opened this issue Jul 31, 2015 · 3 comments
Closed

Error: Input buffer contains unsupported image format #64

stathischaritos opened this issue Jul 31, 2015 · 3 comments

Comments

@stathischaritos
Copy link

I get this error when I try to resize a gif image, on heroku.

This seems to be related to sharp and libvips
lovell/sharp#162

The version used is later than the one they suggest.

I tried changing the .buildpack to get a newer libvips version but it still gave the same error.

Does anyone else have the same issue?

PS. Great work, extremely valuable project.

@saintberry
Copy link

I do know sharp can't write gifs. It can however stream gifs through imagick and resize the first frame as .jpg or something else (lovell/sharp#165). But it can't write gifs. This means post move to sharp the supported image formats array has a bug in it: https://github.com/jimmynicol/image-resizer/blob/master/src/image.js#L62

I'm trying to find the time to do some modifications to fix this. I'm considering a few approaches:

  1. Don't allow resizes of gifs but allow the original source to be passed back to users (useful for animated gifs). I would 404 if any request came through for a gif with a modifier. This is as simple as not using streams.resize(), streams.filter() or streams.optimize() for *.gif requests in index.js (bypass the sharp portion of the application)
  2. Allow resizing of the first frame for a gif through sharps support for streaming gifs through imagick, use imagick to save the result - this is risky as it uses a lot of memory
  3. Use something like http://www.lcdf.org/gifsicle/ to resize and save the animated gifs based on the image-resizer modifiers

I'll probably end up with 1 as I'm time poor at the moment.

@jimmynicol
Copy link
Owner

@saintberry I would probably suggest 1. is the most pragmatic choice too, but then it begs the question of why bother going through the resizer at all.

The use cases I have had for this project rarely ended up needing gif support, and as mentioned resizing animated gifs never works well. The move to sharp just had too many plus sides to consider gifs.

So I would probably prefer not supporting gifs at all, using the same CDN -> custom source setup to s3 for instance would provide just as good a solution as letting them pass through image-resizer.

@teohhanhui
Copy link

For anyone interested, we have decided to maintain our own fork: https://github.com/tripviss/image-resizer

We've added a "normalize" step in tripviss/image-resizer#12

(Yes, the conversion to PNG has a performance hit, but that's the best we can do at the moment.)

So you can now use GIF and TIFF as input, but be sure to specify a supported output format. Of course, GIF output is still not supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants