0

Using Ubuntu 20.04, I can right-click on a jpg and select 'properties'. A window will open containing the tab 'image'. In this tab, there is a section called 'Keywords', the content of which I would like to receive from the terminal. I tried identify -verbose example.jpg, exif example.jpg, file example.jpg, but none of these approaches delivered the Keyword. Does anybody know how I could achieve this?

The goal of this is to create a folder for each keyword (if not existing already) and put each jpg in the respective folder. I want to write this in a shell script, which I will initiate using a personal command. Any suggestions on how to write this script are also more than welcome.

Thanks in advance!

Edit 8 Feb 21: Following this thread, I converted the the jpg to xmp. The metadata is available in the xmp. How can I read it out easily?

7
  • 1
    I just tried with identify -verbose and it showed the keywords. Feb 8 at 1:01
  • Once again, I read the output carefully and tried to grep, but did not succeed. identify --version outputs Version: ImageMagick 7.0.10-7 Q16 x86_64 2020-04-20 https://imagemagick.org. Which version do you use?
    – hyhno01
    Feb 8 at 8:41
  • My version ImageMagick 6.9.10-23. Feb 8 at 10:04
  • Could you show the grep command? The visual inspection may not be reliable. Feb 8 at 10:11
  • identify -version example.jpg | grep my_keyword
    – hyhno01
    Feb 8 at 10:26
2

Let's try this option, using the exiv2 tool:

sudo apt install exiv2

Then we can print the XMP data like this:

$ exiv2 -P X image.jpg
Xmp.iptc.Keywords        XmpBag      1      Some tag
-1

Hachoir metadata is a nice program to handle this kind of usecases

Installation

sudo apt-get install python-hachoir-metadata

Usage

hachoir-metadata example.jpg

Sample output

Metadata:
- Image width: 192 pixels
- Image height: 192 pixels
- Bits/pixel: 32
- Pixel format: RGBA
- Compression rate: 11.3x
- Creation date: 2020-08-10 22:57:38
- Compression: deflate
- Comment: date:create=2020-08-10T22:57:38+02:00
- Comment: date:modify=2020-08-10T22:57:38+02:00
- MIME type: image/png
- Endianness: Big endian

See the online documentation for more info.

2
  • 6
    Would you mind also showing how to use that tool to actually solve the given issue? Without that info, this is clearly just a "link-only" answer.
    – Kusalananda
    Feb 8 at 8:14
  • Informations added!
    – iaeiou
    Feb 11 at 10:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.