Making a new attribute for image files

I want to add an attribute, “tags”, to all image files and query them based on that.
I did every step in the workshop explaining that sort of process, including reindex

mkindex -t string image:tags

reindex -f -r /boot

I’ve also tried adding GIF:tags specifically. Regardless of what I try, including copying files, querying tags doesn’t return any results. Am I missing something?

Works here. You must’ve taken a wrong turn somewhere… :slight_smile:
We’ll need more details, I think.

A quick overview:

  1. Add an extra attribute for the Image supertype, internal name e.g. “Media:tags”, type string
  2. “mkindex -t string Media:tags” on the volume with your images
  3. Open the folder with the images, show the attribute “Tags” (or how you named it in 1.)
  4. Edit the image name, TAB to jump to the “Tags” column and enter the tags
  5. Query for Images | Attributes | Tags for the entered tag

Edit: the alluded to workshop of the User Guide:
https://www.haiku-os.org/docs/userguide/en/workshop-filetypes+attributes.html

Huh, I didn’t know adding “Media:tags” was necessary. Videos are also “media”, right? Will this add “tags” to them too? I thought the internal name of images was just image.

Yeah, no, it still doesn’t work.

mkindex -t string Media:tags
reindex -f -r /boot

The first thing I did was go in the file type editor, add the attribute “tags” to images, and edit that attribute in the tracker.

So as a test, I added an entirely new file type. Maybe I missed some step, but I can’t even query for that type because it’s not one of the options. I’ve done this before successfully, but now it mysteriously doesn’t work.

If I can’t get this to work easily, the average user wont be able to. I’m not saying that to be egotistical, I’m saying it to be realistic.
example

It’s not strictly necessary, but without doing that in the FileTypes prefs, you won’t see the attribute under the “Image” item in the Attributes menu of Tracker windows that have images in the folder.

You decide how to name the attribute. I chose “Media” because I reckoned it would be applicable to other file types besides images. You can add any attribute to any file you like. If you want the attribute to appear under a filetype in Tracker’s Attributes menu, you’ll have to add it to the file type (e.g. video) in the FileTypes prefs.

That’s the supertype “image”. The subtypes like JPG is “image/jpeg”.
The “internal name” I mentioned is the internal name of the new attribute “Media:tags”. You definitely need that to create the similarly named index and it’s the name of the attribute you add to your (image) files.

That wasn’t my experience. I was able to edit them in the tracker without doing that. Just by adding image:tags

Can you screenshoot the FileTypes preferences showing your new application/test type?

It’s definitely something for advanced users. If you have concrete enhancements of the procedure, patches are welcome. :slight_smile:

Weird. How would Tracker know how to label the attribute column etc.?

I don’t know. It does though without adding any “Media:” anything in the index. The workshop doesn’t mention anything like that either.
like

It does though. In the example it’s “DVDdb:title” etc.
We should try not to mix two topics. a) adding an extra attribute to an existing file type, b) creating a new file type.

For your new application/test filetype, you’ll need to restart Tracker to find the new entry in the Find panel.

Is quitting the tracker the same as restarting it? That’s what I’m trying on a clean install and it’s not working on it either. Also, I don’t have to add anything at all to the index for the option to appear in tracker. I assume this is because having an attribute and indexing it are different.

Tracker gets auto-restarted by the launch_daemon, so yes.

Not sure what’s going wrong on your end. I can replicate what’s in the attributes workshop, basically what I wrote in my first comment here, and it works…

Yes. adding to the index is only needed for querying it.

Are you using the nightly build? Or Beta 3? I’m using Beta 3.
By the way, I did do that workshop before. What I’m doing now is for own purposes.

Nightly 64bit, but I would be very surprised if attributes/index/querying don’t work with Beta3 and we havent noticed that.

Edit: I think it’s because every file type must have a name and description and neither can be omitted

Edit2: I forgot to set an internal name. Assumed internal names were generated automatically.

It’s still not returning any results after reindexing and restarting tracker.

I’ve gotten it to work. Tracker doesn’t automatically remove dead attributes which have been renamed or deleted. In fact, I don’t think there is a way to remove dead attributes.

edit:

Moving a column out of a window, is a fast way to get rid of columns you don’t need.

They are both optional. If you don’t set a “Name”, there’ll be no helpful text in Tracker’s “Kind” column.
The “Description” appears not to be visible in the system currently, and seems to be just information when working with the file type in the FileTypes preferences.

Tracker doesn’t remove your attributes when you changed or deleted them in the FileTypes preferences. And that’s good. Imagine you had a partition of nicely tagged images, then e.g. re-installed a fresh Haiku without those attributes set up. We wouldn’t want Tracker to remove all those tags. :slight_smile:

You can remove attributes with the rmattr command in Terminal.

That’s of course just the display of those attributes in the current Tracker window. It doesn’t remove the actual attribute or its data from the files in that folder.

1 Like

Have you tried imagemagick to set attributes?

MagickImage.SetAttribute, ImageMagick C# (CSharp) Code Examples - HotExamples
Custom Properties (Attributes) - ImageMagick

I should add this option into my imagemagickGUI

1 Like

I haven’t. I’ve gotten it to work now, so using an external program isn’t necessary.

1 Like