question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Corrupt images - Windows only outputs BMP images

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
chuckfairycommented, Apr 6, 2020

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.

1reaction
promatikcommented, Apr 1, 2020

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);
          });
        }
      }
    );
  });
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Repair BMP Files: 5 Ways To Fix Corrupted
This repair tool has the best features with the help of which it becomes so easy to repair corrupt BMP files. It not...
Read more >
How To Fix "Windows Photo Viewer can't open this picture"
Open photo in different application Windows Photo Viewer supports only JPEG, TIFF, PNG, GIF, BMP, DIB, and WDP file formats.
Read more >
Corrupt Pictures - Microsoft Community
Corrupt Pictures. I keep finding pictures (jpg's) which cannot be opened. Windows 10 is reporting the file is "not a valid bitmap file,...
Read more >
Large generated BMP file corrupted - Stack Overflow
Your second image is 100001×100001, i.e., 10 gigapixels. While I can't find an official statement online about the maximum allowed size of a ......
Read more >
How to Repair Unreadable Corrupt Pictures
Photos may become unreadable and cannot open due to corruption? Learn here 5 methods to fix unreadable corrupt pictures.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found