PhoneGap iOS - resize the camera only if the photo is larger than targetheight / targetwidth

I am using Cordova 2.0 with a built-in camera plugin. My application contains many photos uploaded to the remote server, and I have to limit the file size on the phone side for bandwidth and performance.

I use the following camera settings to take new photos:

var options = { quality : 30, destinationType : navigator.camera.DestinationType.FILE_URI, targetWidth: 1600, targetHeight: 1200 } 

This is great for photos taken with the phone, as they are usually larger than 1600x1200. However, when I upload an existing photo, I don’t want to scale the images smaller than the target resolution:

  var options = { quality : 30, sourceType : navigator.camera.PictureSourceType.PHOTOLIBRARY, destinationType : navigator.camera.DestinationType.FILE_URI, targetWidth: 1600, targetHeight: 1200 }; 

In fact, I always want to avoid expansion. Any ideas on how to change the “zoom mode” of the camera plugin?

+4
source share
1 answer

According to the documents http://docs.phonegap.com/en/2.2.0/cordova_camera_camera.md.html#camera.getPicture , images in the photo library cannot be scaled regardless of image quality. Only when taking from the phone.

0
source

Source: https://habr.com/ru/post/1442489/


All Articles