PhotoLab Keyword Tools

Summary

I’ve written several tools that add features to Photolab 8, and I’m providing these tools here.

  • importKeywords – Add keywords by importing from a text file.

  • exportKeywords – Export the current keyword structure to to a text file.

  • renameKeywords – Rename, move, and merge keywords.

  • findKeywordMatches – Find images matching logical expressions that can include AND, OR, and NOT operators.

PhotoLabTools-win.zip (36.3 MB)

I will update this OP so that it always points to the latest versions of my tools.

Target Audience

  • These tools only work for Windows users. While I can create versions that run on a Mac, I don’t have a Mac for testing. If you’d like to help develop Mac versions, contact me.

  • The tools are for people who use Photolab as their primary keywording tool. If you do your keyword tagging in some other tool, my tools may be of limited use.

Details

While I include a bit more details on the tools here, the tools come with a lot of options. The ZIP file containing the tools contains detailed documentation.

Some of these tools directly modify the Photolab database. You should exit Photolab and create a backup database before running those.

These tools are based on requests made for these features over the years. I’ve included pointers to some of these.

exportKeywords exports keywords in 3 formats: raw, Adobe, and HTML. The Adobe format should work with Adobe Bridge. Some other keywording tools use extended versions of the Adobe Bridge format, which included features that Photolab doesn’t support (categories, synonyms). You might be able to go from Photolab to one of these other tools, but not necessarily the other way.

importKeywords will modify the Photolab database to add keywords. It supports raw and Adobe Bridge formats. Existing keywords will be unaffected—the tool only adds keywords that don’t currently exist.

renameKeywords can rename a keyword, but it can also move it, and will merge keywords with the same name. If a keyword is being merged and has children, the children will themselves be either moved or merged depending on whether the matching child exists or not.

I saw a request for this feature recently, but can’t find it right now. I’ve wanted this tool for a while, and finally ran into a case where I really needed it, so I went ahead and wrote it.

findKeywordMatches can find images that match logical expressions (ones formed using ANDs, ORs, and NOTs). There is some pattern matching available. The pattern “^$” will match all images that have no keywords. The tool can search through all your indexed images, or just indexed images in one or more folders. The results can be output as a text or HTML file, or used to create a Photolab project. If you choose the HTML option, the tool will look for existing previews and thumbnails stored in Photolab’s cache folder.

Unlike external keyword tools with their own databases, findKeywordMatches can find keywords assigned to Photolab images, whether master copies or virtual copies. It will identify virtual copies in the generated results.

Here is a sample of the output. The first is the results of a keyword search as a project. The second is the same search, but stored in an HTML file.

Do you have DxO’s permission to use their trademark name?

Unfortunately, @Joanna, it looks like you didn’t do any research before posting your question.

I can’t find any evidence that DxO holds the trademark to the word “PhotoLab”. It claims trademarks only for “DxO” and “DxO Labs” (see their “legal” page).

“PHOTOLAB” is a trademark of London Drugs Limited, but that seems irrelevant. DxO uses the word PhotoLab without acknowledging this trademark (I searched through the PhotoLab 9 User Guide for all references to the word “trademark” and there is no mention of London Drugs) , so I assume I can as well. If London Drugs contacts me, then I’ll worry about making a change.

There are so many examples in commercial software, let alone freeware, video tutorials, written tutorials, etc., by which one might gauge whether or not this constitutes fair use (particularly, nominative fair use). I suspect fair use applies here, but admit it’s too murky a subject for me to be sure about.

Is “Keyword Tools for Photolab” better?

Interesting, but you implemented these as compiled executables, so there’s no way to review your work. I’m on a Mac and would be really curious to see how you did this.

I don’t plan to change the name at this time. PhotoLab is not a trademark owned by DxO.

Some clues for how this is done are at https://forum.dxo.com/t/some-database-querying-tools-that-you-might-find-useful/50526.

If you’d like Mac versions of the tools, and have experience with databases, send me a message. I need to have some of the Mac database fields reverse-engineered.

In general:

  • importKeywords and exportKeywords work by reading from and writing to the Keywords table. The getKeywordPaths SQL at the link above will give you an idea of how to read from the Keywords table (and there is a Mac version!)
  • renameKeywords is a more complicated story. As I said in the OP, I had to consider 16 different cases involving renaming, reparenting, and merging. This means that I have to both alter the Keywords table and the KeywordsItems table.
  • findKeywordMatches creates SQL to generate a giant table of all image-to-keyword pairs. The SQL for findImagesWithoutKeywords at the link above will give you a clue to how the query is done. The logical expression given to the tool is parsed and broken down into SQL queries which extract records from the giant table I mentioned and use INTERSECT, UNION, and EXCEPT to support AND, OR, and NOT. The pattern matching is done with the SQL “LIKE” operator.

If you think looking at the code would be a quick path to getting working Mac versions, understand that I can generate Mac versions—it’s just that they would then try to operate on a database with Windows table names and fields, which will not work. You’d still have to reverse-engineer the Mac database fields, and if you can do that, I can generate Mac versions.

The DxO Forum has once again outsmarted me. I cannot update the OP to keep it current. I’ve added some more tools. Here is the complete, updated version of the OP:

Summary

