Code covered by the BSD License  

Highlights from

5.0 | 1 rating Rate this file 36 Downloads (last 30 days) File Size: 50.5 KB File ID: #42000 Version: 1.1




28 May 2013 (Updated )

Read and write full Exif metadata from image files. A Matlab front end for ExifTool, by Phil Harvey.

| Watch this File

File Information

Two functions:
 getexif: read Exif matadata
 putexif: save image with matedata
This is a front end for the command-line executable, ExifTool. It can also serve as an example of how to call other programs from Matlab. This is useful when a reference implementation is available as a command-line version.

MATLAB release MATLAB 8.1 (R2013a)
Other requirements ExifTool by Phil Harvey
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (10)
11 May 2015 Soumyabrata Dev

Is there a Linux version for this script?

Comment only
08 Apr 2014 Nishanth Goli

I would like to add a new tag to a Image. How can I do that with this code?

I exactly wish to add the GPSInfo tag to a JPEG or TIFF image. I want to add GPS information from other device into the images

Comment only
05 Mar 2014 Alexandre Schimel

works like a charm

22 Jul 2013 Peter Burns

Update is posted now.

Comment only
22 Jul 2013 Peter Burns

Note: I have submitted an update. It has not been posted yet.

Comment only
22 Jul 2013 Peter Burns

I have updated the files as suggested by jhh and Jonathan. Thanks.

Also, we can suppress the '1 image files updated', returned by ExifTool to the Command window by adding a second argument, so in putexif.m,
%[status] = system(temp1);
is replaced by,
[status, junk] = system(temp1);
[status, ~] = system(temp1);
I have included this in the update.

Comment only
03 Jul 2013 Jonathan

Thanks jhh, that did the tick,
For others you can get the second file, putexif.m to work by making the following changes to the else section:

test = which('exiftool.exe');
[exifdata, nf] = getexif(refname);
% Save data as image file with Matlab metadata
imwrite(dat, fname, 'quality', 100);
[exifdata2, nf2] = getexif(fname);
% Replace matadata from this file with desired tags from reference file
temp1=['"' test '" -m -tagsfromfile "',refname,'" -all:all "', fname, '"'];
status = system(temp1);

% Approximate check
[exifdata3, nf3] = getexif(fname);

% Delete extra copy of reference image file
temp3 = ['del "',fname,'_original"'];
status = system(temp3);

% Test approx. number of tags
if abs(nf3-nf2<10)
disp('Warning: Exif tags may not have been copied');
status = 1;

I can't figure out how to suppress the output saying that '1 image files was updated' as I think it is being passed from exiftool.exe

Comment only
03 Jul 2013 jhh

jhh (view profile)

I've got it running now by (1) using 'addpath' to tell Matlab where exiftool can be found and (2) changing the 'else' part of getexif.m as follows:

TS=[ '"' test '" -s "' fname '"']
[status, exifdata]=system(TS);
nf = find(exifdata==':');
nf = length(nf);

But even then, you just get exifdata as a 1xn char array, you you still have to decipher that into meaningfull variables. (I've done so for myself, and it works, but it's not mature enough to post it on FileExchange).

I suppose nf should reurn the number of fields in the exif data, but counting the ':' is not the right way to do it.

Comment only
02 Jul 2013 Jonathan

I'm having the same issue as jhh, with it not acculay running

Comment only
20 Jun 2013 jhh

jhh (view profile)

Sounds like just what I need, but is not working on my syetem (R2007b).
I get: "'exiftool.exe' is not recognized as an internal or external command,
operable program or batch file."
Even though exiftool.exe is in my path (confirmed by 'whcih exiftool.exe')

Comment only
22 Jul 2013 1.1

Improved following suggestions from jhh and Jonathan. Thanks.

Contact us