Closed CodeSpent closed 4 years ago
Are you creating an image from windows? It will only output BMP from windows.
I have the same issue, I'm using Windows 10.
Apparently, the output as jpeg is producing an image with the mime type: image/x-ms-bmp
@chuckfairy unfortunately I didn't see your notification in time, and @promatik this was so long ago I'm not sure I can remember much context to help out. :disappointed:
I do know that I've used node-webcam in other projects more recent without this issue, so I believe this issue could be closed and @promatik if you would like to post an SO question I'd be happy to have a look!
For anyone having the same issue, node-webcam on windows produces bmp images only, and width, height and quality options don't work.
To solve this I installed jimp, it allows to manipulate the bitmap, convert it to jpg, set the quality and size and a lot of other things.
@CodeSpent we may close this issue for now 👍
For anyone strugling with this, here is a sample of what I did using Promises:
async webcam(data) {
return new Promise((resolve, reject) => {
webcam.capture(
'picture',
{
output: 'bmp',
},
error => {
if (error) {
reject(error);
} else {
Jimp.read('picture.bmp', (err, bmp) => {
bmp
.resize(data.width || 640, Jimp.AUTO)
.quality(data.quality || 75)
.getBase64Async('image/jpeg')
.then(resolve)
.catch(reject);
});
}
}
);
});
}
having some sort of image post processing would be nice. We could get around a lot of issues like this and anybody trying to do effects that one camera implementation might have and other not. I'll keep jimp in mind thanks. Code wise an error for an invalid type is probably better then the current bmp with a .jpg extension.
var camOpts = { width: 1920, height: 1080, delay: 0, quality: 100, callbackReturn: "location", output: "jpeg", device: false, verbose: true }
I'm not sure if its due to the content-type not properly populating, or if its just poor encoding, but the image file gathered is corrupt and therefore can't be used for delivery to an API. Any workaround for this?
When uploading to S3, the content-type is shown as application.