hMatoba / piexifjs

Read and modify exif in client-side or server-side JavaScript.
MIT License
572 stars 119 forks source link

Removing thumbnail from EXIF data #14

Closed svenbluege closed 8 years ago

svenbluege commented 8 years ago

Hi,

I try to remove the embedded thumbnail from the EXIF data or replace it with a empty thumbnail with code like this:

var jpeg = image.buffer;
var data = jpeg.toString("binary");
var exifObj = piexif.load(data);
exifObj["0th"][piexif.ImageIFD.Model] = "FOOBAR 2";
exifObj['thumbnail'] = null;
var exifbytes = piexif.dump(exifObj);
var newData = piexif.insert(exifbytes, data);
var newJpeg = new Buffer(newData, "binary");

Unfortunately the thumbnail stays in the resulting image files. Can you give me any hint on what I'm doing wrong here?

hMatoba commented 8 years ago

Don't use null as value.

delete exifObj["1st"];
delete exifObj['thumbnail'];
svenbluege commented 8 years ago

nice! Thank you very much!