gomfunkel / node-exif

A node.js library to extract Exif metadata from images.
MIT License
581 stars 104 forks source link

Error: Invalid marker found at offset 623. Expected 0xFF but found 0xFA. #20

Closed joshuamcginnis closed 10 years ago

joshuamcginnis commented 11 years ago

I'm having issues getting the lib to return Exif data for regular plain-ol JPGs. I've attached one that does not work. Your example image does work, however, many other images I try do not.

app.post('/upload', function(req, res) {
    try {
        new ExifImage({ image : req.files.image.path }, function (error, exifData) {
            if (error)
                console.log('Error: '+error.message);
            else
                res.send(exifData);
        });
    } catch (error) {
        console.log('Error: ' + error.message);
    }
});

Returns the following error for the referenced image:

Error: Invalid marker found at offset 623. Expected 0xFF but found 0xFA.

a0477d88209411e3b30a22000aa80109_7

tremby commented 10 years ago

I'm getting similar errors for lots of images. I believe some of these images not to have any exif data in them anyway, but I was expecting in that case (at least if the file is not broken) for no error message, but an empty exif object.

dmitrig01 commented 10 years ago

I'm also encountering this error.

gomfunkel commented 10 years ago

@joshuamcginnis: The image you provided does look tasty but doesn't seem to contain any exif data, as @tremby already suspected. The error is raised because no start marker for exif data was found in the image.

@tremby: Do you really want to get an empty exif object in return? I think it makes sense to throw an error of some kind you can react on in your application. Don't you think? I have to admit that it is worth discussing if the error message is meaningful enough...

tremby commented 10 years ago

Definitely. Asking for exif data and there being none isn't an error to me. There's just no exif data. What's hard about reacting on an empty object, or length === 0? But I can adapt to whatever you think is best.

gomfunkel commented 10 years ago

The more I think of it the more I think your approach would be the better one. Maybe I've simply been coding too much Java lately and like to throw errors around... :)

gomfunkel commented 10 years ago

Switched from returning an error to returning an empty object as @tremby proposed. Makes sense.

The change is already pushed to GitHub but not yet published to npm. I'm going to publish it in a couple of days, as I want to have one or two additional changes done first.

gomfunkel commented 10 years ago

Change made in version 0.4.0.