Imwrite JPG with comments
4 次查看(过去 30 天)
显示 更早的评论
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/202899/image.jpeg)
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 个评论
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
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
2019-2-10
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 个评论
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)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!