I want to modify exif orientation, which I'm able to do for most images, but for some images some exif data (like "Make", "Model", "X-resolution", "Y-resolution") gets corrupted or lost.
So I tried to compare exif objects before and after modification on those problematic images, but when I try to get exif object using load() after inserting modified exif, I'm getting this error:
Uncaught 'unpack' error. Mismatch between symbol and string length. 2:0.
If I just take the inserted jpegData and create a blob out of it, some of exif data becomes corrupted:
Before:
After:
Here is the code that I used:
function modifyOrientation(file) {
var reader = new FileReader();
reader.onload = function(e) {
var origDataUrl = e.target.result;
var exif = piexif.load(origDataUrl);
console.log(exif);
exif['0th'][piexif.ImageIFD.Orientation] = 1; // modifying orientation
var dump = piexif.dump(exif);
var inserted = piexif.insert(dump, origDataUrl);
var modifiedExif = piexif.load(inserted); // <== error thrown here
console.log(modifiedExif);
debugger;
};
reader.readAsDataURL(file);
}
Thanks for the work,
I want to modify exif orientation, which I'm able to do for most images, but for some images some exif data (like "Make", "Model", "X-resolution", "Y-resolution") gets corrupted or lost.
So I tried to compare exif objects before and after modification on those problematic images, but when I try to get exif object using
load()
after inserting modified exif, I'm getting this error:Uncaught 'unpack' error. Mismatch between symbol and string length. 2:0
.If I just take the inserted jpegData and create a blob out of it, some of exif data becomes corrupted:
Before:
After:
Here is the code that I used:
and here is the sample image: