Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement web camera and mobile camera on Meteor [closed]

I need to implement a photo capture on Meteor. Is there any Meteor package to achieve image capturing?

like image 336
Genjuro Avatar asked Mar 18 '15 11:03

Genjuro


1 Answers

I'm using the mdg:camera package. It's simple and useful.

meteor add mdg:camera

First you can create a link on the html side.

<template name="example">
    <a href="#" class="takePhoto">take photo</a>
    <img class="photo">
</template>

After clicking, you can change the captured picture.

Template.example.events({
    'click .takePhoto': function(e, instance) {
        e.preventDefault();

        var cameraOptions = {
            width: 800,
            height: 600
        };

        MeteorCamera.getPicture(cameraOptions, function (error, data) {
           if (error) {
               return; // here maybe you can give an error.
           }

           instance.$('.photo').attr('src', data);
        });
    }
});

You can also check here for some picture options:

https://github.com/meteor/mobile-packages/blob/master/packages/mdg:camera/README.md#meteorcameragetpictureoptions-callback

like image 153
yasaricli Avatar answered Sep 23 '22 06:09

yasaricli