Image Compression and save memory

You must Login before you can answer or comment on any questions.

var filename = new Date().getTime() + ".jpg"; currentWidth = e.media.width; currentHeight = e.media.height;

    blob = e.media;

    if(currentWidth > 500 || currentHeight > 500) {

        if(currentWidth > currentHeight) {
            newWidth = 500;
            newHeight = newWidth*currentHeight/currentWidth;
        } else {
            newHeight = 500;
            newWidth = newHeight*currentWidth/currentHeight;
        }

        blob = Titanium.UI.createImageView({image:blob,width:newWidth,height:newHeight}).toImage();
    }

    var savedfile = Ti.Filesystem.getFile(Titanium.Filesystem.getApplicationDataDirectory(),filename);
    savedfile.write(blob);

ive compressed image with this logic in perspective of height and width, but i want to know that do this logic compress images in memory too??

— asked 2 years ago by Gagan Tiwari
1 Comment
  • What do you mean "compress it in memory"? Do you mean is the file size smaller in the file system? Or do you mean is it a smaller memory footprint when using it in the app?

    — commented 2 years ago by Tony Lukasavage

2 Answers

noo, lemme explain, take an example of camera of galaxy tab,suppose, ive installed an application in it which uses camera and after capturing image i want to reduce image size in consideration of memory .

Your Answer

Think you can help? Login to answer this question!