Author Topic: Danbooru Image tagger/renamer << NEED HELP!!!  (Read 6911 times)

Offline Kyrdua

  • Member
  • Posts: 7306
  • I have no idea what i'm doing.
    • Lunatic Red (A member there XD)
Danbooru Image tagger/renamer << NEED HELP!!!
« on: January 30, 2011, 05:14:37 AM »
I'm sure you peeps here who collect pics from *booru's know what i'm talking about.
it's a pain to manually rename/sort in folders all those hash-named pics you download off boorus.

so i was wondering if there's a program that can rename files by looking them up in danbooru?
basically like how winamp can connect to gracenote and tag/rename mp3s.

-- EDIT: hmm, maybe i should make it a habit to post in the wrong board on purpose to attract more posters next time....--
« Last Edit: January 31, 2011, 07:21:18 PM by Kyrdua »
 avatar/signature: Touhou | My Links | MyAnimelist

Offline sapsa

  • Member
  • Posts: 280
  • ^_^
Re: Danbooru Image tagger/renamer << NEED HELP!!!
« Reply #1 on: January 31, 2011, 11:45:18 PM »
I can't help you directly but will ask - to make some clarification.

mp3 tagger give good name for mp3 that you don't have name - like 01.mp3 change to lat say Metallica - Unforgiven.mp3

Basically Danbooru give file name from tags like: blong_cute_blueeyes _ecchi_dragon_somet hing_nevermind.jpg
So what name you need on jpg ?

Edit: just checked, it give name 0dssada9sd10210.jpg

Possible solution: the real tag is in ALT of IMG tag "<img alt=" if you have time you can try Greasemonkey for Firefox and script it for example: when you click on image it will save it with name from ALT.

Hope that help a little
~ Quality over Quantity ~
~ Standardization make life simpler ~

Offline Kyrdua

  • Member
  • Posts: 7306
  • I have no idea what i'm doing.
    • Lunatic Red (A member there XD)
Re: Danbooru Image tagger/renamer << NEED HELP!!!
« Reply #2 on: February 02, 2011, 09:50:16 AM »
I can't help you directly but will ask - to make some clarification.

mp3 tagger give good name for mp3 that you don't have name - like 01.mp3 change to lat say Metallica - Unforgiven.mp3

Basically Danbooru give file name from tags like: blong_cute_blueeyes _ecchi_dragon_somet hing_nevermind.jpg
So what name you need on jpg ?

Edit: just checked, it give name 0dssada9sd10210.jpg

this is exactly what i'm looking for. i don't mind if i have to do it via command line.


Quote
Possible solution: the real tag is in ALT of IMG tag "<img alt=" if you have time you can try Greasemonkey for Firefox and script it for example: when you click on image it will save it with name from ALT.

i need something to sort pics in my disk, not something that renames on the fly when i download them.
 avatar/signature: Touhou | My Links | MyAnimelist

Offline sapsa

  • Member
  • Posts: 280
  • ^_^
Re: Danbooru Image tagger/renamer << NEED HELP!!!
« Reply #3 on: February 02, 2011, 07:02:22 PM »
the fastes way then is put up apache + php server and use same script like on danbooru, that will collect data from your folder and "list" your tages.
~ Quality over Quantity ~
~ Standardization make life simpler ~

Offline Kyrdua

  • Member
  • Posts: 7306
  • I have no idea what i'm doing.
    • Lunatic Red (A member there XD)
Re: Danbooru Image tagger/renamer << NEED HELP!!!
« Reply #4 on: February 03, 2011, 03:56:53 AM »
you want me to set up a server so i can rename less more or less 700 MB of images? that's overkill dude.(don't have that big of a collection due to my tiny ass 56 GB HDD, and if i install LAMP...)
 avatar/signature: Touhou | My Links | MyAnimelist

Offline Xiong Chiamiov

  • Member
  • Posts: 3012
  • I'm gonna tolerate and love the SHIT out of you!
    • changedmy.name
