Lychee icon indicating copy to clipboard operation
Lychee copied to clipboard

[Enhancement] Support Custom Metadata Fields

Open sebastianraese opened this issue 2 years ago • 4 comments

Apologies first, if this feature is already existing (but I was not able to find) or there is already an exsiting issue (although, I tried to check the issues list carefully), I am relatively new to Lychee...

Although tags are supported, it seems, there is no support existing for custom fields (holding string-based key/value-pairs) so far.

I am handling a lot of (licensed) 3rd-party images with Lychee and it would be very helpful to be able to store additional information - i.e. the original vendor URL or image ID.

sebastianraese avatar May 24 '22 19:05 sebastianraese

Even supporting some common extended metadata elements, like Dublin Core, would open up some very useful fields.

For example I use dc:Identfier=[Image.URL] and dc:Source=[OriginWebsite.URL] for a similar use-case as above. Serious value add on top of that would be URL aware fields so they are actually clickable.

Wdavery avatar Sep 28 '22 17:09 Wdavery

@ildyria I'm more than willing to add some common extended XML elements, but I'm unfamiliar with the project and with PHP. Do you have any pointers to dig into this? /app/Metadata/Extractor.php looks like the main place to be.

Is there a relatively straightforward way to extract and dump a specific XML field to the GUI? I only see EXIF references besides XML sidecars. Every path I follow in code appears increasingly complex, using the values for other purposes beyond simply viewing. If it's quite involved to do properly, I'd be happy with a hacky-implementation I can play with myself and get familiar with the code. Any pointers would be greatly appreciated!

Wdavery avatar Sep 28 '22 21:09 Wdavery

If you are familiar with C++ / Java / C#, PHP will be quite easy to adapt to.

In order to dev with Lychee, you will need to install the dev dependencies. This is easily done with : composer install

You can run the test suite with: make test

Ensure some of your code correctness with make phpstan which will do a static analysis of your code. We do have some strict rules and phpstan will complain if they are not followed. :)

We use php-exif to extract the data from a photo, you will probably need to have a look there: https://github.com/LycheeOrg/php-exif

Here are some reading which I hope will help you to get started. https://lycheeorg.github.io/docs/contributions.html https://lycheeorg.github.io/docs/architecture.html https://lycheeorg.github.io/docs/structure.html

As you noticed, app/Metadata/Extractor.php is the place to apply some changes, do note that you will most likely want to add a migration file to add some columns to the photo table. You will most likely also need to modify the app/Models/Photo to reflect those changes.

The front end lives currently on https://github.com/LycheeOrg/Lychee-front and is in JavaScript. I think you will be particularly interested in that file: https://github.com/LycheeOrg/Lychee-front/blob/master/scripts/main/sidebar.js#L228

In order to compile the front end, you should have a look at this: https://lycheeorg.github.io/docs/frontend.html

Hope this helps. :)

You may find this useful: dd($variableName) will stop the execution with error 500 and display the content fo $variableName. Otherwise we also use DebugBar which you will need to enable in your .env in addition to debug mode.

ildyria avatar Sep 28 '22 21:09 ildyria

That's incredibly helpful, thank you very much! Looking forward to digging in.

Wdavery avatar Sep 28 '22 22:09 Wdavery