(Command line) Punctuation in JPEG comments
Added by Steve Wright almost 12 years ago
Is there some way to put such things as double-quotation marks and exclamation points in JPEG comments using exiv2 on the command line? The ways I've tried so far have either run up against BASH history-expansion errors (the latter) or "Unable to open file" errors (the former, from exiv2 itself). I've also tried to escape double-quotes, but as these are apparently needed for exiv2 to know where the comment string ends, this approach only gives me a "hung prompt."
I suppose I could specify my histchars in .bashrc or .bash_profile, and exclude the bang, but that still leaves the matter of double-quotes (I often like to use comments and IPTC Captions to "put words in folks' mouths," so to speak).
I've also considered the option of making an interactive script or small executable that would ask for the file name and write the comment line as it was input by the user (me). A script might do the job, except I may run into the same "hung prompt" issue as I do on the command line. The small executable might work better; I could certainly compile it linking it to the exiv2 files necessary for running it. But then I run up against the fact that, darn-it-all, I haven't enough knowledge of C++ to know how to write the original precompiled code.
Looks like I'll need help with this one.
Silversleeves
Replies (9)
RE: (Command line) Punctuation in JPEG comments - Added by Andreas Huggel almost 12 years ago
Just use single-quotes instead of double-quotes as the outermost quotes. Bash leaves everything inside of single quotes alone but interprets text enclosed in double quotes (roughly, for what it does exactly see man bash). Alternatively, use a command file - that is not parsed by bash.
Andreas
RE: (Command line) Punctuation in JPEG comments - Added by Steve Wright almost 12 years ago
Andreas Huggel wrote:
Just use single-quotes instead of double-quotes as the outermost quotes. Bash leaves everything inside of single quotes alone but interprets text enclosed in double quotes (roughly, for what it does exactly see man bash). Alternatively, use a command file - that is not parsed by bash.
Andreas
I seriously forgot about command files. Comes from looking up silly things like flip and resize on ImageMagick sites.
Still, I may challenge myself yet and learn-myself-up on writing interactive C for the command line. May come in handy for a few little things my brother (who's personal laptop is 100% Linux) and I might do in the future.
Thanks again for the speedy reply.
S.
RE: (Command line) Punctuation in JPEG comments - Added by Steve Wright almost 12 years ago
Andreas Huggel wrote:
Alternatively, use a command file - that is not parsed by bash.
Andreas
And what would the syntax for that be in a command file? I'm familiar with how to add EXIF, IPTC and XMP tags, but this isn't any one of those, on the face of it. I've looked through the examples, and the best I can come up with is to
exvi2 -c file.txt file9.jpg
Would I be correct in that assumption?
S.
RE: (Command line) Punctuation in JPEG comments - Added by Andreas Huggel almost 12 years ago
Oops, my previous reply was too quick, you're right, there is no command to set the JPEG comment using a command file. But the other method works:
$ exiv2 -c'A "comment"!' exiv2-empty.jpg $ exiv2 -pc exiv2-empty.jpg A "comment"!
Andreas
RE: (Command line) Punctuation in JPEG comments - Added by Steve Wright almost 12 years ago
Andreas,
A comment formatted like your command example worked perfectly. I've almost puzzled out how to get exclamation points past the BASH shell on my system without getting a "hanging prompt." Your example (above) gave me a clue: couch everything in single and double quotes, in the order "single-double-(comment)-double-single." This works from a command file, but I don't quite have the hang of quoting my way around the history-expansion check on the command line.
Just as an example, to help anyone who might see this thread in the future, here's my command-line input creating an EXIF Description in a file:
exiv2 -M'add Exif.Image.ImageDescription Ascii '"Cassie only had three more miles to go to finish the marathon. She was already tired, though, and started dreaming of hamburgers!"' r617-017.jpg
And here's the C&P from the EXIF Info window of a GUI imageviewer I often use:
ImageDescription - Cassie only had three more miles to go to finish the marathon. She was already tired, though, and started dreaming of hamburgers!
As you can see, the exclamation point clears the checker, but I lose the double-quotes in the process.
Any suggestions?
S.
RE: (Command line) Punctuation in JPEG comments - Added by Andreas Huggel almost 12 years ago
I think for this you need a command file. Something like this, if I understand correctly what you're trying to do:
$ cat cmd.txt set Exif.Image.ImageDescription '"A comment!"' $ exiv2 -m cmd.txt exiv2-empty.jpg $ exiv2 -pa exiv2-empty.jpg Exif.Image.ImageDescription Ascii 13 "A comment!"
Andreas
RE: (Command line) Punctuation in JPEG comments - Added by Steve Wright almost 12 years ago
Andreas,
You have it right on the money. And if having to resort to command files or even shell scripts to get past the bash history checker is what's necessary, I can certainly do that.
Looking at change logs and old bugs and issues on this forum, I noticed that there used to be a command syntax for importing JPEG comments from text files. On the whole, I think it's better the way it is. Much easier to brainstorm a comment or "stamp" one in at the last minute, such as just before file "X2.JPG" is sent as an email attachment.
I saw, in a recent patch to the "main" exiv2 code, a provision was made for line-breaks and "special characters" in comments. Reading further I noticed it affected two kinds of comment fields: one for EXIF and this, the JPEG comment header. Just my bad luck I didn't start this thread before the patch was written or you may have been able to include broader punctuation support in the latter field.
S.
RE: (Command line) Punctuation in JPEG comments - Added by Andreas Huggel almost 12 years ago
Well, just specify what you need and chances are it can be added. In fact, if you look at the source code, you'll probably find it's faster to add it yourself and send in a patch.
However, the whole issue in this thread here is only about enclosing quotes, i.e., comments where the first and the last character are both either a single quote character (') or a double quote character ("). Those are stripped by both the shell (if the command is on the command line) and exiv2 (in any case - a questionable 'feature' maybe). A possible work-around is above, any other punctuation as well as quotes within the text are not an issue AFAICS.
Andreas
RE: (Command line) Punctuation in JPEG comments - Added by Sharlyn Harville almost 4 years ago
Photoshop records have default record expansion as .PSD, which remains for "Photoshop Document." A PSD record stores a picture with help for most imaging alternatives accessible in Photoshop. These incorporate layers with covers, straightforwardness, content, alpha channels and spot hues, cutting ways, and duotone settings. This is as opposed to numerous other record positions (e.g. .JPG or .GIF) that confine substance to give streamlined, unsurprising usefulness. A PSD document has a greatest stature and width of 30,000 pixels, and a length point of confinement of 3 Gigabytes. <a href="http://www.google.com/">google</a>