Text inside image file

조회 수: 6 (최근 30일)
Valeriy
Valeriy 2019년 12월 19일
댓글: Valeriy 2019년 12월 26일
Many formats of image files like jpg, png, tiff enable to read/write inside binary file information some comments, captions (so called IPTC data), EXIF data. They can accesible, for example, by XnView viewer, by Edit\Metadata\Edit IPTC data\ or by <Ctrl i> key combination.
It would be very useful and convenient to read/write such fields from Matlab to keep there some service information deals with image processing or parameters of image acquisiton.
Searching of Matlab answers and file exchange shows only possibility to read EXIF data or putting comments, annotation directly into image of such image file.
Is it possible and how is it possible to operate with such fields from Matlab?
Thank you

채택된 답변

Walter Roberson
Walter Roberson 2019년 12월 19일
MATLAB only permits reading EXIF, and only for some image formats.
There is a File Exchange contribution for MS Windows that can invoke an external .exe to write EXIF information.
EXIF-like information can be written into TIFF files if you use the Tiff() class interface and set the appropriate tag fields. It is not all that convenient to do so, but it can be done.
Those are the only things that are available.
  댓글 수: 5
Walter Roberson
Walter Roberson 2019년 12월 24일
EXIF effectively doesn't work for any of the common image formats except for JPEG and TIFF, and the EXIF wikipedia page explains why it is less than ideal in practice (data pointers are only relative, so you have to rebuild the pointers every time you modify the size of anything; encrypted private tags are used by some manufacturers to lock you into their eco-system; cameras / instruments do not have full EXIF processing and so moving an adjusted image back to the device is often incompatible.)
Valeriy
Valeriy 2019년 12월 26일
Dears Walter Robertson, Image Analyst,
At first, Merry Christmas!
Thanks for your help. As usually, reading Matlab Help is useful activity: after all I have found there answer on my question.
To write additional information into image file one can use:
imwrite(MatrVar,'FileName.jpg','Comment','This is my information'); % or
imwrite(MatrVar,'FileName.png','Comment','This is my information',...
'Author','Another information','Description','Additional information field'); % or
imwrite(MatrVar,'FileName.tif','Description','This is my information')
To read this information:
info = imfinfo('FileName.png'); % for example
MyFirstInformation = info.Comment;
AnotherInformation = info.Author; % etc.
Verification shows that it works.

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

추가 답변 (1개)

Image Analyst
Image Analyst 2019년 12월 19일

카테고리

Help CenterFile Exchange에서 Data Import and Export에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by