Pixelpost Forum

Pixelpost Forum (http://www.pixelpost.org/forum/index.php)
-   Hacks and Modifications (http://www.pixelpost.org/forum/forumdisplay.php?f=16)
-   -   How to read aux:Lens from xmp image info? (http://www.pixelpost.org/forum/showthread.php?t=7040)

howardB666 08-13-2007 06:19 AM

How to read aux:Lens from xmp image info?
 
How to read aux:Lens from xmp image info?

My first post, I hope this thread is where it should be.

I’m trying to read lens name info from a JPG image saved from PS.

From what I can conjure up with google I’ve narrowed it down to this PHP function by Pekka Saarinen

http://photography-on-the.net/ee/bet...mp_to_exif.php

Code:

<?php

$xmp_parsed = ee_extract_exif_from_pscs_xmp ("CRW_0016b_preview.jpg",1);

function ee_extract_exif_from_pscs_xmp ($filename,$printout=0) {
   
    // very straightforward one-purpose utility function which
    // reads image data and gets some EXIF data (what I needed) out from its XMP tags (by Adobe Photoshop CS)
    // returns an array with values
    // code by Pekka Saarinen http://photography-on-the.net
   
    ob_start();
    readfile($filename);
    $source = ob_get_contents();
    ob_end_clean();
   
    $xmpdata_start = strpos($source,"<x:xmpmeta");
    $xmpdata_end = strpos($source,"</x:xmpmeta>");
    $xmplenght = $xmpdata_end-$xmpdata_start;
    $xmpdata = substr($source,$xmpdata_start,$xmplenght+12);
   
    $xmp_parsed = array();
   
    $regexps = array(
    array("name" => "DC creator", "regexp" => "/<dc:creator>\s*<rdf:Seq>\s*<rdf:li>.+<\/rdf:li>\s*<\/rdf:Seq>\s*<\/dc:creator>/"),
    array("name" => "TIFF camera model", "regexp" => "/<tiff:Model>.+<\/tiff:Model>/"),
    array("name" => "TIFF maker", "regexp" => "/<tiff:Make>.+<\/tiff:Make>/"),
    array("name" => "EXIF exposure time", "regexp" => "/<exif:ExposureTime>.+<\/exif:ExposureTime>/"),
    array("name" => "EXIF f number", "regexp" => "/<exif:FNumber>.+<\/exif:FNumber>/"),
    array("name" => "EXIF aperture value", "regexp" => "/<exif:ApertureValue>.+<\/exif:ApertureValue>/"),
    array("name" => "EXIF exposure program", "regexp" => "/<exif:ExposureProgram>.+<\/exif:ExposureProgram>/"),
    array("name" => "EXIF iso speed ratings", "regexp" => "/<exif:ISOSpeedRatings>\s*<rdf:Seq>\s*<rdf:li>.+<\/rdf:li>\s*<\/rdf:Seq>\s*<\/exif:ISOSpeedRatings>/"),
    array("name" => "EXIF datetime original", "regexp" => "/<exif:DateTimeOriginal>.+<\/exif:DateTimeOriginal>/"),
    array("name" => "EXIF exposure bias value", "regexp" => "/<exif:ExposureBiasValue>.+<\/exif:ExposureBiasValue>/"),
    array("name" => "EXIF metering mode", "regexp" => "/<exif:MeteringMode>.+<\/exif:MeteringMode>/"),
    array("name" => "EXIF focal lenght", "regexp" => "/<exif:FocalLength>.+<\/exif:FocalLength>/"),
    array("name" => "AUX lens", "regexp" => "/<aux:Lens>.+<\/aux:Lens>/")
    );
   
    foreach ($regexps as $key => $k) {
            $name        = $k["name"];
            $regexp    = $k["regexp"];
            unset($r);
            preg_match ($regexp, $xmpdata, $r);
            $xmp_item = "";
            $xmp_item = @$r[0];
            array_push($xmp_parsed,array("item" => $name, "value" => $xmp_item));
    }
   
    if ($printout == 1) {
        foreach ($xmp_parsed as $key => $k) {
                $item        = $k["item"];
                $value        = $k["value"];
                print "<br><b>" . $item . ":</b> " . $value;
        }
    }

return ($xmp_parsed);

}

?>

I’m only interested in returning the info from the last index in the array “AUX lens” where is will tell you the name of the lens used in the image ex. “EF24-70mm f/2.8L USM”

I’ve been trying to get this custom function to work in pixelpost with modding the functions _exif.php file but my lack of PHP knowledge and a decent way to debugging has stumped me, I know this method will work but someone with a handle on PHP is needed

i can be emailed at bryan AT bryan-howard DOT com

Dennis 08-13-2007 06:44 AM

well first off you should not try to hack the core functions of Pixelpost. Secondly this should be done in an addon.
Third, I'll whip something up for you asap.

howardB666 08-16-2007 03:20 AM

Ok im trying to get this to work as an addon but, I’m stuck with this code

PHP Code:

array("name" => "AUX lens""regexp" => "/<aux:Lens>.+<\/aux:Lens>/"

this bit of code won’t work because “aux…” isn’t in tags. Its in the form as

PHP Code:

aux:Lens="EF24-70mm f/2.8L USM" aux:ImageNumber…

I then tried this bit of code for the search
PHP Code:

array("name" => "AUX lens""regexp" => "/aux:Lens=\".+aux:ImageNumber=\"64\"/"

but then got

PHP Code:

aux:Lens="EF24-70mm f/2.8L USM" aux:ImageNumber="64" 

so my question is how to ignore all the aux stuff and only return
PHP Code:

EF24-70mm f/2.8L USM 


Dkozikowski 08-16-2007 10:18 AM

I'm not too familiar with the EXIF functions as I have never taken the plunge into those files but a regex like this:

Code:

aux:Lens="(.*?)"
would pull out

EF24-70mm f/2.8L USM

from this string,

aux:Lens="EF24-70mm f/2.8L USM" aux:ImageNumber="64"

Dennis 08-16-2007 12:06 PM

I'm working on an addon as we speak.

howardB666 08-16-2007 09:46 PM

Dennis your addon will no doubt be far superior to mine and i will pick it apart when i get stuck again :)

Dennis 08-17-2007 07:24 AM

Howard, I seriously doubt that my addon will be far more superior, after all it is based on the same code. ;)

Dennis 08-17-2007 12:35 PM

It's going to take a little bit more to get this all working. I can extract the info you want, but I don't want to stop there.

HavePh8 10-05-2007 06:53 PM

hi there,
just wondering if there has been an progress with this addon.
Thank you.

Dennis 10-07-2007 01:48 PM

Yes, there is. However, I use some code which is not freely available at this point. I'm still waiting if I can release it.


All times are GMT. The time now is 07:44 AM.

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.