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

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 #20 on: April 10, 2011, 01:46:29 AM »
wee, i've tagged 70% of my gallery now. this thing works like a charm!



i haven't tried tagging with XP though.

UPDATE:  tagged with XP now, works perfectly!
« Last Edit: April 10, 2011, 03:28:41 PM by Kyrdua »
 avatar/signature: Touhou | My Links | MyAnimelist

Offline Jorin

  • Member
  • Posts: 12
Re: Danbooru Image tagger/renamer << NEED HELP!!!
« Reply #21 on: April 26, 2011, 06:09:42 AM »
That looks awesome. I've been looking for something like this for a while, especially since I want to keep artist metadata in the files. I gave it a try, but I got this output:

Code: [Select]
D:\Download>python sheska.py 85c0fc90513b9a2ff6ccbd4f314eb329.jpg
Processing 85c0fc90513b9a2ff6ccbd4f314eb329.jpg
Checking for original hash...  hashing... Warning: Tag 'md5sum' does not exist
Nothing to do.
 ok
Fetching tags from the internets...
Retrying with hash implied from filename...
Warning: Tag 'md5sum' does not exist
Nothing to do.
FILE_NOT_FOUND

The weird thing is I downloaded this image right off Danbooru, so the md5 should be ok. Other images I've tested have pulled maybe 1 or 2 tags, but not all of them. I used the updated script with the tag and Exiftool is in my path, so I'm not sure what's missing.

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 #22 on: April 26, 2011, 08:59:56 AM »
sheska uses sankaku to search for tags by default. you have to change the json url to this:

unparsedJson = urlopen('http://danbooru.donmai.us/post/index.json?tags=md5%3A' + image.hash)

it got "file not found" because some pics that are in sankaku are not in danbooru and vice versa.
 avatar/signature: Touhou | My Links | MyAnimelist

Offline ph4zr

  • Member
  • Posts: 346
  • Izaaaaaaya-kuuun!
Re: Danbooru Image tagger/renamer << NEED HELP!!!
« Reply #23 on: April 26, 2011, 09:01:00 AM »
Hm... it's not necro if I post after someone else bumped it, is it? Also, I apologize in advance for this huge friggin' wall of text.

Re: alt-text as file name (old): The problem with that is there seems to be a 255* character limit on file names. The total character length of all tags, combined with spacing, can easily reach well beyond that on over well tagged images. If you're going to go that route, it's also a pain to do it for each individual image if you're more than just a casual browser (i.e. if you batch download), so you'd want to automate the process somehow. At that point, you might as well just put the tags into the image itself, if it's supported, or store them locally in some kind of custom database.

(click to show/hide)

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.
If you do that (or if you open a new thread for the project), please do make a note of it in this post so I see it in my updated topics. ...'twould be most enlightening (and useful). XD
(click to show/hide)

As I got sidetracked into mentioning in the previous spoiler... I've been toying with the idea of a photo retagger or tag manager to work w/ the Danbooru Downloader's** SQLite data. I didn't want to start the project during the semester b/c it'd suck me into its world and I'd never do my HW, but this summer I'd like to do something about my ~10GB collection of (untagged) images. If you actually started such a project, the code could potentially be re-purposed or modified to both scan over images for updated tags and check for updated posts to specific tag sets. Useful for finally finding out who that "character-request" actually belonged to, for example.

My project would mostly be focused on applying data I already have, whereas yours would be/is/seems to be mostly about getting data the user didn't grab in the first place (i.e., what you want to do is more complicated than just parsing text and importing modules)*. XD
*Outsourcing, FTW!

(click to show/hide)

But I'm not so sure about pulling tag data directly from boorus for existing images that aren't already associated with a post (on the client side)—i.e. any file a user downloaded manually and renamed. Without the exact hash value you'd have a hell of a time figuring out what's what on a one-by-one basis. You could use iqdb to find the original image pretty easily for an individual, unmodified image—preferably sized down a bit for upload—but does iqdb have an API you can use to do it via a script? Managing any more than a few dozen images this way would be painstakingly slow.

Python, hm? Never got past "Hello world" with it, although you hear great things. I was planning on using perl for the exiftool package, and php for dealing with the SQLite DBs, dumping tag data into a more friendly format for parsing with perl, or just perl if I export to a csv format first. How do you handle tagging with python? It looks like a system call to the standalone binary version of exiftool, but I'm not familiar enough w/ python to rule out something else.

