prolethead Posted December 18, 2006 Share Posted December 18, 2006 Hi,I have two pieces of code, one that lists files in a directory, and one that reads image ipct header info from images. I want to be able to combine those pieces of code so I can print the header info for multiple image files.Here's the readdir code:[quote]if ($handle = opendir('.')) { while (false !== ($file = readdir($handle))) { echo "$file\n"; } closedir($handle);}[/quote]Here's the icpt code:[quote]$image_path = 'WHAT I WANT TO BE AN ARRAY';function output_iptc_data( $image_path ) { $size = getimagesize ( $image_path, $info); if(is_array($info)) { $iptc = iptcparse($info["APP13"]); foreach (array_keys($iptc) as $s) { $c = count ($iptc[$s]); for ($i=0; $i <$c; $i++) { echo $s.' = '.$iptc[$s][$i].'<br>'; } } } } output_iptc_data( $image_path );[/quote]So I want to make output_iptc_data work for multiple files in a directory.Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/31125-read-image-info-from-multiple-files/ Share on other sites More sharing options...
HuggieBear Posted December 18, 2006 Share Posted December 18, 2006 You need to just do put the call to the function inside the loop...[code]<?phpif ($handle = opendir('.')) { while (($file = readdir($handle)) !== false){ echo "$file\n"; output_iptc_data($file); } closedir($handle);}function output_iptc_data($image_path) { $size = getimagesize( $image_path, $info); if(is_array($info)){ $iptc = iptcparse($info["APP13"]); foreach (array_keys($iptc) as $s) { $c = count ($iptc[$s]); for ($i=0; $i <$c; $i++){ echo $s." = ".$iptc[$s][$i]."<br>\n"; } } } }?>[/code]RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/31125-read-image-info-from-multiple-files/#findComment-143910 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.