📜 ⬆️ ⬇️

Search for files by tags in XMP / IPTC and operations with the found

At first, it may seem that the post about “one more media player”, and now the panicky habrovchanin is running away with bulging eyes, throwing minuses at people, animals and programmers. Well, in general, yes, a post about this. But. There is, in my opinion, one significant But, about which below.

Search for files by tags in XMP / IPTC and operations with the found

Everyone loves to take pictures of cats. Yes. Approved. Some even make photo albums with them. Someone even bothers with the tagging of these photos. And absolutely one or two times in their life for these tags they are looking for these tags.

My case is very bad. Yes, I really love to take pictures, and not only cats. Therefore, the photographs, moreover, already selected, at the moment have accumulated about 15,000. To all this, I am a down-and-coming perfectionist-pedant and love when everything (well, almost everything) is in order. I tagged photos, looking for them by these tags and not averse to making several thematic albums.
')

AND…


There are many special programs that work with metadata. Starting with the trumpet exiv2 and ending with various viewers and huge combines with preference and combineers. Some programs simply show cats, some allow you to sculpt tags on these cats, some - look for these cats by these tags, some - also edit these tags, and some organize cats into albums.

But. I did not find (although, perhaps, badly searched for) a single solution that would not only provide all these possibilities, but also logically connected them. You can find pictures by tags, but it is impossible to package these tags by one or another criteria. Or you can add a list of tags to photos in any directory, but all at once and categorically. There are a lot of "organizers", but as a rule, with their own bicycle way of organizing photos, and not at least some kind of universal and regular. Not to mention the associated selection criteria.

Sawing


In general, in this zoo I felt sad, and I decided to make something of my own. With combineers, naturally. First on your favorite Perl. Well, here I have such a fad. But, I repeat, only from the beginning. Then I - ta-dam! - rewrote the prog on C. But more on everything below, but for now - right away the links:


What happened and how to live with it


So what can you do with these unhappy tags? In general, add, delete, change and compare (search is essentially a comparison with the template). Moreover, the comparison can be quite complicated.

Search


Many programs allow you to search for files by tags with logical AND , OR, and NOT . But, again, it may look bad, but usually the search is possible either only with AND , or only with OR , or only with NOT . And for some reason, I sometimes have the obsession to find all the photos with people in nature, who commit either thrash or frenzy, but not at the festival. Total condition: (people AND nature) AND (trash OR frenzy) AND (NOT the festival) . The input fields in the program are added, the functionality is implemented, the photos are correct.

ds-findbytags

searching results


By the way, are "where"? The program, having found photos that meet the conditions, creates in the directory in which it is launched a temporary subdirectory with a random abracadable name, where it stores symbolic links to the found photos, with the same abrasive names. Then the viewer is opened, to which the path to this subdirectory is passed as an argument. Which viewer? I love “Geeqie”, so by default it opens. But in the key of the -l program, you can specify any other, or “ no ”, meaning that you don’t need to open anything at all. After a long admiring of the found photo galleries and closing the viewer, the temporary subdirectory with links is deleted (if not indicated otherwise, see below).

Editing


Fine. What about add, delete and replace? The so-called typical tag editing case. There are no problems with editing; Added to the program input fields " Add tags ", " Delete tags " and " Replace tags ." But what tags to edit? Does the idea of ​​the ability to edit tags of files found, actually, by their tags, suggest itself?

So, having found a bunch of photos of people in nature, koi make either thrash or frenzy, but not at the festival, I was horrified to find in this pile a lot of photos with me. And, as a rule, thrash, but not waste, is usually made. What could be the solution to the problem? The first is to avoid thrash and intoxication. Will not go. The second is to edit tags.

So, we set a new search in photos with the same conditions, but with the “ I favorite ” tag added in the “ AND ” field. Now, if you click on the “ Start ” button, there will be a part (and, unfortunately, a larger part) of all that ugliness found earlier. But before that, in the “ Add tags ” field we enter two tags : [intervened in the dream by interveners, do not show it to the wife] (in general, tags are separated by commas in the fields, since the tags themselves may well contain spaces). Also, in the field “ Delete tags ” we enter [people] , and in the field “ Replace tags ” - [thrash, fun, intoxication, holiday] (in the field “ Replace tags ” they are entered in pairs: “ thrash ” will be replaced by “ fun ”, and " waste " on " holiday ").

ds-findbytags

Everything. We zhmakay button " Start ", and the photos get well, at least some justifying, softening signs. Well, useful. You can then compile family albums, selecting when searching for pictures with the tag " do not show the wife ", entered in the " And ".

Organization


And, by the way, about albums. In fact, we already have the principle of compiling albums - a logical search by tags. It remains to implement, in fact, the organization of the found photos in the "albums". And then I thought: I love bicycles, but motorcycles since the second world love more. Isn't it easier to simply save symbolic links to the found photos in certain directories? Simpler. What is done.

To save the links, you must check the “ Save links to: ” box, select the necessary directory next to it and optionally check the “ Save namesbox . With the preservation of names you need to be careful. If you are sure that all the names of your photo files are unique (for example, according to the shooting time, like mine), then it makes sense - symbolic links will have the same names as the original files. But if the file names can be repeated, then obviously you should not put a daw.

ds-findbytags

After practicing the program, admiring the photos in the viewer and closing it, the catalog with symbolic links is not deleted, but remains for posterity.

Tag Tree


Well, to the heap, so as not to keep in my head all the tags that were invented and put in their time, I screwed their tree to the right. I already wrote that I love “Geeqie”, so call me, but this tree is formed from a Geeqie-evs XML-file with settings, which, among other things, stores the tree of tags created in the program. By default, the program searches for this file here: ~/.config/geeqie/geeqierc.xml , but with the -t program key, you can specify the path to your own XML file of the tag tree. The only thing is that this tree in it must be described according to the rules of the Geeqie-ev configuration.

Little about implementations


The program can work both in the CLI interface (by default) and in the GUI - GTK + 2 (if the -g option is specified). In dependencies - exiv2. Plus, for the C version, libxml2-dev. Well, for the GUI, the stump is clear, gtk2.

With the Perl-version, I hope everything is clear - you just run the pearl-barley script with the necessary keys and rejoice. Perl-version in Russian only.

C-version in English with Russian localization. It works twice a half faster than the barley version, and eats one and a half times less memory. The C version needs to be compiled and, if desired, installed. Everything is as usual:

Installation


 cd ~/sources (      ) git clone https://github.com/assador/ds-findbytags.git cd ds-findbytags make sudo make install 

Update


Go to the same directory with the programs:

 cd ~/sources/ds-findbytags git pull make sudo make install 

Uninstall


Not uninstall sorts, but uninstall. Go to the same directory with the programs:

 cd ~/sources/ds-findbytags sudo make uninstall 

The install rule makes the smallest: copies the ds-findbytags to /usr/local/bin/ and the Russian localization file ds-findbytags.mo to /usr/share/locale/ru/LC_MESSAGES/ . The uninstall rule uninstall them from there. Everything.

Works under the Nix. I haven’t yet checked on other platforms, but there should be no particular problems (assuming, of course, GTK + 2 installed and some doping).

In general, here. I am pleased and eager to share this free software (GNU GPL v3), God forgive me, with the world, at the same time very much hoping for constructive criticism, comments and, what the hell is joking, forks and / or participation in the project.

Source: https://habr.com/ru/post/339642/


All Articles