Imagemagick添加和阅读评论

aka*_*ash 1 image imagemagick image-processing imagemagick-convert

我正在尝试使用imagemagick为图像添加注释并将其读回来添加注释我能做到

convert -comment "processed" original.jpg converted.jpg
Run Code Online (Sandbox Code Playgroud)

现在输出识别-verbose converted.jpeg

Properties:
comment: processed
date:create: 2017-05-17T12:22:36+06:00
date:modify: 2017-05-17T12:22:36+06:00
exif:ColorSpace: 1
exif:DateTime: 2017:02:04 12:21:36
exif:ExifImageLength: 1273
exif:ExifImageWidth: 900
exif:ExifOffset: 164
exif:Orientation: 1
exif:ResolutionUnit: 2
exif:Software: Adobe Photoshop CS5 Windows
exif:thumbnail:Compression: 6
exif:thumbnail:JPEGInterchangeFormat: 302
exif:thumbnail:JPEGInterchangeFormatLength: 3805
exif:thumbnail:ResolutionUnit: 2
exif:thumbnail:XResolution: 300/1
exif:thumbnail:YResolution: 300/1
Run Code Online (Sandbox Code Playgroud)

是否有更清晰的方式来回读除了以外的评论

identify -verbose converted.jpg | grep 'comment'
Run Code Online (Sandbox Code Playgroud)

Mar*_*ell 6

您可以像这样设置评论:

convert YourImage.jpg -set comment "fred" YourImage.jpg
Run Code Online (Sandbox Code Playgroud)

或者,最好使用mogrify以避免在此实例中重复自己:

mogrify -set comment "bill" YourImage.jpg
Run Code Online (Sandbox Code Playgroud)

并且该技术允许您一次执行多个图像:

mogrify -set comment "bill" *.jpg
Run Code Online (Sandbox Code Playgroud)

你只需要提取这样的评论:

identify -format %c YourImage.jpg 
fred
Run Code Online (Sandbox Code Playgroud)

im4java - 我不知道im4java,但只能猜测(基于)你会这样做:

 Info imageInfo = new Info(filename,true);
 System.out.println("Format: " + imageInfo.getImageComment());
Run Code Online (Sandbox Code Playgroud)

或者,也许你可以建立你自己ConvertCmd知道下面convert在命令行中的作品,如果你不知道如何使一个identify命令im4java:

convert -format %c YourImage.jpg info:
Run Code Online (Sandbox Code Playgroud)