Skip to content

Commit

Permalink
Merge pull request #32 from eyeccc/check-exif-in-more-segments
Browse files Browse the repository at this point in the history
add more exif checks when removing exif
  • Loading branch information
hMatoba authored Nov 13, 2017
2 parents 9e9df79 + 8bae165 commit aa8bcb7
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions piexif.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,12 @@ SOFTWARE.
}

var segments = splitIntoSegments(jpeg);
if (segments[1].slice(0, 2) == "\xff\xe1" &&
segments[1].slice(4, 10) == "Exif\x00\x00") {
segments = [segments[0]].concat(segments.slice(2));
} else if (segments[2].slice(0, 2) == "\xff\xe1" &&
segments[2].slice(4, 10) == "Exif\x00\x00") {
segments = segments.slice(0, 2).concat(segments.slice(3));
} else {
throw("Exif not found.");
}
var newSegments = segments.filter(function(seg){
return !(seg.slice(0, 2) == "\xff\xe1" &&
seg.slice(4, 10) == "Exif\x00\x00");
});

var new_data = segments.join("");
var new_data = newSegments.join("");
if (b64) {
new_data = "data:image/jpeg;base64," + btoa(new_data);
}
Expand Down

0 comments on commit aa8bcb7

Please sign in to comment.