Take squared images using the camera


#1

I’m using the mdg:camera package and I want to take squared (600px * 600px) images. Something similar to Instagram.

But I don’t find a way to automatically crop them. From the documentation:

options is an optional argument that is an Object with the following possible keys:

width An integer that specifies the minimum width of the returned photo.
height An integer that specifies the minimum height of the returned photo.

I don’t need to set up the minimum size, but the maximum. Are there more options available for the camera?


#2

I’m not sure if you mean your using cordova which I am not. I did it with

var canvas = document.createElement("canvas");
var ctx = canvas.getContext("2d");
ctx.canvas.width = newWidth;
ctx.canvas.height = newHeight;
ctx.drawImage(img ....

and

imageElement.src = canvas.toDataURL("image/jpeg");

The code above is a bit incomplete but I hope it helps…


#3

I’m trying to do it with the MeteorCamera.getPicture() :blush:


#4

I just used a width and height on them. Depends how exactly you want them cropped though.


#5

But cropping them this way might cut important parts of the image, as the camera is taking portrait pictures and I will display only squared ones…