I’ve written several tools that add features to Photolab 8, and I’m providing these tools here.

  • importKeywords – Add keywords by importing from a text file.
  • exportKeywords – Export the current keyword structure to to a text file.
  • renameKeywords – Rename, move, and merge keywords.
  • findKeywordMatches – Find images matching logical expressions that can include AND, OR, and NOT operators.
  • cleanDatabase – Remove image entries from the PhotoLab database. These are images you don’t want in the database, e.g. images that no longer exist on disk.
  • incompleteHierarchies – Find (and optionally add) keywords needed to maintain complete hierarchies. A complete hierarchy is one where when a keyword is associated with an image, all its parent keywords are also associated with the image.
  • synchronizeKeywords – Check to make sure that the keywords in the database and the keywords stored in DOP or XMP files match. This tool can report any differences and, optionally, repair the DOP or XMP files to match.

Target Audience

  • These tools only work for Windows users. While I can create versions that run on a Mac, I don’t have a Mac for testing. If you’d like to help develop Mac versions, contact me.
  • The tools are for people who use Photolab as their primary keywording tool. If you do your keyword tagging in some other tool, my tools may be of limited use.

Details

While I include a bit more details on the tools here, the tools come with a lot of options. The ZIP file containing the tools contains detailed documentation (currently, 27 pages worth!).

Some of these tools directly modify the Photolab database. You should exit Photolab and create a backup database before running those.

Some of these tools are based on requests made for these features over the years. I’ve included pointers to some of these.

exportKeywords exports keywords in 3 formats: raw, Adobe, and HTML. The Adobe format should work with Adobe Bridge. Some other keywording tools use extended versions of the Adobe Bridge format, which included features that Photolab doesn’t support (categories, synonyms). You might be able to go from Photolab to one of these other tools, but not necessarily the other way.

importKeywords will modify the Photolab database to add keywords. It supports raw and Adobe Bridge formats. Existing keywords will be unaffected—the tool only adds keywords that don’t currently exist.

renameKeywords can rename a keyword, but it can also move it, and will merge keywords with the same name. If a keyword is being merged and has children, the children will themselves be either moved or merged depending on whether the matching child exists or not.

I saw a request for this feature recently, but can’t find it right now. I’ve wanted this tool for a while, and finally ran into a case where I really needed it, so I went ahead and wrote it.

findKeywordMatches can find images that match logical expressions (ones formed using ANDs, ORs, and NOTs). There is some pattern matching available. The pattern “^$” will match all images that have no keywords. The tool can search through all your indexed images, or just indexed images in one or more folders. The results can be output as a text or HTML file, or used to create a Photolab project. If you choose the HTML option, the tool will look for existing previews and thumbnails stored in Photolab’s cache folder.

Unlike external keyword tools with their own databases, findKeywordMatches can find keywords assigned to Photolab images, whether master copies or virtual copies. It will identify virtual copies in the generated results.

Here is a sample of the output. The first is the results of a keyword search as a project. The second is the same search, but stored in an HTML file.

cleanDatabase cleans out unwanted crud from the database. As with many of the tools, it can also just tell you about the crud in the database without changing anything. Some of the crud includes images that no longer exist on disk, images outside a given folder (everything I want PL to deal with is in one folder), and folders to which I export images. You can pick any or all of these.

incompleteHierarchies tells you about images containing keywords whose parent keywords aren’t also included. For instance, if an image is tagged with keywords A and A|B|C, then the tool will tell you that A|B is missing. It can also add A|B for you, if you like.

synchronizeKeywords is the most important tool in this collection of tools. It can report any differences between the keywords in the database and the keywords in the DOP or XMP files. On request, it can also repair the DOP and XMP files to match the database. This tool is useful if you use renameKeywords or incompleteHierarchies as those tools will only change the keywords in the database, leaving the DOP/XMP files unsynchronized.

The tool is smart enough to figure out which images have had keyword changes since the last time the tool was executed, so it doesn’t have to check every DOP/XMP file, only the associated with images that have changed. You can force it to check every image. You can also tell it to capture the current database state, make some changes in PL, and then ask it to report on the changes to the database with respect to the saved state.

I’ll answer a few Not Frequently Asked Questions (NFAQs) about my tools:

Do I care that no one is using these tools?

Not really. I figure I win no matter what happens:

  • I’m using the tools so it’s not really no one. And by writing the tools as though others were going to use them, I have better tools for myself. And great documentation!

  • If someone does use one or more tools without problems, that would be nice.

  • If someone uses a tool and finds a bug, then it helps me since I use the tools, and I’d sure like to know about any problems!

What about Mac users?

I have no ideological problems with supporting a Mac. Adapting the tools for a Mac might not even be that much work. The problem is that to do it successfully, the best option is for me to have a Mac with PhotoLab installed. But I’m not going to buy a Mac just to test out these tools.

Another option would be to work with a Mac user who strongly desires to use my tools. DM me if that description matches you.

Can I trust these tools?

Bravo for being suspicious!

First, can you trust me ? I’ve been on the forum since June 2019. You can review my posts and comments and decide if it sounds like I’ve been planning a long con.

Secondly, can you trust the tools? I’ve developed software professionally for over 40 years—I know what I’m doing. That said, I don’t trust any software, including my own. That’s what testing is for. I’ve done a lot of testing, but it’s just me and there’s a lot of code. Something that works on my system with my images might not work for you.

A lot of the tools can be used passively, without changing the database or any files. You can try out the tools and see what you think. Except for synchronizeKeywords, you fully try out all tools by just closing PhotoLab and making a copy of your database. When you’re done, close PhotoLab and put your copied database back.

What language are these tools written in?

They are written in PHP, of all things. PHP is mostly used for creating web pages, but it’s awfully handy for everything except GUI applications. PHP is a platform-independent language. I use a tool called phpacker to package the PHP code as Windows or Mac executables. Sadly, while I can generate the Mac executables today and they will run on a Mac, they won’t run correctly. There are a number of places where I would need to make the code platform-dependent.

1 Like