How to add 'Description' to '.jpeg'?

조회 수: 3 (최근 30일)
Pawel Jastrzebski
Pawel Jastrzebski 2018년 3월 20일
댓글: Pawel Jastrzebski 2018년 3월 21일
Once I've generated a plot and saved it as .jpeg, I'd like to add a description to it i.e.:
  • 'This plot was created with script version 01'
The code for saving the plot is simple:
x = 0:0.1:4
fig(1) = figure
plot(x,x.^3)
saveas(fig(1),'fig.jpg')
And then I tried to access the image info to modify it but to no avail:
fileName = 'fig.jpg';
i = imread(fileName)
info = imfinfo(fileName)
info.Comment = 'Made with script version 1';
imwrite(i,'figC.jpg')
QUESTIONS:
  1. Is what I'm trying possible?
  2. If so, how?
Many thanks.
  댓글 수: 2
Stephen23
Stephen23 2018년 3월 20일
편집: Stephen23 2018년 3월 20일
Pawel Jastrzebski
Pawel Jastrzebski 2018년 3월 21일
Thanks.

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

채택된 답변

C.J. Harris
C.J. Harris 2018년 3월 20일
If you're only interested in the 'Comment' field, then you can set it directly:
imwrite(i,'figC.jpg', 'Comment', 'Made with script version 1')
  댓글 수: 1
Pawel Jastrzebski
Pawel Jastrzebski 2018년 3월 21일
Thanks, it worked. I've run a few trials:
fileName = 'fig.jpeg';
i = imread(fileName);
imwrite(i,'figC.jpeg',...
'Comment','JPEG: Made with script version 1')
imwrite(i,'figC.png',...
'Comment' ,'PNG: Made with script version 1',...
'Author' , 'PJ',...
'Description','simple plot',...
'Copyright' ,'Open')
imwrite(i,'figC.tiff',...
'Description','TIFF: script version 1')
However what I have established is that:
  • A viewer such as IrfanView is needed to see the comment as it doesn't appear on the property section when I right-click on the file
  • When I use other file formats, I still cannot see it under the properties of a file
  • Using Irfanview I cannot see the comments for '.png' and '.tiff
  • The comments will show up in GIMP for all three extensions
  • And lastly, .png offers even more flexibility in adding information to the file which is exactly what I might need for the tractability, I just need to figure an easy way of checking up the details on Windows

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by