0, 'credit' => '', 'camera' => '', 'caption' => '', 'created_timestamp' => 0, 'copyright' => '', 'focal_length' => 0, 'iso' => 0, 'shutter_speed' => 0, 'title' => '', ); // read iptc first, since it might contain data not available in exif such as caption, description etc if ( is_callable('iptcparse') ) { getimagesize($file, $info); if ( !empty($info['APP13']) ) { $iptc = iptcparse($info['APP13']); if ( !empty($iptc['2#110'][0]) ) // credit $meta['credit'] = utf8_encode(trim($iptc['2#110'][0])); elseif ( !empty($iptc['2#080'][0]) ) // byline $meta['credit'] = utf8_encode(trim($iptc['2#080'][0])); if ( !empty($iptc['2#055'][0]) and !empty($iptc['2#060'][0]) ) // created datee and time $meta['created_timestamp'] = strtotime($iptc['2#055'][0] . ' ' . $iptc['2#060'][0]); if ( !empty($iptc['2#120'][0]) ) // caption $meta['caption'] = utf8_encode(trim($iptc['2#120'][0])); if ( !empty($iptc['2#116'][0]) ) // copyright $meta['copyright'] = utf8_encode(trim($iptc['2#116'][0])); if ( !empty($iptc['2#005'][0]) ) // title $meta['title'] = utf8_encode(trim($iptc['2#005'][0])); } } // fetch additional info from exif if available if ( is_callable('exif_read_data') && in_array($sourceImageType, apply_filters('wp_read_image_metadata_types', array(IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM)) ) ) { $exif = @exif_read_data( $file ); if (!empty($exif['FNumber'])) $meta['aperture'] = round( wp_exif_frac2dec( $exif['FNumber'] ), 2 ); if (!empty($exif['Model'])) $meta['camera'] = trim( $exif['Model'] ); if (!empty($exif['DateTimeDigitized'])) $meta['created_timestamp'] = wp_exif_date2ts($exif['DateTimeDigitized']); if (!empty($exif['FocalLength'])) $meta['focal_length'] = wp_exif_frac2dec( $exif['FocalLength'] ); if (!empty($exif['ISOSpeedRatings'])) $meta['iso'] = $exif['ISOSpeedRatings']; if (!empty($exif['ExposureTime'])) $meta['shutter_speed'] = wp_exif_frac2dec( $exif['ExposureTime'] ); } // FIXME: try other exif libraries if available return apply_filters( 'wp_read_image_metadata', $meta, $file, $sourceImageType ); } // is the file a real image file? function file_is_valid_image($path) { $size = @getimagesize($path); return !empty($size); } // is the file an image suitable for displaying within a web page? function file_is_displayable_image($path) { $info = @getimagesize($path); if ( empty($info) ) $result = false; elseif ( !in_array($info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG)) ) // only gif, jpeg and png images can reliably be displayed $result = false; elseif ( $info['channels'] > 0 && $info['channels'] != 3 ) { // some web browsers can't display cmyk or grayscale jpegs $result = false; } else $result = true; return apply_filters('file_is_displayable_image', $result, $path); } ?>