If you actually want -all- of the tags, and not just ones you whitelist (or don't blacklist), it probably wouldn't be too difficult to just have perl connect to said downloader DB and tag any supported images you downloaded via DD using the exiftool module. I'm a bit pickier about which tags I accept, though. Some I have no use for.

(click to show/hide)

(click to show/hide)
« Last Edit: April 26, 2011, 09:12:17 AM by ph4zr »
Oh flickering blaze burn...
Why use skill when you can just spam fireball? /mage <3

Offline Jorin

  • Member
  • Posts: 12
Re: Danbooru Image tagger/renamer << NEED HELP!!!
« Reply #24 on: April 26, 2011, 11:00:19 AM »
Hm... it's not necro if I post after someone else bumped it, is it?

Sorry if I was off base for bumping the thread. It was only on the second page and seemed reasonably new, so I figured I'd give it a shot.

Kyrdua, replacing that URL like you showed fixed the problem. It looks like I had confused something in the script previously, because there were two json url's. I also needed to replace instances of xmp:TagsList with xmp:Subject in order to get Picasa to properly read the tags. It works awesome now (except Picasa displays the tags in reverse-alphabetical order for some reason...).

Thanks a lot for the help! :) This will make it so much easier to manage my thousands of images. Any suggestions on how to feed multiple filenames into the command line aside from typing them manually? * wildcards seem to cause a problem.

Offline ph4zr

  • Member
  • Posts: 346
  • Izaaaaaaya-kuuun!
Re: Danbooru Image tagger/renamer << NEED HELP!!!
« Reply #25 on: April 26, 2011, 11:49:06 AM »
Sorry if I was off base for bumping the thread. It was only on the second page and seemed reasonably new, so I figured I'd give it a shot.
Heh. No... I'm mostly just covering my own rear. Different forums probably have different guidelines for what constitutes necro, and I don't know where this one stands. On a faster moving board, someone would probably yell at you for bumping a thread from as recently as yesterday. On others, month old threads are still fair game. I've not discovered a hard and fast rule. /off-topic, but I thought I'd clarify

Edit: Plus, it isn't like you didn't have anything relevant to say, so it wasn't a bump for bumping's sake. Better to revive an old(er) topic than start a new one that's exactly the same, and all.
« Last Edit: April 26, 2011, 11:52:27 AM by ph4zr »
Oh flickering blaze burn...
Why use skill when you can just spam fireball? /mage <3

Offline Jorin

  • Member
  • Posts: 12
Re: Danbooru Image tagger/renamer << NEED HELP!!!
« Reply #26 on: April 26, 2011, 08:42:39 PM »
Cool, good to know. I'm going to try out that Danbooru Downloader add-on because I've been interested in doing something like this with music files too.

If a stand-alone browser does end up being in the works, I agree about allowing it to pull data locally, not only for the performance increase but also simply so you can get your existing collection up to speed. It would be feasible for it to access any or all of the main databases (Sankaku, Danbooru, etc., just switch them on or off when scanning) to see which files you've downloaded come from where.

Another feature that would suit this project really well would be including the tag types information in the browser. This is something normal image browsers like Picasa can't do, but it's really useful in this kind of image collection. You want to know what's an artist tag, and what's a copyright tag for example.

Offline ph4zr

  • Member
  • Posts: 346
  • Izaaaaaaya-kuuun!
Re: Danbooru Image tagger/renamer << NEED HELP!!!
« Reply #27 on: April 27, 2011, 04:20:20 AM »
see above
(click to show/hide)
(click to show/hide)

Danbooru Downloader fix for Gelbooru ratings
||NOTE: If you downloaded any of these files before the 2011.04.27 or the last edit time, whichever is older, you need to get the updated versions, because I was an idiot and packed the wrong folder. If I did it again, let me know. And hit me over the head with ... something soft, please.
(click to show/hide)
« Last Edit: April 27, 2011, 07:44:47 AM by ph4zr »
Oh flickering blaze burn...
Why use skill when you can just spam fireball? /mage <3

Offline Jorin

  • Member
  • Posts: 12
Re: Danbooru Image tagger/renamer << NEED HELP!!!
« Reply #28 on: April 30, 2011, 06:06:17 AM »
(click to show/hide)

I noticed that DD didn't pull the tags when I tried to use it. The subject field is empty when I read it with Exiftool. Should it be tagging the images, or just only downloading them?

