I have written a Phonegap application and compiled it using the Build service. My application calls the camera in this block of code:
function capturePhoto() {
// Take picture using device camera and retrieve image
navigator.camera.getPicture(onPhotoDataSuccess, onFail, {
quality: 20,
destinationType: destinationType.FILE_URI });
}
The resulting image is uploaded to a server via ajax. When I review the uploaded images, some arrive with their quality reduced appropriately but some arrive with a filesize of ~4 MB. I have realized that users who are running my app on iPhone 4 and 5 (I have no testers with 6 yet) are consistently uploading the large images.
I have reduced quality to 10 and 5. Image size of Android-submitted images are appropriately reduced- but still IOS images are large. Can anyone tell me if there is a known issue here?
The API Docs say that you cannot reduce quality of images selected from gallery or camera roll- but these are not. They are loaded from camera.
There is no issue. iOS has larger pictures. They call it a feature.
http://lifeinlofi.com/more/iphone-photo-sizes-2007-2013/
Jesse
This is the code the plugin uses for processing the image after taking the picture:
So, if
options.encodingType
is PNG the image quality isn't change. The default value is JPG, so the problem isn't there.But then check the
allowsEditing
is NO by defaulttargetSize.width
andtargetSize.height
are 0 by defaultcorrectOrientation
is NO by defaultSo all the conditions of the if are meet, and no change in quality is done.
It sounds like a bug as it isn't mentioned anywhere that you have to specify any other value to make the quality param work.
So, what can you do now?
You can file an issue on the cordova jira page https://issues.apache.org/jira/browse/CB And/or you can pass any param to change the default value and make the code to skip the if and go to the else with the quality code. Changing any of this should work:
EDIT: there is already a bug open https://issues.apache.org/jira/browse/CB-6190
EDIT 2: I fixed the issue, you can get the changes with
cordova plugin add https://github.com/apache/cordova-plugin-camera
or wait until it's released to NPM