Skip to content
This repository has been archived by the owner on Apr 26, 2022. It is now read-only.

Optimize using and uploading images in Cordova #42

Open
ChristianWeyer opened this issue Mar 9, 2016 · 1 comment
Open

Optimize using and uploading images in Cordova #42

ChristianWeyer opened this issue Mar 9, 2016 · 1 comment
Assignees
Labels

Comments

@ChristianWeyer
Copy link
Member

By using the standard e.g. iPhone camera we get very large photos with the current code. It can tkae ages to upload and ages to download all the photos.

We need to optimize this e.g. on Cordova.

We could create thumbnails on the server as well.

@ChristianWeyer
Copy link
Member Author

We should use the File API in Cordova - something like this:
var onCordovaDeviceReady = () => {
const camera = window.navigator.camera;

            var options = {
                quality: 20,
                targetWidth: 400,
                destinationType: camera.DestinationType.FILE_URI,
                sourceType: camera.PictureSourceType.CAMERA,
                encodingType: camera.EncodingType.PNG,
                saveToPhotoAlbum: false,
                correctOrientation: true
            };

            camera.getPicture(imageUri => {
                window.resolveLocalFileSystemURL(imageUri, function (fileEntry) {
                    var imageFileUrl = fileEntry.nativeURL;
                    observer.next(imageFileUrl);
                    removeDomListener();
                    observer.complete();
                });
            }, error => {
                observer.error(error);
                removeDomListener();
                observer.complete();
            }, options);
        };

Then we should post the data as multipart mime.
There is a sample how to implement this in my old sample app.

Server/Web API:
https://github.com/ChristianWeyer/myProducts-End-to-End/blob/master/src/myProducts.Services/Controllers/ArticlesController.cs#L114

Client/ng1:
https://github.com/ChristianWeyer/myProducts-End-to-End/blob/master/src/myProducts.Web/client/app/services/articlesService.js#L54

@ChristianWeyer ChristianWeyer changed the title Optimize using and uploading smartphone images Optimize using and uploading images in Cordova Mar 13, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants
@ManuelRauber @ChristianWeyer and others