It would be incredibly useful to link the functionality of DD and the Sheska script (or just Exiftool if that's possible) if the latter situation is the case, that way you'd get images downloaded into organized folders, and also searchable with the internal tags in an image viewer.

(click to show/hide)

If a standalone *booru viewer is in the cards, colour-coding the prefixes and making sure they're searchable would be great. Blacklisting and whitelisting is already accounted for within DD, so various tags could be filtered. Also, image viewers like Picasa should allow you to detect unwanted tags and mass-remove them from your collection as well.

It looks like almost all the ingredients are here to make a useful app. What's missing still is a process to mass-tag a bunch (like, hundreds or thousands) of files already downloaded, provided they're not renamed and/or they have their original md5 hash.
« Last Edit: April 30, 2011, 06:10:10 AM by Jorin »

Offline Tiffanys

  • Member
  • Posts: 7756
  • real female girl ojō-sama
Re: Danbooru Image tagger/renamer << NEED HELP!!!
« Reply #29 on: April 30, 2011, 07:12:54 AM »
I use Tagbooru to download whole gobs of junk: http://code.google.com/p/tagbooru/

Offline ph4zr

  • Member
  • Posts: 346
  • Izaaaaaaya-kuuun!
Re: Danbooru Image tagger/renamer << NEED HELP!!!
« Reply #30 on: May 02, 2011, 02:46:36 AM »
I use Tagbooru to download whole gobs of junk: http://code.google.com/p/tagbooru/
I tend to shy away from batch downloaders, just because I like to see what I'm putting in my library. There are some images I'd just as soon not add, that would be incredibly hard to find if I batched all of Touhou... as I'm sure I'd do first thing. ;D

(click to show/hide)
Oh flickering blaze burn...
Why use skill when you can just spam fireball? /mage <3

Offline Jorin

  • Member
  • Posts: 12
Re: Danbooru Image tagger/renamer << NEED HELP!!!
« Reply #31 on: May 04, 2011, 02:35:03 AM »
Just a quick reply because I'm busy applying for a job (in user experience design!), I'm interested in user interfaces and I'd have fun working on this. It wouldn't have to be extremely powerful, just slick and functional enough to do the job well. New features could be added over time anyway.

Offline ph4zr

  • Member
  • Posts: 346
  • Izaaaaaaya-kuuun!
Re: Danbooru Image tagger/renamer << NEED HELP!!!
« Reply #32 on: May 04, 2011, 10:37:46 PM »
Hmm...? What kind of languages would work best? The only ones I'd be comfortable drafting it in are Java, PHP, perl, or possibly python if I can pick it up easily enough. C++ for an eventual port, maybe, but I'm not sure I'd want to start it there b/c there's so much more I can screw up. I haven't dealt with pointers or OOP in C++ in literally years, nor have I used it for any kind of non-trivial application or network communication. Then there's the fact it's easier to port the others to other platforms than it is a C++ project. I doubt most would want to compile the source themselves, after all.

(click to show/hide)

Honestly I'm not very dynamic with languages. I stick to what I've used for the most part. Still, if there's another language you had in mind, it never hurts to learn something new, either. And there are almost certainly users on the forum who have the necessary expertise to do it in some language of choice, though AFAIK xiong is the only one who has expressed even potential interest in a similar project, with fairly low priority at that.

If a project did get started, it might be appropriate to either create a dedicated thread for it or move the discussions/planning to a different environment. If it doesn't violate site rules, maybe they wouldn't really care, but there's still the fact that trading code via DL links isn't very efficient. I've never attempted a collaborative project, so I wouldn't know how to go about it, but it can't be too too hard to setup github or svn. /famous last words?

In any case, I couldn't even think about doing anything at all for at least another week. Posting in forums is a tad less time consuming than coding. ...the latter of which I should already be doing for my final... =/
Oh flickering blaze burn...
Why use skill when you can just spam fireball? /mage <3

Offline Jorin

  • Member
  • Posts: 12
Re: Danbooru Image tagger/renamer << NEED HELP!!!
« Reply #33 on: May 08, 2011, 08:39:09 AM »
I figure it's good to be as lightweight and portable as possible, and it would be cool if it could work on mobile devices as well (kind of like the Pixiv app). I think I'd rule out Java and C++ to start at least. I'm not sure whether PHP could do this on its own. Perl and Python might be the best for compatibility. Whichever can do this without needing Exiftool would be a big help, since exif metadata isn't present in anything besides .jpg files. There are a lot of .png and .gif files in this collection and it would be necessary to write metadata for them too.

My problem is I'm good on the research and design side, but I have a gaping hole in my skillset when it comes to actually programming. :( I could prototype it and design the overall architecture and interface down to the mouse-click, but I wouldn't know where to start for actually building it. I'm starting to learn how to program, but it's a bit of a learning curve for me.

But for now it's always possible to brainstorm. If and when it's possible to make this a project (perhaps if anyone else is interested too) it would be fun to get involved. It would be possible to at least get started with a wiki or something. Those are good for version control and note taking and are especially helpful for multi-person projects. No joke: wikis got me through grad school.
« Last Edit: May 08, 2011, 08:45:16 AM by Jorin »

Offline ph4zr

  • Member
  • Posts: 346
  • Izaaaaaaya-kuuun!
Re: Danbooru Image tagger/renamer << NEED HELP!!!
« Reply #34 on: May 08, 2011, 09:26:16 AM »
/formats
I don't really know enough about image formats to be familiar with the metadata PNG and GIF files can store. Exiftool is convenient because it provides a library for writing metadata to JPEGs. Even Picasa doesn't store any metadata in PNGs or GIFs, so my guess is there isn't an accepted tagging standard. A more general approach would be to just store the metadata externally, but then obviously it's not stored with the images themselves, making re-organization somewhat of a hassle.

/mobile|porting
Your comment about mobile devices perplexes me slightly. Is a smartphone or tablet type device appropriate for hosting a user's image library? If you are just browsing that's one thing, but if you are also downloading it seems you'd want a desktop environment of some sort.

I've never actually programmed for a mobile device before, but my understanding is they tend to differ a fair bit in terms of what your available options are for languages and design. If you were designing a mobile app I suspect you'd have to build it with a specific mobile device in mind, although the underlying logic could probably remain untouched.

Honestly I'd be happy just to get it working on Windows in whatever language was most convenient. Porting could come later, although designing with portability in mind would definitely simplify it. As long as you don't rely too heavily on system calls or language/platform specific libraries and functionality, everything else is just translation.
Which is obviously no small feat even when you understand both languages, for which fansub TLs provide more than sufficient evidence.

/experience
Experience probably wouldn't really matter, at least not to me. I'd approach it more as I would a hobby or learning experience than a job. Besides that, even just designing the interface would be a step up. What was or wasn't possible, or was simply too much of a hassle to actually implement, could likely be dealt with on a case by case basis.

I tend to start with a top down approach for design and prototyping and then implement it from the bottom up, so knowing what functionality the GUI requires would make it easier to design the back-end. I.e., knowing what you want to do makes it easier to figure out what you need to do to make it happen.

Heck, they actually pay people to design pretty looking interfaces, so it's not like "just" designing an interface is necessarily a trivial task.
Oh flickering blaze burn...
Why use skill when you can just spam fireball? /mage <3

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 #35 on: May 08, 2011, 10:16:47 AM »
um... should i rename the thread title? while the stuff you guys are talking about aren't really off from the actual topic the current name really doesn't suit it. so... any thoughts?

/obviousy has nothing to contribute *shrinks in shame*
 avatar/signature: Touhou | My Links | MyAnimelist

Offline ph4zr

  • Member
  • Posts: 346
  • Izaaaaaaya-kuuun!
Re: Danbooru Image tagger/renamer << NEED HELP!!!
« Reply #36 on: May 08, 2011, 10:47:44 AM »
Not really sure what you'd name it, to be honest. So far it's still all hypothetical/speculative, so it isn't as if there's a particularly accurate way to describe the (as yet non-existent) project. Sorry if we hijacked your thread, though. =/

If a project actually gets started, a new thread probably will be created for the purpose. I probably should've since the first wall, but it was purely speculative and I didn't want to generate any expectations. << fairly poor follow through, as noted previously
I'd probably be the last to know, though, since I don't really watch the tech forum too too closely. Mostly I just auto-refresh recent posts and updated.

(click to show/hide)
Oh flickering blaze burn...
Why use skill when you can just spam fireball? /mage <3

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 #37 on: May 08, 2011, 01:07:38 PM »
^ lol, i don't mind the hijack. the stuff you're planning sounds quite useful anyway.
but yeah, it could use it's own topic once you've made something that works.
 avatar/signature: Touhou | My Links | MyAnimelist

Offline Jorin

  • Member
  • Posts: 12
Re: Danbooru Image tagger/renamer << NEED HELP!!!
« Reply #38 on: May 09, 2011, 07:35:31 PM »
In terms of the thread name, the idea for the project literally is a Danbooru image tagger, though Image Board Browser/Tagger Program (Ideas) might be a better fit. Whichever works for you. It's true this is only still hypothetical, so it would probably only need to be renamed if anything got started. For now we're just brainstorming.

As for the project, I figure since we're at this stage, why not keep going with the top-down approach and figuring out which features would be best. As for the mobile thing, I perplexed myself as well upon reading it again! It would be incredible for browsing, but not at all useful for handling image collections. Thinking too far ahead here. :)

[qoute=kyrdua]/obviousy has nothing to contribute *shrinks in shame*[/quote]
Any ideas at all for how this project could be useful are welcome!

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 #39 on: May 09, 2011, 10:40:39 PM »
▲ then in that case, it deserves a new thread, since it's still in brainstorming stage.
 avatar/signature: Touhou | My Links | MyAnimelist