From 569fd13637c106a02faaabcec31d34cdc14a969e Mon Sep 17 00:00:00 2001 From: Stephen Handley Date: Thu, 1 Aug 2019 18:33:37 -0700 Subject: [PATCH 1/2] add support for InteroperabilityVersion --- piexif.js | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/piexif.js b/piexif.js index 3d0bd12..abe4762 100644 --- a/piexif.js +++ b/piexif.js @@ -37,13 +37,13 @@ SOFTWARE. } else { throw new Error("Given data is not jpeg."); } - + var segments = splitIntoSegments(jpeg); var newSegments = segments.filter(function(seg){ return !(seg.slice(0, 2) == "\xff\xe1" && - seg.slice(4, 10) == "Exif\x00\x00"); + seg.slice(4, 10) == "Exif\x00\x00"); }); - + var new_data = newSegments.join(""); if (b64) { new_data = "data:image/jpeg;base64," + btoa(new_data); @@ -162,13 +162,13 @@ SOFTWARE. interop_ifd, gps_ifd, first_ifd; - + if ("0th" in exif_dict) { zeroth_ifd = exif_dict["0th"]; } else { zeroth_ifd = {}; } - + if ((("Exif" in exif_dict) && (Object.keys(exif_dict["Exif"]).length)) || (("Interop" in exif_dict) && (Object.keys(exif_dict["Interop"]).length))) { zeroth_ifd[34665] = 1; @@ -192,7 +192,7 @@ SOFTWARE. } else if (Object.keys(zeroth_ifd).indexOf(that.ImageIFD.GPSTag.toString()) > -1) { delete zeroth_ifd[that.ImageIFD.GPSTag]; } - + if (("1st" in exif_dict) && ("thumbnail" in exif_dict) && (exif_dict["thumbnail"] != null)) { @@ -201,7 +201,7 @@ SOFTWARE. exif_dict["1st"][514] = 1; first_ifd = exif_dict["1st"]; } - + var zeroth_set = _dict_to_bytes(zeroth_ifd, "0th", 0); var zeroth_length = (zeroth_set[0].length + exif_is * 12 + gps_is * 12 + 4 + zeroth_set[1].length); @@ -670,8 +670,8 @@ SOFTWARE. return output; }; } - - + + if (typeof window !== "undefined" && typeof window.atob === "function") { var atob = window.atob; } @@ -2136,6 +2136,10 @@ SOFTWARE. 1: { 'name': 'InteroperabilityIndex', 'type': 'Ascii' + }, + 2: { + 'name': 'InteroperabilityVersion', + 'type': 'Ascii' } }, }; @@ -2143,7 +2147,7 @@ SOFTWARE. TAGS["1st"] = TAGS["Image"]; that.TAGS = TAGS; - + that.ImageIFD = { ProcessingSoftware:11, NewSubfileType:254, @@ -2332,7 +2336,7 @@ SOFTWARE. NoiseProfile:51041, }; - + that.ExifIFD = { ExposureTime:33434, FNumber:33437, @@ -2445,6 +2449,7 @@ SOFTWARE. that.InteropIFD = { InteroperabilityIndex:1, + InteroperabilityVersion:2 }; that.GPSHelper = { @@ -2468,8 +2473,8 @@ SOFTWARE. return deg * sign; } }; - - + + if (typeof exports !== 'undefined') { if (typeof module !== 'undefined' && module.exports) { exports = module.exports = that; From 6ea7470e3185314206d6322274b27f31dc292e01 Mon Sep 17 00:00:00 2001 From: Stephen Handley Date: Thu, 1 Aug 2019 18:55:02 -0700 Subject: [PATCH 2/2] fix issue with SceneType --- piexif.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/piexif.js b/piexif.js index abe4762..343606b 100644 --- a/piexif.js +++ b/piexif.js @@ -1915,7 +1915,7 @@ SOFTWARE. }, 41729: { 'name': 'SceneType', - 'type': 'Undefined' + 'type': 'Short' }, 41730: { 'name': 'CFAPattern',