How to preserve image metadata

I want to preserve image metadata but my code strips all metadata. How do I stop this? I run this script from the MATLAB SDE command prompt. Code is below:
p = which('G0011363.JPG');
filelist = dir([fileparts(p) filesep '*.JPG']);
fileNames = {filelist.name};
fileNames_size = size(fileNames,2);
number_of_colums = fileNames_size;
for k = 1:number_of_colums
imwrite(undistortImage(imread(fileNames{k}), cameraParams2cof, 'OutputView', 'valid'), (strcat(int2str(k), 'R2_3COF_ONRcorrected.jpg')));
end

댓글 수: 2

Andrew Nault
Andrew Nault 2016년 8월 16일
편집: Andrew Nault 2016년 8월 16일
The code shown below is what I used to solve my metadata problem. In it I store image capture date only:
load('C:\mypath\workspace.mat')
p = which('G0011363.JPG');
filelist = dir([fileparts(p) filesep '*.JPG']);
fileNames = {filelist.name};
fileNames_size = size(fileNames,2);
number_of_colums = fileNames_size;
for k = 1:number_of_colums
k2 = imfinfo(fileNames{k});
k3 = k2.FileModDate;
imwrite(undistortImage(imread(fileNames{k}), cameraParams2cof, 'OutputView', 'valid'), (strcat(int2str(k), '_R2_3COF.jpg')), 'jpg', 'comment', k3);
end
Image Analyst
Image Analyst 2016년 8월 16일
Yeah it's too bad they only allow a single "comment" meta data tag and not all of the IPTC and EXIF tags.

댓글을 달려면 로그인하십시오.

답변 (2개)

Andrew Nault
Andrew Nault 2016년 8월 20일
편집: Andrew Nault 2016년 8월 20일

1 개 추천

A rose by any other name is just as sweet. I may not have literally extracted and transferred "metadata" but I have the information I need and I was able to imbed it in the new undistorted images. Of special note in the code below, I changed the metadata variable captured to "DateTime" and added total time (in seconds) to the title in lieu of strictly by the books metadata.
load('C:\redacted_lol\workspace.mat')
p = which('G0017317.JPG');
filelist = dir([fileparts(p) filesep '*.JPG']);
fileNames = {filelist.name};
fileNames_size = size(fileNames,2);
number_of_colums = fileNames_size;
k5 = 0;
for k = 1:number_of_colums
k2 = imfinfo(fileNames{k});
k3 = k2.DateTime;
k4 = strrep(k3(12:19), ':', '-');
k5 = k5 + 2;
imwrite(undistortImage(imread(fileNames{k}), cameraParams2cof, 'OutputView', 'valid'), (strcat(int2str(k5), 'SECONDS_LEFTT_', k4, '.png')), 'png', 'comment', k3);
end
Image Analyst
Image Analyst 2016년 8월 14일

0 개 추천

You are creating a brand new image. You did not extract the metadata (EXIF and IPTC tags) from the image so it's not being saved. Also, even if you did extract the tags, I'm pretty sure imwrite() does not have the ability to include metadata tags. I think the TIFF class ( http://www.mathworks.com/help/matlab/ref/tiff-class.html ) does give you the ability to save some tags but I have not used it and don't know if you can save EXIF and IPTC tags.

질문:

2016년 8월 14일

편집:

2016년 8월 20일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by