Jump to content


Photo

Print certain elements of an EXIF array


  • Please log in to reply
2 replies to this topic

#1 kallegurra

kallegurra
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 16 July 2006 - 07:22 PM

Hi!

Im pretty new to php and all that stuff and I have been trying to figure out an array problem for a couple of days now.
I havent been able to google or find anything that I can understand on php.net.

I'm trying to build a web album with exif information from the images using code from php.net.

With this piece of code I can get out the exif info, but I don't know how I choose which parts of the array I want to print out:
$exif = exif_read_data('path/to/image.jpg', 0, true);

foreach ($exif as $key => $section) {
	foreach ($section as $name => $val) {
		echo "$key $name: $val<br>";
	}	
}

The above code part gives me all the exif info. But I just want to keep maybe 10 elements of the array.

I have tried to sort out using brackets etc. But nothing works. Arrays isn't exactly my strong side...  :)
Anyone who knows how to solve my problem?



#2 ShogunWarrior

ShogunWarrior
  • Members
  • PipPipPip
  • Advanced Member
  • 528 posts
  • LocationIreland

Posted 16 July 2006 - 07:40 PM

Well this is the best option I think:
<?php
$exif = exif_read_data('path/to/image.jpg', 0, true);

/*Print only these fields that are listed*/
$printThese = array('Exposure','White Balance','Make');

foreach ($exif as $key => $section) {
	foreach ($section as $name => $val) {
		if(in_array($name,$printThese)){echo "$key $name: $val<br>";}
	}	
}
This should only print EXIF data with a $name that is in the $printThese array. Just add more elements to the array to print different elements. My ones were just examples, you will need the proper names of the EXIF names.
<a href="http://www.daviddora...nmedia.com/">My New Site/Blog</a> | <a href="http://www.daviddora...m/check/">Check your page for broken links/images/scripts</a>

Zend Certified Engineer
Follow me on Twitter: http://twitter.com/davidd

#3 kallegurra

kallegurra
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 16 July 2006 - 07:58 PM

Things are so easy when you see them...  :D

Testet and it works great.

Thanks alot!!!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users