gomfunkel / node-exif

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

Problem getting exif #17

Open CodersBrothers opened 11 years ago

CodersBrothers commented 11 years ago

In some images can't get exif, and return this in terminal: ERROR: [TypeError: Object # has no method 'extractMakernotes'] ERROR: [Error: No Exif segment found in the given image.]

    /home/leif/proyectos/widplay/widplay-back-server/node_modules/mongoose/lib/utils.js:419
    throw err;
          ^
Error: Can't set headers after they are sent.
    at ServerResponse.OutgoingMessage.setHeader (http.js:707:11)
    at ServerResponse.formatJSON (/home/leif/proyectos/widplay/widplay-back-server/node_modules/restify/lib/formatters/json.js:25:13)
    at ServerResponse.format (/home/leif/proyectos/widplay/widplay-back-server/node_modules/restify/lib/response.js:94:27)
    at ServerResponse.send (/home/leif/proyectos/widplay/widplay-back-server/node_modules/restify/lib/response.js:197:32)
    at /home/leif/proyectos/widplay/widplay-back-server/inc/server.js:187:33
    at Promise.<anonymous> (/home/leif/proyectos/widplay/widplay-back-server/inc/controllers/database.js:185:17)
    at Promise.<anonymous> (/home/leif/proyectos/widplay/widplay-back-server/node_modules/mongoose/node_modules/mpromise/lib/promise.js:162:8)
    at Promise.EventEmitter.emit (events.js:95:17)
    at Promise.emit (/home/leif/proyectos/widplay/widplay-back-server/node_modules/mongoose/node_modules/mpromise/lib/promise.js:79:38)
    at Promise.fulfill (/home/leif/proyectos/widplay/widplay-back-server/node_modules/mongoose/node_modules/mpromise/lib/promise.js:92:20)

This is my code: 1. Get exif, 2. Save in mongodb, 3. remove file, 4. return info from mongodb. Exif make problems in some images.

// Obtenemos los metadatos exif
        Img.getExif(path, function(err, exifResult){

            if(err){
                console.log("ERROR:", err);
            }

            // Guardamos en GridFs
            var fileInfo = {
                    name: name,
                    path: path,
                    type: typeFile
                },
                metadata = exifResult || {},
                userId = 1;

            // Guardamos en la base de datos
            Database.saveFile(userId, fileInfo, metadata, function(err, fileResult){

                // Eliminamos el fichero
                Disk.remove(path, function(err, result){

                    // Obtenemos metadatos
                    Database.getInfoFile(fileResult._id, userId, function(err, infoResult){

                        // Devolvemos la info
                        res.send(infoResult || {ok: true});
                        next();

                    });

                });

            });

        });
CodersBrothers commented 11 years ago

Not its the same that: ERROR: [Error: The given image is not a JPEG and thus unsupported right now.]

When this error occurred the server don't stop, no there are fatal error.

CodersBrothers commented 11 years ago

I used this picture: http://www.exif.org/samples/canon-ixus.jpg Its a canon image from here: http://www.exif.org/samples.html (the first example)

CodersBrothers commented 11 years ago

Maybe we need a markernote for canon? http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Canon.html

stennie commented 10 years ago

Dupe of #19? makernotes appear to be fixed in 0.3.4+. You could test from current github checkout to confirm.

gomfunkel commented 10 years ago

As @stennie suggested, please check again with the latest version of node-exif which is 0.3.6 and available from npm as well.