Page 1 of 1

Importing function for mass categorization

Posted: Tue Jul 07, 2015 6:01 am
by MrSwordFish
Long story short, an objective of mine would be very much facilitated if I could automate the assignment of categories to an image and apply this to thousands of images. I have no found such a feature in the options, but I may have missed it, if I have, please in form me. Let me describe what I would like to do... (firstly I would like to note how niche and specialized this request is, but surely other people out there have walked similar roads)


The way I imagine this feature, I declare that I wish to import an image of folder containing many images, which bring me to a wizard or a panel. I find and select from a list all delimiters of interest (common examples would be ' ', '_', '+', etc). There could be a list of common delimiters, or let the user input one. XnView now scans the folder/images and processes the string of their filenames. All images are assigned to be of the category with the delimiters listed. Example:

I declare the delimiter to be '_'
XnView scans an image called 20150703_books_library_plants_table.png
XnView could automatically assign the categories of 20150703, books, library, plants.

This feature would enable importing collections of photos that are already 'tagged' or categorized via filename (which, to may dismay, is something outside of my control that I have to deal with).

If things seem to make sense so far, hear me out. I would also make this import feature have a blacklist and a whitelist feature. A user can checkmark if they wish to use a whitelist, a blacklist or neither. Expanding on the example, if I know several pictures had 'books' in their filename and I desired to get rid of that category in the automation process, I can simply add it to the blacklist. Images will not receive that category ie: resulting in the categories 20150703, library, plants for the image. Similarly for the whitely except whitelisted strings are the only categories created.

Another potentially useful expansion would be to exclude all strings of a certain length. Why is this useful? Well, suppose the images have dates, or id codes(ie: hashes, that are no longer relevant), these could be filtered out. Add the value '8' to this exclusion list and voila, all dates of the form yyyy/mm/dd or dd/mm/yyyy will not appear in the categories. In a similar line of thinking one could extrapolate to strings > n or < n...

One could also easily imagine an export feature which does this opposite of this to move/rename collections of images for use outside of the XnView database... though I would rather do everything in XnView so I don't need this :D

Please let me know if my idea is really dumb, already implemented and somehow I missed it, or something about it is unclear. Also, feel free to relabel anything in an actual implementation as I will admit that I haven't pondered on this for a long time.

Thanks for reading

Re: Importing function for mass categorization

Posted: Thu Oct 29, 2015 4:51 pm
by orbspider
Hi, my quick thoughts..

1. renaming your actual files as to indicate what categories they belong to would seem time consuming and tedious to me- you really do that? eg, even for 300 pics per folder?
2. it's MUCH faster and more efficient just to name your files generally, ie, "plants_1503##", and then multi-select files and assign categories to them just with a few clicks in the side panel, isn't it?
3. once the auto category assigning during "import" sets the wrong categories you will be having fun finding those.

Re: Importing function for mass categorization

Posted: Thu Oct 29, 2015 10:52 pm
by Erixx haxx
Hello,
I had made a similar request here:
http://newsgroup.xnview.com/viewtopic.php?f=60&t=32052

This would allow you to pull any string from the File-Name/Folder-Name and apply to the photo's keyword, or tags.
You would need to learn Regex, but that's pretty simple.

Exif-tool does this, but requires you to use the cmd.prompt. Time consuming and you can't have any typos.
XnviewMp already has Exif-tool embeded to read the meta-data.

At the very least it would be nice to be able and use other vars beside $foldername/$filename. Keywords are almost never the whole file-name, but parts of it like you stated.

Re: Importing function for mass categorization

Posted: Sat Oct 31, 2015 9:02 am
by CameronD
Erixx haxx wrote:...
Exif-tool does this, but requires you to use the cmd.prompt. Time consuming and you can't have any typos....
It is a lot faster and simpler than you might think. exiftool can take a csv file to automate the import.

MrSwordFish's example was .PNG format, so I will assume that. The command:

Code: Select all

exiftool  -IPTC:keywords -XMP-dc:Subject *.png
will list all the existing IPTC and XMP keywords in the images.
Just use this as a test, in case you have any files you need to get out of the way, and use it as a test at the end.

There is no GUI software I know of that warns you if the IPTC and XMP keywords are different, but it will cause later headaches if they are different. So I always use exiftool to check.

1. Create a Template

Code: Select all

exiftool  -IPTC:keywords -XMP-dc:Subject -csv *.png> filelist.csv
This will generate the starting point for the import, and, importantly, give you the correct heading line.
Actually, I just realised that if you have zero files with keywords in then it will just generate a list of filenames and you will need to insert the header names as in the example below.

2. Create the import data file
Open in excel, or any text editor that you are adept with. You need to copy the filenames into Keyword column, and remove the bits that are not keywords. Leave the '_' separator in place - you can simply tell exiftool that that is the separator.
Duplicate the Keywords column under Subject
So for your example the first two lines would be

Code: Select all

SourceFile,Keywords,Subject
./20150703_books_library_plants_table.png,20150703_books_library_plants,20150703_books_library_plants
3. Import the new keywords
Save your file as newlist.csv and run...

Code: Select all

exiftool -sep  _  -csv=newlist.csv  *.png
This produces some warnings about creating a non-standard exif format, so you might want to check the results thoroughly, with other software you might use on the images.

This has also thrown up another bug in XnViewMP (V0.76.1). I will report it separately. You might need to "update catalog from files" in xnviewMP.