Telephony reduces image size

I have a phonegap application that has several input fields, including text fields / text fields / captions / thumbnails / image frames / camera images. This data is uploaded to the server via ajax post.

Problem:

When downloading data, the file is unreasonably large and takes a long time to load due to images. When photographs are not added, the size is about 200 kB - 400 kB, but with images the file reaches 60 MB, and from the point of view of using an Android device with a poor Internet connection (an area with a bad signal), this is unsuitable.

What I tried:

I used image compression in the camera settings, as shown in the code snippet below, however, the problem I am facing is that different devices with different camera characteristics are used, so if the device has a low quality camera and a device with image quality image quality will occur regardless of whether the image quality is terrible.

var cameraOptions = { destinationType: Camera.DestinationType.DATA_URL, quality: 40, encodingType: 0, }; 

Link to the phone’s camera API and options:

http://docs.phonegap.com/en/2.0.0/cordova_camera_camera.md.html#Camera

From the post read below, I realized that jpeg is the easiest format, so endodingType 0 is used

PNG vs GIF vs JPEG vs SVG - When is the best time to use?

What we want to achieve:

Limiting image size to 500 kB per image, and if it is more than compression.

+6
source share
1 answer

I tried with various camera settings, and with the following I got 4.5 MB file size from iPhone 5:

 navigator.camera.getPicture(onSuccess, onFail, { destinationType : Camera.DestinationType.DATA_URL, sourceType : Camera.PictureSourceType.CAMERA, quality : 50, encodingType : Camera.EncodingType.JPEG }); 

Just adding a line

 correctOrientation : true 

File size reduced to ~ 500 KB.

I have no explanation why it should work this way, but I suggest you try if the quality property does nothing.

+5
source

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


All Articles