Recommendations for jpeg compression?

Thread is closed for posting
3 posts, 0 answers
  1. Gerard
    Gerard avatar
    10 posts
    Member since:
    Jun 2012

    Posted 07 Oct 2014 Link to this post


    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'); = 'block';
        // Show the captured photo.
        smallImage.src = "data:image/jpeg;base64," + imageData;
        // manually clear the receipt error msg if present as validator not doing it
        if ($("#receipt_data").val()!="") {

    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. Tsvetina
    Tsvetina avatar
    2329 posts

    Posted 10 Oct 2014 Link to this post

    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:

    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:


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

  3. Gerard
    Gerard avatar
    10 posts
    Member since:
    Jun 2012

    Posted 13 Oct 2014 in reply to Tsvetina Link to this post

    Thanks Tsvetina - I had assumed targetWidth and targetHeight would squash or stretch the image but they don't so that is perfect.
Back to Top