Re: Danbooru Image tagger/renamer << NEED HELP!!!
« Reply #5 on: February 04, 2011, 12:21:09 AM »
A few months ago I hacked up a script to assign metadata to images based on their tags on Sankaku Complex's imageboard.  It's not a particularly clean design, but it works enough for me (which is why I haven't done anything more to it since then).  I've never run it on Windows, but I don't believe anything about it is OS-specific.

Once I started using a photo organizer that can filter by tags, I gave up browsing photos by folders entirely.  It's really quite a bit better.  If you want to move files around, though, that's easily done.

If you want to use it, you'll need to change the urls to point to your image board of choice.  You'll probably want to change the actual tags that get written, too, unless you're using Digikam.  See the comments on starting on line 44.  If you're not familiar with Python, I can make the desired modifications for you.

I've been pondering a photo organizer that is specifically designed for dealing with imageboards; if you're interested in this, let me know, and it might get pushed up my (rather long) priority queue.
Projects of interest: nagi | sheska | bdg
Posts made between 2009-05-09 and 2011-08-26 were in the capacity of staff.  Please read accordingly.

Offline Kyrdua

  • Member
  • Posts: 7306
  • I have no idea what i'm doing.
    • Lunatic Red (A member there XD)
Re: Danbooru Image tagger/renamer << NEED HELP!!!
« Reply #6 on: February 04, 2011, 12:56:53 AM »
^ hmm, never knew you had such project, might just be the thing i'm looking for.


I have picasa(windows)  ATM, will that do?
i don't quite get this dublin core thing though. i did a google but i don't think i got it yet.
so from what i gather here, this python script gets the tags from the booru i point it to, and exports it to a file(kinda like sfv or a database of sorts, i guess) containing the path/filenames of my images and their tags.
and from there, i can use stuff that can rename files based on a text/database/whatever file to sort/rename my images, is that right?


I think i can modify the script myself, i'll just post what i did in case it doesn't work, i also don't know how to run python scripts in windows since the last time i used python was on linux.
damn, wish PS CS3 and word 2007 worked perfectly in linux so i didn't have to switch back to win >_<.


and i think a photo organizer for imageboards is a great idea, definitely would be great if you'll make one.
 avatar/signature: Touhou | My Links | MyAnimelist

Offline Xiong Chiamiov

  • Member
  • Posts: 3012
  • I'm gonna tolerate and love the SHIT out of you!
    • changedmy.name
Re: Danbooru Image tagger/renamer << NEED HELP!!!
« Reply #7 on: February 04, 2011, 08:01:55 PM »
I have picasa(windows)  ATM, will that do?
Depends on your needs.

Tags are shown underneath pictures, if available.
(click to show/hide)

You need to enable that as the thumbnail caption, though.
(click to show/hide)

You can filter images by tag, and tags are auto-completed.  There doesn't seem to be a list of all tags, though.
(click to show/hide)

To compare, this is what Digikam's main window looks like (with the folder/etc. views on the left collapsed):
(click to show/hide)
As you can see, I can do some moderately complicated filtering of tags (either AND or OR them all together).  Personally, I'd like nested boolean expressions, but I'm rather demanding of my applications.

Quote
i don't quite get this dublin core thing though. i did a google but i don't think i got it yet.
so from what i gather here, this python script gets the tags from the booru i point it to, and exports it to a file(kinda like sfv or a database of sorts, i guess) containing the path/filenames of my images and their tags.
and from there, i can use stuff that can rename files based on a text/database/whatever file to sort/rename my images, is that right?
Not quite.  The tags that I was talking about are a form of metadata, which is information about a file contained in the file itself (ok, not strictly, but for this purpose).  The most common example is ID3 tags in your mp3s.  So, rather than having an artist associated with a piece of music, you have a series of descriptive "tags" associated with an image.

Unfortunately, there are a number of different formats for image metadata.  EXIF is one of the more common ones, and what sheska writes.  IPTC and XMP are the other common ones that I know of.

Even once we decide on a format to use for the metadata, we still have to decide on what to call the various fields.  Dublin Core is a small set of standard fields that are recognized by pretty much everything.  Most applications define additional fields in their own schema for any more specific needs.  Digikam has one called 'TagsList', which I used over the generic 'Subject' for reasons that aren't important here.

So, since Picasa doesn't recognize Digikam's 'TagsList', just change that part of the code to 'Subject' instead.

One thing to be aware of is that EXIF doesn't support PNGs or GIFs.

Quote
I think i can modify the script myself, i'll just post what i did in case it doesn't work, i also don't know how to run python scripts in windows since the last time i used python was on linux.
Just download Python (2.7, not 3.1) from python.org and install it, then run the script the same way you would in Linux (python sheska.py file1 file2 file3...).

Quote
and i think a photo organizer for imageboards is a great idea, definitely would be great if you'll make one.
I'll post here if I start working on it.
Projects of interest: nagi | sheska | bdg
Posts made between 2009-05-09 and 2011-08-26 were in the capacity of staff.  Please read accordingly.

Offline Kyrdua

  • Member
  • Posts: 7306
  • I have no idea what i'm doing.
    • Lunatic Red (A member there XD)
Re: Danbooru Image tagger/renamer << NEED HELP!!!
« Reply #8 on: February 05, 2011, 12:54:04 PM »
^ hmm, i can live with that. i'll just post if it works or a problem comes up.
 avatar/signature: Touhou | My Links | MyAnimelist

Offline Kyrdua

  • Member
  • Posts: 7306
  • I have no idea what i'm doing.
    • Lunatic Red (A member there XD)
Re: Danbooru Image tagger/renamer << NEED HELP!!!
« Reply #9 on: February 11, 2011, 02:23:03 PM »
<bump, pls merge>

OTL that's it, i give up, here's the command line error message

(click to show/hide)

here's the edited py file i'm using.

here are the file locations(dublincore included)
Code: [Select]
C:\Documents and Settings\<USER>\My Documents\Downloads\dublincore-1.0\dublincore.py
C:\Documents and Settings\<USER>\My Documents\Downloads\dublincore-1.0\dublincore-meta.rdf
C:\Documents and Settings\<USER>\My Documents\Downloads\dublincore-1.0\PKG-INFO
C:\Documents and Settings\<USER>\My Documents\Downloads\dublincore-1.0\setup.py

C:\Documents and Settings\<USER>\My Documents\Downloads\sheska.py
C:\Documents and Settings\<USER>\My Documents\Downloads\<hash>.jpg

 avatar/signature: Touhou | My Links | MyAnimelist

Offline Xiong Chiamiov

  • Member
  • Posts: 3012
  • I'm gonna tolerate and love the SHIT out of you!
    • changedmy.name
Re: Danbooru Image tagger/renamer << NEED HELP!!!
« Reply #10 on: February 18, 2011, 11:40:32 PM »
How are you calling the script?  How did you install ExifTool?

I downloaded the Windows binary of ExifTool, renamed it to exiftool.exe, and placed it in C:\WINDOWS.  I then ran the command "C:\path\to\sheska2.py bf23c60786ea0472eb8 0f001fa9451a3.jpg".  I did have to rename the function back to 'write_taglist', because otherwise a call somewhere else failed (and it was easier to change that).

This was on a pretty fresh Windows XP vm.

* I didn't do anything with a dublincore module or whatever you did; exiftool takes care of that.
* I didn't do anything with ExifTool_config, because those config changes aren't necessary when using the subject attribute.
* Only the last tag remained at the end.  That is, rather than appending tags to the subject, each one overwrote the previous.  I'll look into this.
Projects of interest: nagi | sheska | bdg
Posts made between 2009-05-09 and 2011-08-26 were in the capacity of staff.  Please read accordingly.

Offline Kyrdua

  • Member
  • Posts: 7306
  • I have no idea what i'm doing.
    • Lunatic Red (A member there XD)
Re: Danbooru Image tagger/renamer << NEED HELP!!!
« Reply #11 on: February 19, 2011, 03:55:33 PM »
How are you calling the script?  How did you install ExifTool?

I downloaded the Windows binary of ExifTool, renamed it to exiftool.exe, and placed it in C:\WINDOWS.  I then ran the command "C:\path\to\sheska2.py bf23c60786ea0472eb8 0f001fa9451a3.jpg".  I did have to rename the function back to 'write_taglist', because otherwise a call somewhere else failed (and it was easier to change that).

This was on a pretty fresh Windows XP vm.

* I didn't do anything with a dublincore module or whatever you did; exiftool takes care of that.
* I didn't do anything with ExifTool_config, because those config changes aren't necessary when using the subject attribute.
* Only the last tag remained at the end.  That is, rather than appending tags to the subject, each one overwrote the previous.  I'll look into this.

i'll wait for the updated script before trying again, then.
 avatar/signature: Touhou | My Links | MyAnimelist

Offline zetskee

  • Member
  • Posts: 23
Re: Danbooru Image tagger/renamer << NEED HELP!!!
« Reply #12 on: March 05, 2011, 05:42:00 AM »
<bump, pls merge>

OTL that's it, i give up, here's the command line error message

(click to show/hide)


I had the exact same error, except I didn't edit any files. Just turns out that exiftool wasn't in my path.

@Xiong Chiamiov - Thank you for this awesome script. It worked for me in Linux. It makes my 4000 pictures much easier to search through.

Offline Kyrdua

  • Member
  • Posts: 7306
  • I have no idea what i'm doing.
    • Lunatic Red (A member there XD)
Re: Danbooru Image tagger/renamer << NEED HELP!!!
« Reply #13 on: March 05, 2011, 05:56:48 AM »
oh shit, now that you mentioned it, does this work on live KDE CD's(e.g. opensuse/kubuntu)?
 avatar/signature: Touhou | My Links | MyAnimelist

Offline zetskee

  • Member
  • Posts: 23
Re: Danbooru Image tagger/renamer << NEED HELP!!!
« Reply #14 on: March 05, 2011, 01:04:56 PM »
I don't think that kubuntu/opensuse come with exiftool. I also tested it on Windows and it worked fine for me there too. I think the default exiftool name was something like ExifTool(-k).exe or something, just rename it to exiftool.exe and put it in C:\Windows and everything should work.

Offline Kyrdua

  • Member
  • Posts: 7306
  • I have no idea what i'm doing.
    • Lunatic Red (A member there XD)
Re: Danbooru Image tagger/renamer << NEED HELP!!!
« Reply #15 on: March 05, 2011, 03:03:17 PM »
^ >_>, i think that's obvious. i'll download exiftools first, naturally. BTW, what distro did you use? i don't wanna waste bandwidth.(even if linux torrents are pretty well seeded and download fast.)
 avatar/signature: Touhou | My Links | MyAnimelist

Offline Xiong Chiamiov

  • Member
  • Posts: 3012
  • I'm gonna tolerate and love the SHIT out of you!
    • changedmy.name
Re: Danbooru Image tagger/renamer << NEED HELP!!!
« Reply #16 on: March 05, 2011, 11:08:44 PM »
oh shit, now that you mentioned it, does this work on live KDE CD's(e.g. opensuse/kubuntu)?
You might have to install some packages.  Unfortunately, Ubuntu doesn't seem to package it, but you can just follow the instructions to install it manually.

@Xiong Chiamiov - Thank you for this awesome script. It worked for me in Linux. It makes my 4000 pictures much easier to search through.
I'm always glad to be of help.


I'm heading into dead week now (the week before finals), so I may not have a chance soon to look closer into the subject-tagging issue I mentioned previously.
Projects of interest: nagi | sheska | bdg
Posts made between 2009-05-09 and 2011-08-26 were in the capacity of staff.  Please read accordingly.

Offline Kyrdua

  • Member
  • Posts: 7306
  • I have no idea what i'm doing.
    • Lunatic Red (A member there XD)
Re: Danbooru Image tagger/renamer << NEED HELP!!!
« Reply #17 on: March 06, 2011, 01:11:27 AM »
oh shit, now that you mentioned it, does this work on live KDE CD's(e.g. opensuse/kubuntu)?
You might have to install some packages.  Unfortunately, Ubuntu doesn't seem to package it, but you can just follow the instructions to install it manually.

well, you searched for efixtool...

anyway, you used digikam as your example, what distro do you use this in? i have another computer here with ubuntu maverick installed and i also got a lucid livecd so i was thinking i should just use those instead of using it in windows.
 avatar/signature: Touhou | My Links | MyAnimelist

Offline Xiong Chiamiov

  • Member
  • Posts: 3012
  • I'm gonna tolerate and love the SHIT out of you!
    • changedmy.name
Re: Danbooru Image tagger/renamer << NEED HELP!!!
« Reply #18 on: March 06, 2011, 08:05:54 PM »
oh shit, now that you mentioned it, does this work on live KDE CD's(e.g. opensuse/kubuntu)?
You might have to install some packages.  Unfortunately, Ubuntu doesn't seem to package it, but you can just follow the instructions to install it manually.

well, you searched for efixtool...
Doh.  Ok, they have it packaged.

Quote
anyway, you used digikam as your example, what distro do you use this in? i have another computer here with ubuntu maverick installed and i also got a lucid livecd so i was thinking i should just use those instead of using it in windows.
I use Arch, but Digikam is part of the kde-graphics package, and thus available on any distro that has KDE in the repositories.  They claim it will run on Windows, as well.
Projects of interest: nagi | sheska | bdg
Posts made between 2009-05-09 and 2011-08-26 were in the capacity of staff.  Please read accordingly.

Offline Kyrdua

  • Member
  • Posts: 7306
  • I have no idea what i'm doing.
    • Lunatic Red (A member there XD)
--delete post--
« Reply #19 on: March 06, 2011, 11:10:00 PM »
--delete post--
« Last Edit: April 10, 2011, 01:47:23 AM by Kyrdua »
 avatar/signature: Touhou | My Links | MyAnimelist