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

GIF resize throws Error #162

Closed
joelabair opened this issue Feb 10, 2015 · 9 comments
Closed

GIF resize throws Error #162

joelabair opened this issue Feb 10, 2015 · 9 comments
Labels

Comments

@joelabair
Copy link

sharp@0.9.1
vips-7.40.11-1.fc20.x86_64
vips-devel-7.40.11-1.fc20.x86_64
node v0.10.33

Error: Input buffer contains unsupported image format

calling code

var transformer = sharp().resize(maxWidth, maxHeight).max().withoutEnlargement().toFile(downSampleCacheFile, function(err) {
    if (err) {
        debug("Sharp Error", err);
        return next(err);
    }
    fs.stat(downSampleCacheFile, function(err, stats) {
        if (err) {
            debug("Stat Error", err);
            return next(err);
        }
        res.set('Content-Length', stats.size);
        fs.createReadStream(downSampleCacheFile).pipe(res);
    });
});

readStream.pipe(transformer);
@lovell
Copy link
Owner

lovell commented Feb 11, 2015

Hi Joel, whilst GIF files are supported, GIF data is unsupported for Stream-based input.

https://github.com/lovell/sharp#sharpinput

JPEG, PNG, WebP or TIFF format image data can be streamed into the object when input is not provided.

This is because libvips decompresses GIF data using *magick, which doesn't provide any stream-like support.

@joelabair
Copy link
Author

Thanks! Sorry, I overlooked that. I'll buffer the GIF stream first.

@lovell
Copy link
Owner

lovell commented Feb 11, 2015

No probs. For GIF you'll need to "buffer" to the filesystem (tmpfs will suffice) then provide the filename to sharp's constructor.

@joelabair
Copy link
Author

@lovell how would I output the gif, after transform? is gif output supported?

@lovell
Copy link
Owner

lovell commented Feb 12, 2015

No, sorry.

@joelabair
Copy link
Author

NP. I'll just switch to gm on unsupported formats. Thanks for the quick followup!

@lovell
Copy link
Owner

lovell commented Feb 27, 2015

Thanks to @mcuelenaere, sharp v0.9.3 adds support for GIF input via Stream and Buffer. You'll need to compile libvips from the latest source to take advantage.

@joelabair
Copy link
Author

ooooh! Sweet! Thanks for the heads up @lovell

@lovell
Copy link
Owner

lovell commented Mar 12, 2015

Closing this inactive question - feel free to re-open if you have a related question.

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

No branches or pull requests

2 participants