Giter Club home page Giter Club logo

jay-peg's People

Contributors

diegomura avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

jay-peg's Issues

Decoding Exif with GPS markers cause failure

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.

Version 1.0.2 on npm is the same as 1.0.1

Looks like npm run build (or whatever you're using to compile) may not have been ran before npm publish for 1.0.2..

For example, the dist/index.cjs still shows on line 347

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

rather than

entries.gpsInfo = this._decodeIDFEntries(buffer, $0b53e5b7c7fe341c$var$tags.gps, gps);

but line 271 is the src/marjers/exif.js in the bundle is as expected:

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

Result being i need to run npm i && npm run build in the node_modules/jay-peg after npm i to ensure the issue related to this change is resolved

Parsing fails with non-standard APP0

Some JPEGs have a non-standard APP0 segment. It is non-standard but it breaks parsing because jay-peg assumes fixed size APP0.

I can't give the original image but here's the hex for the broken segment: (includes APP0 marker, two-byte size, and the whole marker data)

0xFF,0xE0,0x00,0x14,0x4A,0x46,0x49,0x46,0x00,0x01,0x01,0x01,0x01,0x2C,0x01,0x2C,0x00,0x00,0x41,0x4D,0x50,0x46

The last four bytes spell out AMPF in ascii, which according to a random googling is somehow related to some Apple extension. See also https://github.com/exiftool/exiftool/blob/master/lib/Image/ExifTool.pm#L2226

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.