Permalink
Browse files

Analyze of images now stores proper size (width/height).

  • Loading branch information...
1 parent e9ea232 commit baeff74e208b36ecdf4057909d90a1e9404bcb1c @Driesvanl Driesvanl committed Feb 9, 2012
@@ -1399,7 +1399,17 @@ class mediamosa_job_scheduler {
return '';
}
- if (!(($w_target > 0) && ($h_target > 0) && ($w_source > 0) && ($h_source > 0))) {
+ // if source is unknown, but target is, just return the target size.
+ if ((w_target > 0 && $h_target > 0) && (!($w_source > 0 && $h_source > 0))) {
+ return(array(
+ 'width' => $w_target,
+ 'height' => $h_target,
+ 'h_padding' => 0,
+ 'v_padding' => 0,
+ ));
+ }
+ // if source is unknown, and target is unknown, jump out and decide there.
+ if (!($w_target > 0 && $h_target > 0 && $w_source > 0 && $h_source > 0)) {
return '';
}
@@ -139,10 +139,11 @@ class mediamosa_tool_mapping {
$parse_array = array();
// Get full definitions.
$metadata_definitions_full = mediamosa_asset_metadata_property::get_metadata_properties_full($app_id);
- // append, replace, update
- $action = 'update';
+ $metadata_found = array();
+
foreach ($output_array as $output_line) {
if (strpos($output_line, $separator) !== FALSE) {
+ // Map Asset metadata.
// Eg. CreationDate: Wed Jul 8 16:14:29 2009
// => array('CreationDate', 'Wed Jul 8 16:14:29 2009')
list($key, $metadata_value) = explode($separator, $output_line, 2);
@@ -157,8 +158,28 @@ class mediamosa_tool_mapping {
$parse_array[$mapping_array[$key]] = array($metadata_value);
}
+
+ $metadata_found[$key] = $metadata_value;
+ }
+ }
+
+ // See if we can store some technical metadata.
+ $visit_func = "mediamosa_tool_" . $tool_id . "_mediamosa_tool_store_technical_metadata";
+ if (function_exists($visit_func)) {
+ $technical_metadata_mapping = call_user_func($visit_func, $metadata_found);
+ }
+
+ if ($technical_metadata_mapping) {
+ foreach ($technical_metadata_mapping as $key => $value) {
+ mediamosa_asset_mediafile_metadata::delete_mediafile_metadata($mediafile_id, $key, key($value));
+ mediamosa_asset_mediafile_metadata::create_mediafile_multiple_metadata($mediafile_id, array( array(
+ 'value' => current($value),
+ 'prop_name' => $key,
+ 'type' => key($value))));
}
}
- mediamosa_asset_metadata::metadata_create($asset_id, $metadata_definitions_full, $parse_array, $action);
+
+ // Store found asset metadata.
+ mediamosa_asset_metadata::metadata_create($asset_id, $metadata_definitions_full, $parse_array, 'update');
}
}
@@ -50,6 +50,25 @@ function mediamosa_tool_image_mediamosa_tool_analyse($job_ext) {
}
/**
+ * Implements hook_mediamosa_tool_store_technical_metadata().
+ */
+function mediamosa_tool_image_mediamosa_tool_store_technical_metadata($technical_metadata_mapping) {
+ $new_mapping = array();
+ foreach ($technical_metadata_mapping as $key => $value) {
+ switch ($key) {
+ case 'image size':
+ $metadata_value = str_replace(' ', '', $value);
+ if (preg_match('/(?P<width>\d+)+x(?P<height>\d+)$/', $metadata_value, $matches)) {
+ $new_mapping['width'][mediamosa_asset_mediafile_metadata_property_db::TYPE_INT] = $matches['width'];
+ $new_mapping['height'][mediamosa_asset_mediafile_metadata_property_db::TYPE_INT] = $matches['height'];
+ }
+ break;
+ }
+ }
+ return $new_mapping;
+}
+
+/**
* Implements hook_mediamosa_tool_can_generate_still().
*/
function mediamosa_tool_image_mediamosa_tool_can_generate_still($mime_type) {

0 comments on commit baeff74

Please sign in to comment.