Is there a way to modify the current caption?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
ooker
Posts: 22
Joined: 2014-07-24T10:32:57-07:00
Authentication code: 6789

Is there a way to modify the current caption?

Post by ooker »

Say I have a picture with caption "A", I want to change it to "A and B" without knowing A? The only way I know so far is

Code: Select all

old_caption=`identify -verbose file |grep caption|cut -c 14-`
then edit the old caption. Is there any better solution?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Is there a way to modify the current caption?

Post by fmw42 »

Do you mean comment in the Properties section? If so, you can use the %c string format at http://www.imagemagick.org/script/escape.php

comment=`convert image -format "%c" info:`

to retrieve the comment and store it in a variable. Then change the variable to add more.
ooker
Posts: 22
Joined: 2014-07-24T10:32:57-07:00
Authentication code: 6789

Re: Is there a way to modify the current caption?

Post by ooker »

Although it's still an indirect solution, your command is more intuitive. Thank you.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Is there a way to modify the current caption?

Post by fmw42 »

If you do not care what was there already, you can just write over the old comment. Otherwise, I do not believe there is any more direct way to add to a comment. But the IM developers would have to comment to confirm that statement. Perhaps there is another way that I do not know about.

see
http://www.imagemagick.org/script/comma ... hp#comment

But I believe by modify, it really means replace and not add to.
Post Reply