This is a migrated thread and some comments may be shown as answers.

Recommendations for jpeg compression?

2 Answers 129 Views
Apache Cordova
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Gerard
Top achievements
Rank 1
Gerard asked on 07 Oct 2014, 10:06 AM
Hi

We have an app that utilises the camera. We have it previewing the image on the form and it holds the base64 data in a hidden variable and this gets uploaded to our server on submission of the form.

_onPhotoDataSuccessReceipt: function(imageData) {
    console.log("function _onPhotoDataSuccessReceipt called");
    var smallImage = document.getElementById('smallImageReceipt');
    smallImage.style.display = 'block';
     
    // Show the captured photo.
    smallImage.src = "data:image/jpeg;base64," + imageData;
             
    $("#receipt_data").val(imageData);
     
    // manually clear the receipt error msg if present as validator not doing it
    if ($("#receipt_data").val()!="") {
        $("#receipt_data").next().html("");
    }
 
},

We have been testing using an iPhone 4s and a HTC One.

The iPhone photo sizes are averaging about 5Mb and the HTC about 200k.

Can you recommend any ways that we can compress the jpgs if taken by iPhone or cameras with high resolution by detection  or otherwise?

Many thanks.



2 Answers, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 10 Oct 2014, 07:55 AM
Hi Gerard,

The most probably reason for the big difference in image size is the image resolution. You can specify targetWidth and targetHeight to limit the size of the images taken with the iPhone. Also, you can consider using the quality option to reduce the image file size. These three options are described in the Cordova documentation here:
Camera

If you want to apply different settings when shooting an image, you can use the device object to determine whether the used device is an iPhone or a different one:
Device

Regards,
Tsvetina
Telerik
 

Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

 
0
Gerard
Top achievements
Rank 1
answered on 13 Oct 2014, 01:32 PM
Thanks Tsvetina - I had assumed targetWidth and targetHeight would squash or stretch the image but they don't so that is perfect.
Tags
Apache Cordova
Asked by
Gerard
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Gerard
Top achievements
Rank 1
Share this question
or