How To Write Custom Metadata to an Image Created by RMagick?

和自甴很熟 提交于 2019-12-07 17:12:12

问题


I'm creating composite images using Rmagick and want to include some specific info (author etc.) in the image file metadata, but can't find an obvious way to do this in the Rmagick docs, can this be done?

Sorry if this is an obvious one, but I've been searching around on both the Rmagick docs and here, but have only found a couple of items about orientation on SO, nothing about writing to metadata.

From the Rmagick Docs; Annotate seems to write the info on the image, which isn't what I want to do, I just want to store it in the metadata.

Comment looks promising but I'm not sure if this will be visible to other users when written?


回答1:


I was able to put in an EXIF XMP tag using the properties

image = Magick::Image.new(1, 1)    
image['comment'] = 'Testing'
image.write('test.png')

And than I can read the data using the exiftool:

exiftool test.png

...
Comment                         : Testing
...

Also, this site is useful for reading the EXIF image data.



来源:https://stackoverflow.com/questions/20901713/how-to-write-custom-metadata-to-an-image-created-by-rmagick

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!