Could the module somehow used as an API to handle metadata? I am working on a bulk image import that uses iptc/exif. So i need to extract metadata and use them then to put them in fields and so on.

Comments

jphautin’s picture

Assigned: Unassigned » jphautin

I am also thinking on the same thing as a drush command but does not start to implement it as it is not a priority.
Principle of import is :
- read paths (required parameter of command line) to make a list a images
- for each file
+ create a node, the title is the name of the image file.
+ update the node with the uploaded file, metadata will be automatically updated following node type
+ update the node title with a chosen metadata type (optional parameter of command line)

If you are not working on drush integration, please give me what type of API you need to see what can i do.

regards,

marcoka’s picture

i mean at the moment i dostuff like this:

/**
 * @param $file
 * File Object
 * @return $image_data
 * An array containing the IPTC data
 */
function imagefield_classification_get_iptc_data($filepath) {
	
	 $size = getimagesize($filepath, $info);	
  			 if ($size != FALSE) {
  			 	$iptc = iptcparse($info['APP13']);
  			 	$meta_data['title'] = @iconv('Windows-1252', 'UTF-8//TRANSLIT', $iptc['2#005'][0]); //IPTC Field Object Name
  			 	$meta_data['body'] = @iconv('Windows-1252', 'UTF-8//TRANSLIT', $iptc['2#120'][0]); //IPTC Field Caption
  			 	$meta_data['photographer'] = @iconv('Windows-1252', 'UTF-8//TRANSLIT', $iptc['2#080'][0]); //IPTC Field Photographer
  			 	//$meta_data['supplemental_category'] = @iconv('Windows-1252', 'UTF-8//TRANSLIT', $iptc['2#020'][0]); //subcategories  			 	
  			 	
  			 	$keywordcount = count($iptc["2#025"]); //IPTC Field "keywords"  

  			 	//@TODO foreach instead of for???
	  			 	
	  			 	for ($i=0; $i<$keywordcount; $i++) {
	  			 		if ($i<$keywordcount) {
	  			 			$keyword = $iptc["2#025"][$i];
	  			 			$meta_data['tags'][$i] = @iconv('Windows-1252', 'UTF-8//TRANSLIT', $keyword);	  			 			
	  			 		} 
					} 		  			 	
  			 	
  			 } else {
  			 	 	drupal_set_message(t('error while trying to parse iptc data tags', 'error')); 			 	
  			 }  	
  			 		
  	//dsm($meta_data);	
	return $meta_data;
}

an api would centralize iptc/exif meta data stuff. i am taking single fields here.

jphautin’s picture

at first glance, you coould use the Exif class.

jphautin’s picture

Issue summary: View changes
Status: Active » Closed (outdated)