From e4a91b53970f1ca0292ae4a2446bd6d1a4772c9f Mon Sep 17 00:00:00 2001 From: David Moodie Date: Wed, 7 Jun 2017 21:41:02 +0100 Subject: [PATCH] Use functions from utils --- src/core/lib/remove-exif.js | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/core/lib/remove-exif.js b/src/core/lib/remove-exif.js index 1e158221..5dbb5bb0 100644 --- a/src/core/lib/remove-exif.js +++ b/src/core/lib/remove-exif.js @@ -18,22 +18,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -function bin2String(array) { - return String.fromCharCode.apply(String, array); -} - -function string2Bin(str) { - var result = []; - for (var i = 0; i < str.length; i++) { - result.push(str.charCodeAt(i)); - } - return result; -} +import Utils from "../Utils.js"; // Param jpeg should be a binaryArray function removeEXIF(jpeg) { // Convert binaryArray to char string - jpeg = bin2String(jpeg); + jpeg = Utils.byteArrayToChars(jpeg); if (jpeg.slice(0, 2) != "\xff\xd8") { throw ("Given data is not jpeg."); } @@ -52,7 +42,7 @@ function removeEXIF(jpeg) { var new_data = segments.join(""); // Convert back to binaryArray - new_data = string2Bin(new_data); + new_data = Utils.strToCharcode(new_data); return new_data; };