We have added import plugins in the meantime (for example the IIIF manifest plugin), but this plugin hook is only for creating new items, not changing existing ones. We have also been working with a ‘processing’ plugin hook that can change existing items – we have not released it yet, but it’s probably not perfect for your use case either (with that plugin, you would have to select the items in the UI and then trigger the plugin).
If you’re managing the tags outside of Tropy and each tag can be associated with a photo’s checksum, updating the project database directly could be an option as well. Compared to metadata, manipulating tags in the database should be relatively easy. There’s also an HTTP API that you could use. Here are some quick examples to illustrate how this could work. If you let us know which approach sounds most promising we can go into more detail.
You can use these queries to explore tags directly in the project database (using the project file “tmp/gamma.tropy/project.tpy” as an example:
# All tags
sqlite3 tmp/gamma.tropy/project.tpy "select * from tags"
# All photos (by checksum) and their associated tags
sqlite3 tmp/gamma.tropy/project.tpy "select checksum, name from tags join taggings using (tag_id) join photos on (item_id = taggings.id) order by checksum
You can see the project db schema here. The relevant tables are photos
, tags
and taggings
which links tags
and items
.
Alternatively, you can use an HTTP API to access the current project. To enable the API, you need to open the Tropy user data folder (via the help menu), then quit Tropy and then edit the state.json
file, setting the api
property to true
. When you start Tropy next, the active project can be accessed via the API.
# To test if the API works you can print the version
curl http://localhost:2019/version
# To list all tags
curl http://localhost:2019/project/tags
# If you have `jq` installed you can improve the output like this:
curl http://localhost:2019/project/tags | jq .
We have no API documentation unfortunately, but you can see all the available endpoints here. Using the API it’s possible to create tags and add or remove tags from existing items.
I think this sums up the current options: there’s an import hook to create new items using JSON input. To change existing items you can use either the API or edit the database directly; alternatively you could look into using the processing plugin hook (but we’re still finalizing that one).