From a201722f6d9e94dcd071154287416f53b7423089 Mon Sep 17 00:00:00 2001 From: Tyler Pham Date: Thu, 1 Dec 2016 14:12:01 -0500 Subject: [PATCH 1/4] CB-11714: (windows) added extra check for content-type in savePhoto() without options.targetWidth/Height --- src/windows/CameraProxy.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/windows/CameraProxy.js b/src/windows/CameraProxy.js index eb10cd2..aee07a7 100644 --- a/src/windows/CameraProxy.js +++ b/src/windows/CameraProxy.js @@ -800,9 +800,16 @@ function savePhoto(picture, options, successCallback, errorCallback) { if (options.targetHeight > 0 && options.targetWidth > 0) { resizeImage(successCallback, errorCallback, picture, options.targetWidth, options.targetHeight, options.encodingType); } else { - picture.copyAsync(getAppData().localFolder, picture.name, OptUnique).done(function (copiedFile) { - successCallback("ms-appdata:///local/" + copiedFile.name); - },errorCallback); + // CB-11714: check if target content-type is PNG to just rename as *.jpg since camera is captured as JPEG + var pictureName = picture.name; + + if (options.encodingType === Camera.EncodingType.PNG) { + pictureName = pictureName.replace(/\.png$/, ".jpg"); + } + + picture + .copyAsync(getAppData().localFolder, pictureName, OptUnique) + .done(function (copiedFile) { successCallback("ms-appdata:///local/" + copiedFile.name); }, errorCallback); } } else { if (options.targetHeight > 0 && options.targetWidth > 0) { From dca4b9c82b4392dcf2e89fa5aa5fab1043bd9732 Mon Sep 17 00:00:00 2001 From: Tyler Pham Date: Sun, 16 Sep 2018 19:19:13 -0400 Subject: [PATCH 2/4] simplify picture.copyAsync --- src/windows/CameraProxy.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/windows/CameraProxy.js b/src/windows/CameraProxy.js index aee07a7..f648c63 100644 --- a/src/windows/CameraProxy.js +++ b/src/windows/CameraProxy.js @@ -807,9 +807,9 @@ function savePhoto(picture, options, successCallback, errorCallback) { pictureName = pictureName.replace(/\.png$/, ".jpg"); } - picture - .copyAsync(getAppData().localFolder, pictureName, OptUnique) - .done(function (copiedFile) { successCallback("ms-appdata:///local/" + copiedFile.name); }, errorCallback); + picture.copyAsync(getAppData().localFolder, pictureName, OptUnique).done(function (copiedFile) { + successCallback('ms-appdata:///local/' + copiedFile.name); + }, errorCallback); } } else { if (options.targetHeight > 0 && options.targetWidth > 0) { From eb57b02ba85429450d35a32ec13f86b88645a511 Mon Sep 17 00:00:00 2001 From: Tyler Pham Date: Sun, 16 Sep 2018 19:22:16 -0400 Subject: [PATCH 3/4] CB-11714: reuse picture.name instead of pictureName --- src/windows/CameraProxy.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/windows/CameraProxy.js b/src/windows/CameraProxy.js index f648c63..9362be5 100644 --- a/src/windows/CameraProxy.js +++ b/src/windows/CameraProxy.js @@ -801,13 +801,11 @@ function savePhoto(picture, options, successCallback, errorCallback) { resizeImage(successCallback, errorCallback, picture, options.targetWidth, options.targetHeight, options.encodingType); } else { // CB-11714: check if target content-type is PNG to just rename as *.jpg since camera is captured as JPEG - var pictureName = picture.name; - if (options.encodingType === Camera.EncodingType.PNG) { - pictureName = pictureName.replace(/\.png$/, ".jpg"); + picture.name = picture.name.replace(/\.png$/, ".jpg"); } - picture.copyAsync(getAppData().localFolder, pictureName, OptUnique).done(function (copiedFile) { + picture.copyAsync(getAppData().localFolder, picture.name, OptUnique).done(function (copiedFile) { successCallback('ms-appdata:///local/' + copiedFile.name); }, errorCallback); } From c1b9772dca33fd796865ddf75f8ec611430cc09a Mon Sep 17 00:00:00 2001 From: Jan Piotrowski Date: Wed, 3 Oct 2018 20:54:06 +0200 Subject: [PATCH 4/4] replace double quotes with single quotes --- src/windows/CameraProxy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/windows/CameraProxy.js b/src/windows/CameraProxy.js index 9362be5..b24f623 100644 --- a/src/windows/CameraProxy.js +++ b/src/windows/CameraProxy.js @@ -802,7 +802,7 @@ function savePhoto(picture, options, successCallback, errorCallback) { } else { // CB-11714: check if target content-type is PNG to just rename as *.jpg since camera is captured as JPEG if (options.encodingType === Camera.EncodingType.PNG) { - picture.name = picture.name.replace(/\.png$/, ".jpg"); + picture.name = picture.name.replace(/\.png$/, '.jpg'); } picture.copyAsync(getAppData().localFolder, picture.name, OptUnique).done(function (copiedFile) {