Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some exif data is corrupted after using insert() #19

Closed
aidanxyz opened this issue Feb 22, 2017 · 3 comments
Closed

Some exif data is corrupted after using insert() #19

aidanxyz opened this issue Feb 22, 2017 · 3 comments

Comments

@aidanxyz
Copy link

aidanxyz commented Feb 22, 2017

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:

screen shot 2017-02-22 at 4 35 25 pm

After:

screen shot 2017-02-22 at 4 35 57 pm

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);
}

and here is the sample image:

sample 2 - this night scene has sacrificed light for detail and contains no colour

@hMatoba
Copy link
Owner

hMatoba commented Feb 26, 2017

Thank you. Fixed it.

@aidanxyz
Copy link
Author

Great, when are you going to publish 1.0.3 release?

@hMatoba
Copy link
Owner

hMatoba commented Feb 28, 2017

Done : )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants