views:

59

answers:

2

I am trying to extract the photo 'stars' rating from .jpg files using php code. My intent is to show the highest rated images as part of a slideshow. I found that using the PHP_JPEG_Metadata_Toolkit_1.11 I am able to get the rating of the file if the rating is set from within Vista (Right click -> Properties -> Details -> Set rating by clicking on stars) by reading the array returned by the Metadata_Toolkit

$exif = get_EXIF_JPEG( $photodir . "/" . $filename );
$rating = $exif[0][18246]['Data'][0];

However if I set the rating using Adobe Bridge, I can see the 'stars' in Vista, but the
$exif[0][18246]['Data'][0] returns a null value.

Is PHP code available to read the ratings applied by both Windows Vista AND Adobe Bridge?

+1  A: 

Beats me, but why don't you find out for yourself:

$exif = get_EXIF_JPEG( $photodir . "/" . $filename );
print_r($exif);

This will print the contents of $exif, which I'm guessing will be large, but you've got time, right? (View the source in your web browser so you can see it properly formatted.) Drill down to find key 0, then key 18246, then key Data, then key 0. That's the one you already found. Now search for where the other rating might be. Hopefully it's not too hard to find. When you find it, take note of the path to it. Then to get it:

// This is your Vista rating
$rating = $exif[0][18246]['Data'][0];
if ($rating == null) {
    // no Vista rating, so get the Bridge rating
    $rating = $exif[...fill in this path...];
}
alexantd
Thanks for the hint. I am writing a recursive function to print out the differences between 2 arrays to help identify the differences between 2 large multidimensional arrays. I will post the results once I am able to locate the difference between 2 jpeg headers.
DarwinIcesurfer
A: 

I found that Adobe Bridge stores the rating in a different location in the jpeg file than Vista. See details in the post found at http://stackoverflow.com/questions/3042083

DarwinIcesurfer