erperejildo / cordova-plugin-preview-camera

Camera embed in html for Cordova projects
Apache License 2.0
1 stars 3 forks source link

takePicture result is not what be supposed #2

Closed zyf0330 closed 8 years ago

zyf0330 commented 8 years ago

takePicture({maxWidth:1920, maxHeight:1920}) give me a origin picture with 1920x3413 resolution and a preview picture with 600x600 resolution, so I believe something is wrong.

erperejildo commented 8 years ago

Ok, thanks for letting me know. I'll take a look into it ASAP

erperejildo commented 8 years ago

I've been working for a while into this issue. The problem comes from the original repo and it is not resolved yed: https://github.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview/pull/114 https://github.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview/issues/27

The problem is easy to fix but I think the fix itself would be worst. I explain myself: You have to take the picture and scale it, if you've a final image with 1920x3413 having maxHeight as 1920, obviously that is not ok, and we could create another if to check this before load the image in the java file to render the image again.

Resuming, if you take a picture with your device in portrait mode the app has to work twice to render always an image in that mode.

Not sure if this could be fixed in a different way, I don't know Java. If you would like to help the file is CameraActivity.java (line 358)

Anyway, I've added new stuffs:

cordova.plugins.camerapreview.takePicture({
      maxWidth: 500,
      maxHeight: 500
    });

result[0]: image with those sizes. This is the most useful option because it would the exactly size than preview canvas (not hidden parts). But those sizes should be proportional than canvas size. result[1]: preview image (in this particular case would be bigger).

cordova.plugins.camerapreview.takePicture({
      maxWidth: 0,
      maxHeight: 0
    });

result[0]: image with real size. In your case 1920x3413 or even bigger. result[1]: preview image (always smaller).

Hope this helps.

zyf0330 commented 8 years ago

Thanks also. But I doesn't know Android more than iOS which I doesn't know any too. Maybe someday origin author will come back, or a new plugin. I cannot contribute now.