Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions piexif.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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)) {
Expand All @@ -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);
Expand Down Expand Up @@ -670,8 +670,8 @@ SOFTWARE.
return output;
};
}


if (typeof window !== "undefined" && typeof window.atob === "function") {
var atob = window.atob;
}
Expand Down Expand Up @@ -1915,7 +1915,7 @@ SOFTWARE.
},
41729: {
'name': 'SceneType',
'type': 'Undefined'
'type': 'Short'
},
41730: {
'name': 'CFAPattern',
Expand Down Expand Up @@ -2136,14 +2136,18 @@ SOFTWARE.
1: {
'name': 'InteroperabilityIndex',
'type': 'Ascii'
},
2: {
'name': 'InteroperabilityVersion',
'type': 'Ascii'
}
},
};
TAGS["0th"] = TAGS["Image"];
TAGS["1st"] = TAGS["Image"];
that.TAGS = TAGS;


that.ImageIFD = {
ProcessingSoftware:11,
NewSubfileType:254,
Expand Down Expand Up @@ -2332,7 +2336,7 @@ SOFTWARE.
NoiseProfile:51041,
};


that.ExifIFD = {
ExposureTime:33434,
FNumber:33437,
Expand Down Expand Up @@ -2445,6 +2449,7 @@ SOFTWARE.

that.InteropIFD = {
InteroperabilityIndex:1,
InteroperabilityVersion:2
};

that.GPSHelper = {
Expand All @@ -2468,8 +2473,8 @@ SOFTWARE.
return deg * sign;
}
};


if (typeof exports !== 'undefined') {
if (typeof module !== 'undefined' && module.exports) {
exports = module.exports = that;
Expand Down