Output Image gets rotated

Author: thumslCreated Mar 15, 2024Updated Mar 18, 2024

I'm running the node version, with a very simples program just to test it out and a lot of images get rotated, here's an example:

090691fb-9aeb-4d56-a1bb-9adaeee1c2a1 8ab4af6f-e095-4697-a4eb-eab199e5b4bb

Here's my code;

const
const fs = require('fs');

async function saveBlobToDisk(blob, outputPath) {
  try {
      const buffer = Buffer.from(await blob.arrayBuffer());
      fs.writeFileSync(outputPath, buffer);
      return 0;
  } catch (error) {
      return 1;
  }
}

async function remove(imgSource, outputPath) {
    let blob = await removeBackground(imgSource)
    saveBlobToDisk(blob, outputPath);
}

await remove('input.jpg', 'output.png');

Is this somehow an issue with my code, or is it a bug?

I don't think Github compresses uploaded images, so my original file can be used for testing purposes.

Source: imgly/background-removal-js