Closed Profesor08 closed 6 months ago
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); }
II↕☺♥☺☺→☺♣☺b☺♣☺(☺♥☺☻1☺☻ r‼☻♥☺☺i�♦☺|x2☻�♥x2☻�♥sharp:80♠�♦0210☺�♦☺☻♥�♦0100☺�♥☺��☻�♦☺�☻♥�♦☺ ♥
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)
PR for this at https://github.com/devongovett/exif-reader/pull/35
v2.0.1 now available with the fix for this.
Code
Buffer to string
Exception