diegomura / jay-peg

Performant JPEG decoder
MIT License
7 stars 2 forks source link

Decoding Exif with GPS markers cause failure #8

Closed gabrielhamel closed 4 months ago

gabrielhamel commented 4 months ago

When I use react-pdf, I'm trying to insert a JPG image but for some reason the image reader fail when he try to decode EXIF metadata. So i tried to reproduce the minimal code to get the error:

const JPEG = require('jay-peg').default;
const fs = require('fs');
const notWorkingImage = fs.readFileSync('/Users/me/Downloads/not-working.jpg');
JPEG.decode(notWorkingImage);

Leads to:

ReferenceError: IFDHandler is not defined
    at $0b53e5b7c7fe341c$var$IDFEntries.decode (/Users/me/Downloads/jpg-test/node_modules/jay-peg/dist/index.cjs:347:36)
    at $aa8b66bae6abe658$export$eabc71f011df675a._parseFields (/Users/me/Downloads/jpg-test/node_modules/restructure/dist/main.cjs:750:29)
    at $aa8b66bae6abe658$export$eabc71f011df675a.decode (/Users/me/Downloads/jpg-test/node_modules/restructure/dist/main.cjs:721:14)
    at $0b53e5b7c7fe341c$var$TIFFHeader.decode (/Users/me/Downloads/jpg-test/node_modules/jay-peg/dist/index.cjs:368:63)
    at $fcb208a95f6d048b$export$95a8b60f4da7dec8._parseFields (/Users/me/Downloads/jpg-test/node_modules/restructure/dist/main.cjs:750:29)
    at $fcb208a95f6d048b$export$95a8b60f4da7dec8.decode (/Users/me/Downloads/jpg-test/node_modules/restructure/dist/main.cjs:817:14)
    at $8ea28a08eae2a116$export$c4be6576ca6fe4aa.decode (/Users/me/Downloads/jpg-test/node_modules/restructure/dist/main.cjs:382:58)
    at $8ea28a08eae2a116$export$c4be6576ca6fe4aa.fromBuffer (/Users/me/Downloads/jpg-test/node_modules/restructure/dist/main.cjs:208:21)
    at Object.$4fa36e821943b400$var$decode [as decode] (/Users/me/Downloads/jpg-test/node_modules/jay-peg/dist/index.cjs:489:48)
    at Object.<anonymous> (/Users/me/Downloads/jpg-test/index.js:7:22)

The line of code who throw the error is:

entries.gpsInfo = IFDHandler(subuffer, $0b53e5b7c7fe341c$var$tags.gps, gps);

And in fact I don't understand what is this IFDHandler. Cause when I read the sources, the corresponding line of code is:

entries.gpsInfo = this._decodeIDFEntries(buffer, tags.gps, gps, true);

and there is no mention of an IFDHandler.

gabrielhamel commented 4 months ago

I close this issue, I am seeing that the problem was already fixed, but somehow the package isn't right deployed -> https://github.com/diegomura/jay-peg/issues/7