I'm trying to save my images with some comments like so
imwrite(imageData, '/MATLAB Drive/ArtScraper/out_img/Ukiyo-e_1549412662/592fa615edc2c933948514b7.jpg' 'Comment', {['Title: ' nStyle(jj).title '; Author: ' nStyle(jj).artistName '; Year: ' nStyle(jj).year]});
To check if the comments were written correctly I used imfinfo
struct with fields:
Filename: '/MATLAB Drive/ArtScraper/out_img/Ukiyo-e_1549412662/592fa615edc2c933948514b7.jpg'
FileModDate: '06-Feb-2019 00:36:24'
FileSize: 37242
Format: 'jpg'
FormatVersion: ''
Width: 327
Height: 520
BitDepth: 24
ColorType: 'truecolor'
FormatSignature: ''
NumberOfSamples: 3
CodingMethod: 'Huffman'
CodingProcess: 'Sequential'
Comment: {'Title: Ichikawa Monnosuke Ii as Date No Yosaku in the Kabuki Play "koi-nyōbō Somewake Tazuna"; Author: Tōshūsai Sharaku; Year: 1794'}
Now I was under the assumption that image now contains comments if I'd check the properties but sadly that wasn't the case
So I'm either doing something wrong with writing comments to my images or the comments are only visible in Matlab and I misunderstood the documentation. Either way, I still need to add this additional information to my files.

댓글 수: 9

YT
YT 2019년 2월 10일
[tumbleweed.jpg]
Image Analyst
Image Analyst 2019년 2월 10일
That is not an image attachment.
YT
YT 2019년 2월 10일
It was an (humorous) attempt to get someones attention. Well I still haven't found out how to add "visible" comments to images, so every suggestion is welcome.
Walter Roberson
Walter Roberson 2019년 2월 10일
I dug into the code and found that 'Comment' is writing to JFIF tag COM, hex tag FFFE . This is not EXIF, this appears to be basic JFIF.
It looks to me as if you are using Windows Explorer to examine the information. I do not know why Windows Explorer is not picking up the information to place in Comments.
My own testing with MacOS and Preview program showed that Preview does not find the information either.
YT
YT 2019년 2월 11일
@Walter Roberson - Well I'm not that familiar with EXIF/JFIF but it would make sense if Windows Explorer (or MacOS for that matter) only recognizes EXIF data and not JFIF?
By the way, I also tried it the otherway, by manually adding a comment (HELLO WORLD) using Windows Explorer and then checking if that comment was visible using imfinfo
x =
struct with fields:
Filename: '/MATLAB Drive/test-image-new.jpg'
FileModDate: '11-Feb-2019 18:05:44'
FileSize: 10047
Format: 'jpg'
FormatVersion: ''
Width: 214
Height: 194
BitDepth: 24
ColorType: 'truecolor'
FormatSignature: ''
NumberOfSamples: 3
CodingMethod: 'Huffman'
CodingProcess: 'Sequential'
Comment: {}
DigitalCamera: [1×1 struct] %contains only double data
UnknownTags: [2×1 struct] %contains only double data
According to the documentation, imfinfo is able to read EXIF tags... so why not the comments?
Walter Roberson
Walter Roberson 2019년 2월 11일
The DigitalCamera or UnknownTags structure might contain the data. Try applying char() to the tag content .
YT
YT 2019년 2월 12일
Well you're right that the UnknownTags contains the comment data but it's annoying that for some reason it's filled with spaces. Also, I'm not sure what the other tag is supposed to be.
>> tmp = struct2cell(x.UnknownTags);
>> char(tmp{3,1})
ans =
'H E L L O W O R L D '
>> char(tmp{3,2}) %tmp{3,2} = [28 234 0 0 0 8 0 ... 0] (1x2060)
ans =
'ê ' %cut off most spaces to fit on screen
I got a bit sidetracked here, but there's still no solid explanation to why the comments written using imwrite are not showing up outside Matlab.
Walter Roberson
Walter Roberson 2019년 2월 12일
28 234 is 1c ea in hex. If we assume Little Endian then 0Xea1c which appears to be a Microsoft patented (!!) WindowsPadding tag. Basically it is space reserved in the file in anticipation that you might add more tags.
Walter Roberson
Walter Roberson 2019년 2월 12일
My guess is that the comments were stored as UTF16, probably little endian. Do the numeric values alternate 32 and something useful or do they alternate 0 and something useful like would be the case for utf16?

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

답변 (1개)

Rik
Rik 2019년 2월 10일

1 개 추천

For my FEX submission PhotoAnnotation I bypass the built-in tools in favor of exiftool.
URL=['http://web.archive.org/web/20170820125224if_/',...
'https://www.sno.phy.queensu.ca/~phil/exiftool/exiftool-10.61.zip'];
urlwrite(URL,[folderpath 'exiftool.zip']);
You can either canibalize some functions I use in my GUI, or go through its documentation yourself. (I have no clue anymore how it works outside of my specific work flow, which I would say is both the upside and the downside of modular programming.)

댓글 수: 2

YT
YT 2019년 2월 10일
Well exiftool seems easy to use (from the lines I've seen in your function) but I don't really want to use another tool besides Matlab.
Rik
Rik 2019년 2월 11일
Of course that is your decision to make. At least you have a backup method in case you don't get the pure-Matlab method to work.
For me exiftool was the better fit, as I wanted to use the same function in Octave as well, and the comment writing is not (yet?) implemented. (Or at least in the version I was using when writing PA)

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

카테고리

도움말 센터File Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

질문:

YT
2019년 2월 6일

댓글:

2019년 2월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by