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

Output Image gets rotated #107

Open
thumsl opened this issue Mar 15, 2024 · 1 comment
Open

Output Image gets rotated #107

thumsl opened this issue Mar 15, 2024 · 1 comment

Comments

@thumsl
Copy link

thumsl commented Mar 15, 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 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.

@dasiux
Copy link

dasiux commented Mar 18, 2024

I discovered the same issue, as for what i figured out, when running in the browser the exif orientation is respected and used for the output, when running via node the rotation is ignored and the pixeldata is returned as given, my current solution is to pre-process the image and apply respective orientation before handing it to the node process.

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

No branches or pull requests

2 participants