Hi, I'm trying to resize an image based on a url. I have things working so that I can fetch the image from the url, copy it to the server, and then resize, but I would like to eliminate the need to copy the image onto the server.
When I try to use a buffer I get the following error:
Input file is of an unsupported image formatVipsForeignLoad
The way I'm trying to do this is like this with - https://github.com/request/request:
var sharp = require('sharp'),
request = require('request');
request(url, function(err, res, bodyBuffer) {
sharp(bodyBuffer)....
});
Am I using the constructor wrong? Do you think this the right approach, or do you have any alternative ideas?
Thanks for any insights!
https://github.com/request/request#requestoptions-callback says:
if you expect binary data, you should set encoding: null
so perhaps try:
request({url: url, encoding: null}, function(err, res, bodyBuffer) {
sharp(bodyBuffer)....
});
@lovell thanks for catching that in the docs! works perfectly.
Most helpful comment
https://github.com/request/request#requestoptions-callback says:
so perhaps try: