cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kyle Slack (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CB-12512) No way to get from a FILE_URL to a DATA_URL onsuccess
Date Tue, 28 Feb 2017 13:17:45 GMT

    [ https://issues.apache.org/jira/browse/CB-12512?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15887981#comment-15887981
] 

Kyle Slack commented on CB-12512:
---------------------------------

1. We were working under the assumption that PNGs have better compression than other image
formats, it doesn't matter much the encoding as long as the data is saved, PNG/JPEG can be
utilized as PNG or JPEG when displaying the image later. We have switched over to using JPEG
in this application to use less memory.

2. I've tested this without errors where on Android we take a JPEG and then display with the
data:image/png;base64 preamble but this isn't much of a concern on our end.

3. No we do not need full-resolution images. This is a simple low quality image just to verify
that something happened with picture proof. I have set the targetWidth and targetHeight each
to 600. I can also verify the aspect ration isn't a problem as all images captured fill to
the view width and follows the CSS rules properly for displaying within our application. 

Thank you very much for the help. At this point I believe this code is properly handling both
Android and iOS camera interactions perfectly with a DATA_URL return:

viewModel.getPicture = function () {
        navigator.camera.getPicture(function (data) {
            //use setTimeout especially w/ iOS to allow time for the UI to replace/resize
the controls and statusbar
            setTimeout(function () {
                StatusBar.overlaysWebView(true);
                setTimeout(function () {
                    StatusBar.overlaysWebView(false);
                }, 250);
            }, 250);
            viewModel.txtImageStatus("Loading...");
            document.getElementById("image").src = "data:image/png;base64," + data;
            viewModel.showNoImage(false);
            document.getElementById("image").style.display = "block";
            viewModel.shipment.CustomerPhotoInfo = data;
        }, function (msg) {
            if (!msg == "Camera cancelled.") {
                viewModel.popVisible(true);
                viewModel.popMessage("Failed: " + msg);
            };
            setTimeout(function () {
                StatusBar.overlaysWebView(true);
                setTimeout(function () {
                    StatusBar.overlaysWebView(false);
                }, 250);
            }, 250);
        }, {
            quality: 30,
            destinationType: Camera.DestinationType.DATA_URL,
            targetWidth: 600,
            targetHeight: 600,
            saveToPhotoAlbum: false,
            correctOrientation: true,
            encodingType: Camera.EncodingType.JPEG
        });
    }

> No way to get from a FILE_URL to a DATA_URL onsuccess
> -----------------------------------------------------
>
>                 Key: CB-12512
>                 URL: https://issues.apache.org/jira/browse/CB-12512
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Plugin Camera, Plugin File
>         Environment: Android 4.0+ / iOS 9.0+
>            Reporter: Kyle Slack
>
> The onsuccess function of the getPicture method uses the FILE_URI to set an <img>
source perfectly fine, however, the conversion of this FILE_URI to get the image data or DATA_URL
is never successful no matter the means attempted. Even utilizing your posted methods to get
the actual file have failed:
> window.resolveLocalFileSystemURL(imgUri, function success(fileEntry) - is not getting
to the image, always results in null DATA_URL in the end.
> Our method using FILE_URI:
> {code}
> navigator.camera.getPicture(function (data) {
>             setTimeout(function () {
>                 StatusBar.overlaysWebView(true);
>                 setTimeout(function () {
>                     StatusBar.overlaysWebView(false);
>                 }, 250);
>             }, 250);
>             viewModel.txtImageStatus("Loading...");
>             document.getElementById("image").src = data; 
>             viewModel.showNoImage(false);
>             document.getElementById("image").style.display = "block";
>             SavetoShipment(data);
>         }, function (msg) {
>             if (!msg == "Camera cancelled.") {
>                 viewModel.popVisible(true);
>                 viewModel.popMessage("Failed: " + msg);
>             };
>             setTimeout(function () {
>                 StatusBar.overlaysWebView(true);
>                 setTimeout(function () {
>                     StatusBar.overlaysWebView(false);
>                 }, 250);
>             }, 250);
>         }, {
>             quality: DevExpress.devices.real().platform == "ios" ? 50 : 100,
>             destinationType: Camera.DestinationType.FILE_URI,
>             saveToPhotoAlbum: false,
>             correctOrientation: true,
>             encodingType: DevExpress.devices.real().platform == "ios" ? Camera.EncodingType.PNG
: Camera.EncodingType.JPEG
>         });
> function SavetoShipment(fileURI) {
>         var fileReader = new FileReader();
>         fileReader.onload = function (fileLoad) {
>             viewModel.shipment.CustomerPhotoInfo = fileLoad.target.result;
>         };
>         fileReader.readAsDataURL(fileURI);
>     }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Mime
View raw message