[Closed]: adding exif date to user1 column [Closed]: adding exif date to user1 column
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

[Closed]: adding exif date to user1 column

Started by vktr, October 28, 2009, 02:29:33 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

vktr

Hi,

I just started with coppermine, looks great. I'd like to have a plugin to populate user1 column of the pictures table with date from exif info. I'm trying this:


$thisplugin->add_filter('add_file_data', 'exif2user');

function exif2user($pict_data) {
   $fullpath = $pict_data['filepath'] . $pict_data['filename'];
   $exif = read_exif_data_raw($fullpath, true);
   $pict_data['user1'] = ??????????????;

   return $pict_data;
}


How do I get the content of 'DateTime digitized' field from $exif? Does this hook really execute once when a file is added?

Thanks,
Viktor

Jeff Bailey

Thinking is the hardest work there is, which is probably the reason why so few engage in it. - Henry Ford

vktr

Quote from: Jeff Bailey on October 28, 2009, 04:20:39 AM
http://forum.coppermine-gallery.net/index.php/topic,55415.msg270616.html#msg270616

Quote8. Post links
When posting a support request, it's helpfull for supporters in most cases to see what the actual page looks like, that's why it's mandatory that you always post a link to your coppermine gallery page when asking for support. If your site contains adult content, make sure to post a warning together with your link!

Well, it looks like any other coppermine gallery (looks great). Any hint on how to get the exif info from within a plugin? Thanks.

Jeff Bailey

I'm Sorry I wasn't clear before... The board rules are saying that you must post a link to your gallery before you will receive support. There is a mod that does something similar, you'd know this if you read the rules and did a search  ;) 
Thinking is the hardest work there is, which is probably the reason why so few engage in it. - Henry Ford

vktr

So here is the solution. Indeed, PhotoComment plugin has a similar thing.

include_once('include/exif.php');
if (!defined('IN_COPPERMINE')) die('Not in Coppermine...');

$thisplugin->add_filter('add_file_data', 'exif2user');

function exif2user($pict_data) {
    global $CONFIG;

    $fullpath = $CONFIG['fullpath'] . $pict_data['filepath'] . $pict_data['filename'];
    $exif = read_exif_data_raw($fullpath, true);

    if (isset($exif) && is_array($exif)) {
    foreach ($exif as $k => $v) {
    if ($k == 'SubIFD') {
                $pict_data['user1'] = substr($v['DateTimedigitized'], 0, 10);
            }
    }
    }
    return $pict_data;
}


P.S. php does feel a bit weird  ;)

Cheers,
Viktor


Joachim Müller

Quote from: vktr on October 29, 2009, 01:21:46 AMphp does feel a bit weird  ;)
Hm...

In the future, please do as supporters and board rules suggest. Marking thread as "closed", as you haven't really resolved it properly (again: please read up board rules).
You haven't supplied enough details to enable us to answer your actual question: it depends on the plugin hook you use. In PHP as well as in any other programming language, it depends on the context, so you should have told us what you already ahev and where you need to call the needed data from.
Example from the real world: You can't ask "how do I drive a vehicle?", as this depends on the type of vehicle you want to drive and a number of other factors that have an impact. The same thing applies for programming as well: you need to make sure that the processing results /data that you want to re-use are already present (i.e. they must have been processed already) and you need to make sure to respect the particular rules that exist for programming languages (in PHP: make sure to understand the scope of variables).

vktr

Joachim Müller, I have no idea what you are talking about. What details are missing? All I wanted was to populate the user1 field when a file is added, as stated in the original post. Still not clear?? Or you mean I didn't post the URL of my private photo gallery? That's a plain stupid request if you ask me. Or is my solution bad? In what regard? If it's bad, then please correct it. In any case it works for me :)

What a strange place this is for an open source community LOL

Cheers,
Viktor

Joachim Müller

Quote from: vktr on October 29, 2009, 09:56:23 AMWhat details are missing?
Have you actually bothered to click the link in Jeff's initial reply in this thread:
Quote from: Jeff Bailey on October 28, 2009, 04:20:39 AM
http://forum.coppermine-gallery.net/index.php/topic,55415.msg270616.html#msg270616
and read the section you quoted yourself? It says that it's mandatory to post a link to your gallery if you want help. You claim to be from Canada so I expect you know the meaning of the word "mandatory". I can't spot that link to your gallery anywhere, so there no further help for you - simple as that.

vktr

Joachim Müller, all I can say you're fucking idiot. Coppermine is great, I'm converting hundreds of my albums to it. Thanks to all developers who made it happen. Wonderful project, I wish I could participate, but it looks like you've got a bunch of assholes on board.... Again, my ultimate respect to the developers, guys, you rock. Thanks!!

8)

Cheers,
Viktor

phill104

Hi Viktor,

Guess what, you are banned, out of here, outstayed your welcome, gone. See ya.

Don't bother coming back. Comments like your above show just the kind of nice person you are.
It is a mistake to think you can solve any major problems just with potatoes.