Pixelpost

Authentic Photoblog Flavour


Go Back   Pixelpost Forum > DEVELOPMENT > Hacks and Modifications

Post Reply
 
Thread Tools
  #1  
Old 08-13-2007, 06:19 AM
howardB666 Offline
forum loafer
 
Join Date: Aug 2007
Posts: 3
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
Reply With Quote
  #2  
Old 08-13-2007, 06:44 AM
Dennis's Avatar
Dennis+ Offline
Team Pixelpost
 
Join Date: Jul 2006
Posts: 2,394
Send a message via MSN to Dennis
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.
__________________
My photoblog, powered by PixelPost 1.9 dev SVN | My Pixelpost Addons | My Cool Photoblog profile
Reply With Quote
  #3  
Old 08-16-2007, 03:20 AM
howardB666 Offline
forum loafer
 
Join Date: Aug 2007
Posts: 3
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 
Reply With Quote
  #4  
Old 08-16-2007, 10:18 AM
Dkozikowski's Avatar
Dkozikowski+ Offline
Team Pixelpost
 
Join Date: Oct 2005
Posts: 1,855
Send a message via AIM to Dkozikowski
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"
Reply With Quote
  #5  
Old 08-16-2007, 12:06 PM
Dennis's Avatar
Dennis+ Offline
Team Pixelpost
 
Join Date: Jul 2006
Posts: 2,394
Send a message via MSN to Dennis
I'm working on an addon as we speak.
__________________
My photoblog, powered by PixelPost 1.9 dev SVN | My Pixelpost Addons | My Cool Photoblog profile
Reply With Quote
  #6  
Old 08-16-2007, 09:46 PM
howardB666 Offline
forum loafer
 
Join Date: Aug 2007
Posts: 3
Dennis your addon will no doubt be far superior to mine and i will pick it apart when i get stuck again
Reply With Quote
  #7  
Old 08-17-2007, 07:24 AM
Dennis's Avatar
Dennis+ Offline
Team Pixelpost
 
Join Date: Jul 2006
Posts: 2,394
Send a message via MSN to Dennis
Howard, I seriously doubt that my addon will be far more superior, after all it is based on the same code.
__________________
My photoblog, powered by PixelPost 1.9 dev SVN | My Pixelpost Addons | My Cool Photoblog profile
Reply With Quote
  #8  
Old 08-17-2007, 12:35 PM
Dennis's Avatar
Dennis+ Offline
Team Pixelpost
 
Join Date: Jul 2006
Posts: 2,394
Send a message via MSN to Dennis
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.
__________________
My photoblog, powered by PixelPost 1.9 dev SVN | My Pixelpost Addons | My Cool Photoblog profile
Reply With Quote
  #9  
Old 10-05-2007, 06:53 PM
HavePh8 Offline
forum loafer
 
Join Date: Oct 2007
Posts: 2
hi there,
just wondering if there has been an progress with this addon.
Thank you.
Reply With Quote
  #10  
Old 10-07-2007, 01:48 PM
Dennis's Avatar
Dennis+ Offline
Team Pixelpost
 
Join Date: Jul 2006
Posts: 2,394
Send a message via MSN to Dennis
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.
__________________
My photoblog, powered by PixelPost 1.9 dev SVN | My Pixelpost Addons | My Cool Photoblog profile
Reply With Quote
Post Reply


Thread Tools




All times are GMT. The time now is 01:11 AM.

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd. | Style Design: d3 designs