Tutorial :Obtaining photo 'stars' rating using PHP


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?


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...];  }  


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 Suggested php code to read file rating set by Adobe Bridge CS3

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »