Friday, 17 March 2017

How to read each file and check if there is qr code?

function upload(bucket, key, filename, content_type, cb) {
        s3.putObject({
                Bucket: bucket,
                Key: key,
                Body: fs.createReadStream(filename),
                ContentType: content_type
        }, function (err, data) {
                console.log(err);
                cb(err, data);
        });
        var jpegData = fs.createReadStream(filename);
        var rawImageData = jpeg.decode(jpegData);
        console.log("barcode detection");
        console.log(rawImageData);
        var decode = jsQR.decodeQRFromImage(rawImageData.data, rawImageData.width, rawImageData.height);
        console.log(decode);
}

function uploadImages(context, _images, cb) {
        numCompleted = 1;
        for (var i = 1; i <= _images; i++) {
                console.log(_images);
                console.log(dstKey + "/" + srcFilename + "_" + i);
                upload(dstBucket, dstKey + "/images/" + i + ".jpeg", "/tmp/" + i + ".jpeg", "image/jpeg", function (err, data) {
                        numCompleted++;
                        if (numCompleted > _images) {                                  
                                cb();
                        }
                });
        }
}

I want to check if the file has qr code once the upload is completed. right now the above console.log(rawImageData) returns undefined.



via face turn

No comments:

Post a Comment