rr- / szurubooru

Image board engine, Danbooru-style.
GNU General Public License v3.0
704 stars 178 forks source link

Preserve original filename #417

Open ioistired opened 3 years ago

ioistired commented 3 years ago

It would be nice if we could keep the user's original filename, as it often has clues about its origin or at least where to find it again in their own media library. Since uploaded post filenames are already prefixed with the post ID and an underscore, name conflicts wouldn't be a problem.

If this interests you I can implement it probably within a week

sgsunder commented 3 years ago

What you're asking for kinda goes against the philosophy of a booru but I think the best way of achieving this would be to store the file path in the "source" field for each post. You would have to write a script to automate this, though.

ioistired commented 3 years ago

How does it go against the philosophy of a booru?

sgsunder commented 3 years ago

Boorus are designed so that listing, searching, and indexing of posts are done all through the tags of the posts. Using filenames to store metadata would defeat this core functionality.

404Fox commented 3 years ago

It's not intended for the purpose of finding the image, but for finding the source link in the future. For instance, if you downloaded an image from Pixiv and uploaded it to your booru, the Pixiv ID of that image is in the filename but that information is lost and has to be added manually for all pictures. If you uploaded many Pixiv downloaded pictures then adding the source link is a massive task without any leads. Of course, that is the same for any other picture, but having the filename information is better than nothing.

neobooru commented 3 years ago

I personally like the idea to store the filename in the source field. We could even make this feature optional, but idk whether we want every little thing to be a setting.

ioistired commented 3 years ago

Don't make it optional. If the user doesn't like it they can change the source field per image.

noirscape commented 3 years ago

uh no id rather make this optional.

source field does some domain checking magic, dumping random filenames in there is a super dumb idea + messes with source: magic keyword.

if you want to do this, maybe put it in a template for a description field or something? i think there's an outstanding pr for a description feature.

sgsunder commented 3 years ago

It's not intended for the purpose of finding the image, but for finding the source link in the future. For instance, if you downloaded an image from Pixiv and uploaded it to your booru, the Pixiv ID of that image is in the filename but that information is lost and has to be added manually for all pictures. If you uploaded many Pixiv downloaded pictures then adding the source link is a massive task without any leads. Of course, that is the same for any other picture, but having the filename information is better than nothing.

We already have this functionality if you upload the hotlink to the image and let szurubooru download it.

I don't like storing filepaths for multiple reasons:

1) Dumping the uploaded filepath to the post can potentially expose some private details that you wouldn't want to expose. (e.g. storing and publically sharing a filepath of /home/Your Name/pictures/nsfw/01.png might accidentally dox a user.)

2) An image hotlink, should, in theory, be accessible by anyone, however the filepath only makes sense to the uploader. Image hotlinks also serve as quasi-attribution to the original artist, which filenames don't necessarily do.

3) There's no guarantee that the filepath is in a sensible format that contains information. If there is information, wouldn't it be more sensible to parse that information into tags to begin with? (e.g if you're uploading a path of /home/somebody/pictures/fanart/evangelion/rei_ayanami/01.jpg why not just upload the tags fanart, rei_ayanami, neon_genesis_evangelion instead, using a script to parse the path?)

4) Most important for me: I think this is an example of feature creep that only serves a small edge case of users while adding complexity for others + increasing project maintenance requirements. Which is important because this project doesn't have very active maintenance. On top of that, there is already a reasonable workaround to get this functionality: you could set the source field to file:///home/somebody/pictures/fanart/evangelion/rei_ayanami/01.jpg either manually or through an upload script.

ioistired commented 3 years ago

The proposal is not to expose the full file path, but just the basename, in your example 01.png and 01.jpg. I don't think browsers even expose the full path anymore. IIRC if you try to access it on Chrome, it just returns the basename prefixed with C:\fakepath\.

I have a lot of media previously downloaded from sites like pixiv and other boorus, just because it's easier for me to save to my local machine than to open tor browser, sign in, paste in a hotlink, and wait. A lot of boorus embed every tag in there, and while you're right that it would be ideal to just store the tags in the database, I would rather not let the perfect be the enemy of the good.

noirscape commented 3 years ago

honestly it's pretty trivial to code your own upload script for this. given your usecase, you wouldn't get much yield out of dumping it in the source field (it's not what it's really meant for anyway), you'd want this stored in some nicely formatted way which you can best achieve with a comment.

given this is pretty specific, it seems a lot easier to just code your own upload script than to have szuru handle this, given the usecase for preserving filenames is not usually attached to a booru (and runs kinda against a couple of ideas of what a booru is supposed to do with organization).