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

PNG, little endian without Exif\0\0 prefix: Invalid EXIF data: buffer should start with "Exif", "MM" or "II". #34

Closed
Profesor08 opened this issue Jan 27, 2024 · 2 comments
Labels

Comments

@Profesor08
Copy link

Code

  const sharpImage = sharp(src, { animated: true });

  sharpImage.png({ quality: quality });

  sharpImage.withExif({
    IFD0: {
      Software: `sharp:${quality}`,
    },
  });

  sharpImage.keepMetadata();

  sharpImage.keepExif();

  const buffer = await sharpImage.toBuffer();

  const { exif } = await sharp(buffer).metadata();

  console.log(exif?.toString());

  try {
    if (exif !== undefined) {
      console.log(exif.toString().substring(0, 2) === "II");
      console.log(ExifReader.load(exif));
    }
  } catch (err) {
    console.log(err);
  }

Buffer to string

II↕☺♥☺☺→☺♣☺b☺♣☺(☺♥☺☻1☺☻ r‼☻♥☺☺i�♦☺|x2☻�♥x2☻�♥sharp:80♠�♦0210☺�♦☺☻♥�♦0100☺�♥☺��☻�♦☺�☻♥�♦☺ ♥

Exception

Error: Invalid EXIF data: buffer should start with "Exif", "MM" or "II".
    at module.exports (\node_modules\exif-reader\index.js:8:13)
    at test (\vite.config.ts:130:50)
    at async FSWatcher.<anonymous> (\vite.config.ts:102:5)
@lovell lovell added the bug label Jan 27, 2024
@lovell lovell changed the title Invalid EXIF data: buffer should start with "Exif", "MM" or "II". PNG, little endian without Exif\0\0 prefix: Invalid EXIF data: buffer should start with "Exif", "MM" or "II". Jan 27, 2024
@lovell
Copy link
Collaborator

lovell commented Jan 27, 2024

PR for this at #35

@lovell
Copy link
Collaborator

lovell commented Jan 28, 2024

v2.0.1 now available with the fix for this.

@lovell lovell closed this as completed Jan 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants