UksusoFF / webtrees-faces

webtrees module for mark people on photos
https://www.webtrees.net/index.php/en/forum/2-open-discussion/30219-how-to-mark-individuals-on-group-photo
37 stars 8 forks source link

Add Age of when photo taken #70

Closed MYLE-01 closed 5 months ago

MYLE-01 commented 1 year ago

what about if we add the Year the photo was taken. then when we tag the person it could work out there age base on birth

hartenthaler commented 1 year ago

I'm adding already the date a picture was taken using a _DATE tag.

MYLE-01 commented 1 year ago

Thanks, Bro could we have the option to add manually Year

Just that the Photos I'm uploading are Photos of the photo so _DATE would be wrong

hartenthaler commented 1 year ago

Yes, I'm adding the date a picture was taken manually. Sometimes the date is written on the back side of the photo. Or I know the event when the photo was taken. Since the GEDCOM standard 5.5.1 does not allow storing the date, I have to use a NOTE or a custom GEDCOM tag like _DATE.

hartenthaler commented 1 year ago

I agree that it would be nice if the faces module would show the age of the tagged persons in a picture together with their names. This could help to be sure that the identification of the persons is correct.

UksusoFF commented 1 year ago

Faces can show date from fact attached to photo. So it's not so hard implement age on titles. I will try implement it when possible.

MYLE-01 commented 1 year ago

My thinking would be to add the Year to the Notes field

image

new note data looks like this Y2005, X9, X10, X2, X11, X16, X55

I'm thinking the logic looks at that split it by the , if the first array has a Y then do the maths base on the X??

Would like to know what files you are changing to get to work?

hartenthaler commented 1 year ago

I do not understand what you mean. The date a picture is taken is an attribute of the picture. So it has to be stored as a GEDCOM tag in the OBJE record of the picture.

At the moment the data of the faces module is stored in a database table and cannot be exported as GEDCOM. This makes it complicated when transferring data to another installation of webtrees. This was ok, because there was no standard defined for that. Now there is GEDCOM 7 and so we have a standard for exchanging data like the position of "faces" in a picture. So I suggest orienting the module on that. even if webtrees is following the GEDCOM 5.5.1 standard up to now.

UksusoFF commented 1 year ago

@hartenthaler GEDCOM 7 is supported with webtreees? Can you give example of this?

hartenthaler commented 1 year ago

webtrees is still supporting officially only 5.5.1. But there are already several 7.0 structures possible.

You can import GEDCOM 7.0 in webtrees (but not gedzip format) and export it without any errors (see German webtrees manual).

Support for GEDCOM 7.0

UksusoFF commented 1 year ago

@MYLE-01 Check latest master version image

MYLE-01 commented 5 months ago

long time no see i understanding more about this now I add a photo as a fact added the Date which shows when I display that image like that bit

image

what I would like to see age of me when that photo taken as I add 01 DEC 2002 using the date field in the fact as It knows my birth 1965 and the date is 01 Dec 2003 would like the Age @ Photo to say Age @ photo 37

MYLE-01 commented 5 months ago

Been Playing no nothing about PHP but after some reading got this working well sort of seeing what it would look like

in

function getMediaMapForTree(

change the 'age'=>

'age' => (strlen(trim(strip_tags($person->lifespan()))) > 6) 
            ? 2004 - (substr(strip_tags($person->lifespan()),0,4) + 0)  
            : 'Missing DATES', 

I know its Not the correct way of do it. Shit it looks good when you mouse over you see there age working on finding that fact date then replacing the 2004 with the fact date.

know this is not the correct way could you give some links where to start reading.

my think ill have to put it in the

function getPersonDisplayAge

and change the maths logic a bit...

image

image

now looking at it on screen think ill drop lifespan for live people but show it dead people

found this

function getMediaMeta
...
...
...
$fact->attribute('DATE'),

is that putting the date of the FACT into the $fact ....... hope so

just need to work out how to pull that value out..

have no idea what I doing but enjoying it.

MYLE-01 commented 5 months ago

made this fuction

    private function getPersonDisplayAgePhoto(Individual $person, $fact, $media): string
    {
        if (strlen(trim(strip_tags($person->lifespan()))) > 6) {
            $birthyear = substr(strip_tags($person->lifespan()),0,4) + 0;
        }
        else {
            return I18N::translate('Missing Birth');
        }

        $Photoyear =  2018; 

        $birthyear = $Photoyear - $birthyear;
        return $birthyear ;
    }

still can't get the DATE from the NOTE :(

MYLE-01 commented 5 months ago

I have fix it and working

    private function getPersonDisplayAgePhoto(Individual $person, ?Fact $fact): string
    {
        if (strlen(trim(strip_tags($person->lifespan()))) > 6) {
            $birthyear = substr(strip_tags($person->lifespan()),0,4) + 0;
        }
        else {
            return I18N::translate('Missing Birth');
        }
        if (empty($fact)) {
            return I18N::translate('Missing fact Date');
        }

        $Photoyear =  substr($fact->attribute('DATE'),-4) + 0; 

        $birthyear = $Photoyear - $birthyear;
        return $birthyear ;
    }

hope I done the updating to here right

MYLE-01 commented 5 months ago

Tested on home server work