aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.cvsignore2
-rw-r--r--CHANGES.txt55
-rw-r--r--CVS/Entries13
-rw-r--r--CVS/Tag1
-rwxr-xr-xREADME.txt65
-rw-r--r--exif.css3
-rwxr-xr-xexif.info7
-rwxr-xr-xexif.install89
-rwxr-xr-xexif.module566
-rw-r--r--exif_helper/CVS/Entries3
-rw-r--r--exif_helper/CVS/Repository1
-rw-r--r--exif_helper/CVS/Root1
-rw-r--r--exif_helper/CVS/Tag1
-rw-r--r--exif_helper/exif_helper.info5
-rw-r--r--exif_helper/exif_helper.module80
-rw-r--r--exif_location/CVS/Entries6
-rw-r--r--exif_location/CVS/Tag1
-rw-r--r--exif_location/exif_location.info1
-rw-r--r--exif_location/exif_location.install7
-rw-r--r--exif_location/exif_location.module25
-rw-r--r--sample.jpgbin24802 -> 0 bytes
21 files changed, 433 insertions, 499 deletions
diff --git a/.cvsignore b/.cvsignore
deleted file mode 100644
index f592eba..0000000
--- a/.cvsignore
+++ /dev/null
@@ -1,2 +0,0 @@
-.project
-.buildpath
diff --git a/CHANGES.txt b/CHANGES.txt
deleted file mode 100644
index 443496e..0000000
--- a/CHANGES.txt
+++ /dev/null
@@ -1,55 +0,0 @@
-// $Id:
-
-FAST GALLERY MODULE CHANGES
----------------------------
-
-ACKNOWLEDGEMENTS
-----------------
- * rapsli (Raphael Schär)
-
-
-CHANGES LOG
------------
-2010/04/27
-* UTF-8 support #783310 by silvio
-* XMP Support #783344 by silvio
-
-2009/12/01
-* added option to choose if the exif information should be refreshed upon update or not
-
-2009/11/25
-* Prevent from reading exif information from png files (http://drupal.org/node/613776) by rapsli
-
-2009/10/26
-* Multiple IPTC Keywords http://drupal.org/node/226703 by chachasikes
-* Error with exif extraction http://drupal.org/node/473140 by raintonr
-
-2009/09/24 dman
-* Cleaned up PHP E_ALL notices (undefined variables) in a few places, including exif.class
-* Typo in exif_nodeapi()
-* Applied fix for array-structured Geo tags http://drupal.org/node/473140
-
-2009/09/24
-* Applied Drupal Code styles
-
-2009/09/21
-* Better communications for users who don't have the exif_read_data function available
-
-2009/09/15
-* committed patch for iptc support
-
-2009/04/13
-* changed to fit the new CCK Datastructure.
-
-2009/03/30
-* better support for datefields
-
-2009/03/17
- * if the datetime exif data is read we make sure to put it into the correct form (2004-02-12T15:19:21) so that we don't
- need to use a text field only, but could use some date CCK field
-
-2009/02/05
- * give the user the option to either show or not show the exif form fields created with cck on the node-form
-
-2009/01/23
- * Initial first version providing support for CCK.
diff --git a/CVS/Entries b/CVS/Entries
index 228d67b..7547316 100644
--- a/CVS/Entries
+++ b/CVS/Entries
@@ -1,12 +1,7 @@
-/CHANGES.txt/1.1.2.13/Tue Apr 27 20:53:49 2010//TDRUPAL-6--1
-/README.txt/1.6.2.3/Fri Mar 19 22:17:00 2010//TDRUPAL-6--1
-/exif.css/1.1.2.1/Fri Jan 23 11:13:15 2009//TDRUPAL-6--1
-/exif.info/1.4.2.2/Thu Feb 5 20:11:54 2009//TDRUPAL-6--1
-/exif.install/1.4.2.6/Tue Apr 27 20:53:13 2010//TDRUPAL-6--1
-/sample.jpg/1.1.2.1/Fri Jan 30 16:04:44 2009/-kb/TDRUPAL-6--1
D/exif_helper////
D/exif_location////
-/.cvsignore/1.1.2.2/Tue Apr 27 21:34:24 2010//TDRUPAL-6--1
-/exif.admin.inc/1.1.2.1/Wed Jun 9 13:14:02 2010//TDRUPAL-6--1
/exif.class.php/1.1.2.16/Result of merge//TDRUPAL-6--1
-/exif.module/1.9.2.18/Wed Aug 11 14:45:29 2010//TDRUPAL-6--1
+/README.txt/1.6/Thu Oct 7 21:44:03 2010//
+/exif.info/1.4/Thu Oct 7 21:44:03 2010//
+/exif.install/1.4/Thu Oct 7 21:44:03 2010//
+/exif.module/1.9/Result of merge+Thu Oct 7 21:44:03 2010//
diff --git a/CVS/Tag b/CVS/Tag
deleted file mode 100644
index d7ee0a3..0000000
--- a/CVS/Tag
+++ /dev/null
@@ -1 +0,0 @@
-TDRUPAL-6--1
diff --git a/README.txt b/README.txt
index a0d5173..e25757a 100755
--- a/README.txt
+++ b/README.txt
@@ -1,5 +1,3 @@
-// $Id:
-
README file for the Exif Drupal module.
@@ -21,43 +19,58 @@ The metadata tags defined in the Exif standard cover a broad spectrum including
camera.
* Descriptions and copyright information.
-Administrators can choose via CCK fields which Exif information are read.
+Administrators can choose what Exif tags they want to display, and control the
+order of appearance.
At this time, this module supports Exif information only with JPEG files.
[1] Reference: http://en.wikipedia.org/wiki/Exchangeable_image_file_format
-Requirements and Constraints
-****************************
+Requirements
+************
+
+This module requires the PHP Exif Library (PEL), http://sourceforge.net/projects/pel
+
+Your PHP must be compiled in with --enable-exif. Windows users must also have
+the mbstring extension enabled.
+
+PEL itself requires PHP version 5.
+It does NOT work under PHP 4.
-CCK with at least textfields enabled.
-If you use a module like imagefield. It's only possible to have one image per node!!
-If there are more than one images per node, only the exif data of one image is read!
+This module has been tested with PEL version 0.91.
-IMPORTANT: If you are using imagefield, do not call the content type "image"!!! Image
-is reserved for using the Image module. If you call your content type image and you are
-using imagefield, the module is not going to work.
+And of course, this module also requires Drupal (version 5.0). This module won't
+do anything without the Image module (http://drupal.org/project/image), as Exif
+data is displayed only on image nodes.
-Usage
+Installation
************
-After installing it you can go to your CCK nodetype. It supports both the image module
-aswell as the imagefield module. Let's say you have an content type "photo". Go to your
-cck settings and add a new field. For the name of the field you need to follow the following
-naming conventions:
+1. Extract the 'exif' module directory, including all its subdirectories, into
+ your Drupal modules directory.
+
+2. Download and extract the PEL archive into the modules/exif/pel
+ directory. When you're finished the directory structure should look something
+ like:
-Example:
-#1 field_exif_exposuretime -> this would read the ExposureTime of the image and save it
-in this field.
+ drupal/
+ sites/
+ example.com/
+ modules/
+ exif/
+ pel/
+ README
+ INSTALL
+ Pel.php
+ PelJpeg.php
+ ...
+
+3. Enable the Exif module on your site's administer > site building > modules
+ page. A database table will automagically be created at this point.
-#2 field_ifd0_datetime -> this would read the date time (2009:01:23 08:52:43) of the image.
-as a field_type you can take for example a normal textfield, but also a date field would be
-possible.
+4. Go to administer > site configuration > exif settings, and select what Exif
+ tags to display.
-General rule is: [field]_[section]_[name]
-Under admin/settings/exif you can see a list of all possible information. These informations
-are taken from the image "sample.jpg". I may not contain all tags available. If you are looking
-for some specific tags you can just replace this image with your own image. \ No newline at end of file
diff --git a/exif.css b/exif.css
deleted file mode 100644
index 37686fa..0000000
--- a/exif.css
+++ /dev/null
@@ -1,3 +0,0 @@
-.tag_type{
- background-color: gray !important;
-} \ No newline at end of file
diff --git a/exif.info b/exif.info
index 7dbae23..89868e4 100755
--- a/exif.info
+++ b/exif.info
@@ -1,9 +1,6 @@
-; $Id: exif.info,v 1.4.2.2 2009/02/05 20:11:54 rapsli Exp $
+; $Id: exif.info,v 1.4 2007/06/18 23:50:49 dww Exp $
name = Exif
description = "Display Exif metadata on image nodes."
-dependencies[] = content
-dependencies[] = text
-dependencies[] = exif_helper
+dependencies = image
package = Image
-core = 6.x
diff --git a/exif.install b/exif.install
index cc1373d..75bf5d2 100755
--- a/exif.install
+++ b/exif.install
@@ -1,26 +1,85 @@
<?php
-// $Id: exif.install,v 1.4.2.6 2010/04/27 20:53:13 rapsli Exp $
-/**
- * @file the install part of the module
-*/
+// $Id: exif.install,v 1.4 2008/04/05 23:22:05 davidlesieur Exp $
/**
* Implementation of hook_install().
*/
function exif_install() {
- db_query("UPDATE {system} SET weight = %d WHERE name = '%s'", -10, 'exif');
+ switch ($GLOBALS['db_type']) {
+ case 'mysql':
+ case 'mysqli':
+ db_query("CREATE TABLE {exif_tags} (
+ ifd int(10) unsigned NOT NULL default '0',
+ tag int(10) unsigned NOT NULL default '0',
+ status int(10) unsigned NOT NULL default '0',
+ weight int(11) NOT NULL default '0',
+ PRIMARY KEY (ifd, tag)
+ ) /*!40100 DEFAULT CHARACTER SET utf8 */;"
+ );
+ db_query("CREATE TABLE {exif} (
+ fid int(10) unsigned NOT NULL default '0',
+ ifd int(10) unsigned NOT NULL default '0',
+ tag int(10) unsigned NOT NULL default '0',
+ value varchar(255) NOT NULL default '',
+ PRIMARY KEY (fid, ifd, tag)
+ ) /*!40100 DEFAULT CHARACTER SET utf8 */;"
+ );
+ break;
+ case 'pgsql':
+ db_query("CREATE TABLE {exif_tags} (
+ ifd integer NOT NULL default '0',
+ tag integer NOT NULL default '0',
+ status integer NOT NULL default '0',
+ weight integer NOT NULL default '0',
+ PRIMARY KEY (ifd, tag)
+ );"
+ );
+ db_query("CREATE TABLE {exif} (
+ fid int(10) unsigned NOT NULL default '0',
+ ifd int(10) unsigned NOT NULL default '0',
+ tag int(10) unsigned NOT NULL default '0',
+ value varchar(255) NOT NULL default '',
+ PRIMARY KEY (fid, ifd, tag)
+ );"
+ );
+ break;
+ }
}
-function exif_requirements($phase) {
- $t = get_t();
- if ($phase == 'runtime' || $phase == 'install') {
- if (!function_exists('exif_read_data')) {
- $requirements['exif_read_data'] = array(
- 'title' => $t('Function exif_read_data not available'),
- 'value' => $t('The Function exif_read_data is not available on the system.'),
- 'severity' => REQUIREMENT_ERROR,
+function exif_update_1() {
+ // Works for postgres??
+ $ret[] = update_sql('ALTER TABLE {exif} RENAME TO {exif_tags}');
+ // make new table for caching and tracking exif data.
+ switch ($GLOBALS['db_type']) {
+ case 'mysql':
+ case 'mysqli':
+ $ret[] = update_sql("CREATE TABLE {exif} (
+ fid int(10) unsigned NOT NULL default '0',
+ ifd int(10) unsigned NOT NULL default '0',
+ tag int(10) unsigned NOT NULL default '0',
+ value varchar(255) NOT NULL default '',
+ PRIMARY KEY (fid, ifd, tag)
+ ) /*!40100 DEFAULT CHARACTER SET utf8 */;"
+ );
+ break;
+ case 'pgsql':
+ $ret[] = update_sql("CREATE TABLE {exif} (
+ fid int(10) unsigned NOT NULL default '0',
+ ifd int(10) unsigned NOT NULL default '0',
+ tag int(10) unsigned NOT NULL default '0',
+ value varchar(255) NOT NULL default '',
+ PRIMARY KEY (fid, ifd, tag)
+ );"
);
- }
+ break;
}
- return $requirements;
+ return $ret;
}
+
+/**
+ * Implementation of hook_uninstall().
+ */
+function exif_uninstall() {
+ db_query('DROP TABLE {exif_tags}');
+ db_query('DROP TABLE {exif}');
+} \ No newline at end of file
diff --git a/exif.module b/exif.module
index 7d955f1..2f41afb 100755
--- a/exif.module
+++ b/exif.module
@@ -1,61 +1,50 @@
<?php
-// $Id: exif.module,v 1.9.2.18 2010/07/23 17:47:46 rapsli Exp $:
+// $Id: exif.module,v 1.9 2008/04/05 23:22:05 davidlesieur Exp $
/**
- * @file implementing the drupal api
- */
-/**
- * @author: Raphael Schär - www.rapsli.ch
+ * Implementation of hook_menu().
*/
+function exif_menu($may_cache) {
+ $items = array();
+
+ if ($may_cache) {
+ $items[] = array(
+ 'path' => 'admin/settings/exif',
+ 'title' => t('Exif'),
+ 'callback' => 'drupal_get_form',
+ 'callback arguments' => array('exif_admin_settings_form'),
+ 'access' => user_access('administer site configuration'),
+ 'description' => t('Configure what Exif tags to display.'),
+ );
+ }
-function exif_menu() {
- $items['admin/settings/exif'] = array(
- 'title' => 'Exif',
- 'page callback' => 'exif_admin_settings',
- 'access arguments' => array('administer site configuration'),
- 'description' => t('Display available fields'),
- 'access callback' => 'user_access',
- 'file' => 'exif.admin.inc',
- 'type' => MENU_NORMAL_ITEM,
- );
- $items['admin/settings/exif/general'] = array(
- 'title' => 'Exif',
- 'page callback' => 'exif_admin_settings',
- 'access arguments' => array('administer site configuration'),
- 'description' => t('Display available fields'),
- 'access callback' => 'user_access',
- 'file' => 'exif.admin.inc',
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- );
- $items['admin/settings/exif/config'] = array(
- 'title' => 'Config',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('exif_admin_settings_form'),
- 'access arguments' => array('administer site configuration'),
- 'description' => t('Some Settings'),
- 'access callback' => 'user_access',
- 'file' => 'exif.admin.inc',
- 'type' => MENU_LOCAL_TASK,
- );
return $items;
}
/**
- * implementation of hook_nodeapi
+ * Implementation of hook_nodeapi().
*/
-function exif_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
-
- if ($teaser) {
+function exif_nodeapi(&$node, $op, $teaser) {
+ if ($teaser || $node->type != 'image') {
return;
}
switch ($op) {
-
+ case 'insert':
case 'update':
- //we are only going to update if we have said so
- if (!variable_get('exif_update', TRUE)) {
- break;
+ $fid = db_result(db_query("SELECT fid FROM {files} WHERE filepath = '%s'", $node->images[IMAGE_ORIGINAL]));
+ $file = file_create_path($node->images[IMAGE_ORIGINAL]);
+ $data = _exif_read_exif($file);
+ db_query('DELETE FROM {exif} WHERE fid = %d', $fid);
+
+ // Cache data in db.
+ foreach ($data as $ifd => $tags) {
+ foreach ($tags as $tag => $value) {
+ db_query("INSERT INTO {exif} (fid, ifd, tag, value) VALUES (%d, %d, %d, '%s')",
+ $fid, $ifd, $tag, $value);
+ }
}
+<<<<<<< exif.module
case 'insert':
if (! _exif_check_for_exif_data($node->type)) {
return;
@@ -67,282 +56,325 @@ function exif_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
//get all the fields that will be filled with exif data
$ar_exif_fields = $exif->getExifFields($fields);
-
- //get the path to the image
- $image_path = _exif_get_image_path($fields, $node);
-
- $fid = db_result(db_query("SELECT fid FROM {files} WHERE filepath = '%s'", $image_path));
- $file = file_create_path($image_path);
-
- $data1 = _exif_reformat($exif->readExifTags($file, $ar_exif_fields));
- $data2 = $exif->readIPTCTags($file, $ar_exif_fields);
-
- if (class_exists('SXMPFiles')) {
- $data3 = $exif->readXMPTags($file, $ar_exif_fields);
- $data = array_merge($data1, $data2, $data3);
- }
- else {
- $data = array_merge($data1, $data2);
- }
-
- // Loop through every exif enabled field and set its value to the
- // corresponding exif value. If no exif value was found, set the field
- // value to NULL, to avoid strange behaviour in other field modules
- // (date).
- foreach ($ar_exif_fields as $ar_exif_field) {
- $exif_name = $ar_exif_field['section'] .'_'. $ar_exif_field['tag'];
- $exif_value = isset($data[$exif_name]) ? $data[$exif_name] : NULL;
-
- $field_name = 'field_'. $exif_name;
- if (! $exif_value) {
- if (variable_get('exif_empty_values', TRUE)) {
- $node->{$field_name}[0]['value'] = NULL;
- }
- continue;
- }
- $field = $fields[$field_name];
-
- // Setup the field value array for delta = 0.
- switch ($exif_name) {
- case 'exif_datetimeoriginal':
- case 'exif_datetimedigitized':
- case 'ifd0_datetime':
- $first_delta = _exif_date_handler($field, $exif_value);
- break;
- default:
- $first_delta = array('value' => $data[$exif_name]);
- break;
- }
- $node->{$field_name}[0] = $first_delta;
- }
+=======
+ break;
+>>>>>>> 1.9
+
+ case 'load':
+ $fid = db_result(db_query("SELECT fid FROM {files} WHERE filepath = '%s'", $node->images[IMAGE_ORIGINAL]));
+ return array('exif_data' => _exif_get_exif($fid));
+ case 'view':
+ $node->content['exif'] = array(
+ '#value' => theme('exif_table', $node),
+ '#weight' => 10,
+ );
break;
}
}
/**
- * Date API hook.
- *
- * Make exif a date format in Date API. This makes it possible to alter the
- * format exif dates is parsed as.
+ * Administration page callback.
*/
-function exif_date_format_types() {
- return array('exif' => 'EXIF');
-}
-
-/**
- * Date API hook.
- *
- * Make the EXIF date format default for the 'exif' date type.
- */
-function exif_date_formats() {
- return array(
- array(
- 'type' => 'exif',
- 'format' => 'Y:m:d H:i:s',
- ),
+function exif_admin_settings_form() {
+ _exif_bootstrap();
+ $tags = exif_load_settings();
+ foreach ($tags as $tag) {
+ $form['tags']["{$tag->ifd}_{$tag->tag}"]['type'] = array(
+ '#type' => 'markup',
+ '#value' => PelIfd::getTypeName($tag->ifd),
+ );
+ $form['tags']["{$tag->ifd}_{$tag->tag}"]['ifd'] = array(
+ '#type' => 'hidden',
+ '#value' => $tag->ifd,
+ );
+ $form['tags']["{$tag->ifd}_{$tag->tag}"]['tag'] = array(
+ '#type' => 'hidden',
+ '#value' => $tag->tag,
+ );
+ $form['tags']["{$tag->ifd}_{$tag->tag}"]['status'] = array(
+ '#type' => 'checkbox',
+ '#title' => utf8_encode(PelTag::getTitle($tag->ifd, $tag->tag)),
+ '#default_value' => $tag->status,
+ );
+ $form['tags']["{$tag->ifd}_{$tag->tag}"]['weight'] = array(
+ '#type' => 'weight',
+ '#delta' => 10,
+ '#default_value' => $tag->weight,
+ );
+ $form['tags']["{$tag->ifd}_{$tag->tag}"]['#tree'] = TRUE;
+ $form['tags']["{$tag->ifd}_{$tag->tag}"]['#weight'] = $tag->weight;
+ }
+ $form['buttons']['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Save configuration')
+ );
+ $form['buttons']['reset'] = array(
+ '#type' => 'submit',
+ '#value' => t('Reset to defaults')
);
+
+ return $form;
}
-/**
- * Helper function to handle all date values from exif header. This is
- * designed for the date_api and date modules, but is compatible if these
- * aren't enabled.
- *
- * @param array $field
- * The field definition for the matcing exif date
- * @param string $exif_date
- * The date extracted from exif header.
- * @return array
- * The field value array for delta = 0
- */
-function _exif_date_handler($field, $exif_date) {
- if (! module_exists('date_api')) {
- // Don't bother doing anything if the webmaster doesn't ...
- return array('value' => $exif_date);
- }
+function exif_admin_settings_form_submit($form_id, $values) {
+ $op = isset($_POST['op']) ? $_POST['op'] : '';
- require_once drupal_get_path('module', 'date_api') .'/date_api_elements.inc';
- $date_datetime = date_convert_from_custom($exif_date, variable_get('date_format_exif', 'Y:m:d H:i:s'));
- if (! in_array($field['type'], array('date', 'datetime', 'datestamp'))) {
- // Field is not a date field type, so we return a ISO-8601 representation
- return array('value' => date_convert($date_datetime, DATE_DATETIME, DATE_ISO));
+ if ($op == t('Reset to defaults')) {
+ exif_reset_settings();
+ drupal_set_message(t('The configuration options have been reset to their default values.'));
+ }
+ elseif ($op == t('Save configuration')) {
+ exif_save_settings($values);
+ drupal_set_message(t('The configuration options have been saved.'));
}
-
- // Exif doesn't handles timezones, so we assume the exif date is in the
- // timezone configured for this date field. This means the exif date needs
- // to be converted to UTC before it's stored.
- $timezone = date_get_timezone($field['tz_handling']);
- $date = date_make_date($date_datetime, $timezone, DATE_DATETIME, $field['granularity']);
-
- // Store date offset before converting to UTC as this is lost when setting
- // timezone to 'UTC'.
- $offset = date_offset_get($date);
- date_timezone_set($date, timezone_open('UTC'));
-
- // Finally, convert the date object in UTC to a date according to the field
- // type: DATE_ISO, DATE_DATETIME or DATE_UNIX.
- $date_field = date_convert($date, DATE_OBJECT, $field['type']);
- return array(
- 'value' => $date_field,
- 'value2' => $date_field,
- 'timezone' => $timezone,
- 'offset' => $offset,
- 'offset2' => $offset,
- );
}
/**
- * Let's check if this node type contains an image field.
- *
- * @param $fields fields from this content type
- * @return boolean
+ * Fetch exif data.
*/
-function _exif_check_for_exif_data($node_type) {
-
- $new_types = array();
- //fill up array with checked nodetypes
- foreach (variable_get('exif_nodetypes', array()) as $type) {
- if ($type != "0" ) {
- $new_types[] = $type;
+function _exif_get_exif($fid) {
+ $data = array();
+ if ($result = db_query('SELECT * FROM {exif} WHERE fid = %d', $fid)) {
+ while ($row = db_fetch_object($result)) {
+ $data[$row->ifd][$row->tag] = $row->value;
}
}
- if (in_array($node_type, $new_types)) {
- return TRUE;
- }
- return FALSE;
+
+ return $data;
}
/**
- * From a given node we are going to get the imagepath of the image. if it's an image node
- * it's just going to be images[IMAGE_ORIGINAL]. If it's an imagefield node, we have to go
- * through the fields and look if there is an imagefield and then return the path
- *
- * @param $fields
- * @param $node
- * @return unknown_type
+ * Reads exif data from a file.
*/
-function _exif_get_image_path($fields, &$node) {
- if ($node->type == 'image') {
- return $node->images[IMAGE_ORIGINAL];
+function _exif_read_exif($file) {
+ _exif_bootstrap();
+ $data = array();
+ if (!file_exists($file)) {
+ watchdog('exif', t('Image %file not found.', array('%file' => $file)), WATCHDOG_WARNING);
+ return $exif;
}
-
- foreach ($fields as $field) {
- if ($field['type'] == 'filefield') {
- $tmp = $node->$field['field_name'];
- return $tmp[0]['filepath'];
+ if (exif_imagetype($file) != IMAGETYPE_JPEG) {
+ return $data;
+ }
+ $jpeg = new PelJpeg($file);
+ $exif = $jpeg->getExif();
+ if (!$exif) {
+ return $data;
+ }
+ $tiff = $exif->getTiff();
+ if (!$tiff) {
+ return $data;
+ }
+ $ifd0 = $tiff->getIfd();
+ if (!$ifd0) {
+ return $data;
+ }
+ $ifds[PelIfd::IFD0] = $ifd0;
+ if ($exif = $ifd0->getSubIfd(PelIfd::EXIF)) {
+ $ifds[PelIfd::EXIF] = $exif;
+ }
+ if ($gps = $ifd0->getSubIfd(PelIfd::GPS)) {
+ $ifds[PelIfd::GPS] = $gps;
+ }
+ $tags = exif_get_enabled_tags();
+ $data = array();
+ foreach ($tags as $tag) {
+ $entry = $ifds[$tag->ifd]->getEntry($tag->tag);
+ if ($entry) {
+ $row = array();
+ switch($tag->tag) {
+ case PelTag::DATE_TIME:
+ case PelTag::DATE_TIME_ORIGINAL:
+ case PelTag::DATE_TIME_DIGITIZED:
+ // Return a unixtimestamp. Theme will handle date formating.
+ $data[$tag->ifd][$tag->tag] = $entry->getValue();
+ break;
+
+ default:
+ $data[$tag->ifd][$tag->tag] = utf8_encode($entry->getText());
+ }
}
}
- return NULL;
+ return $data;
}
-
/**
- * Helper function to reformat fields where required.
- *
- * Some values (lat/lon) break down into structures, not strings.
+ * Return an array containing only the tags that were enabled.
*/
-function _exif_reformat($data) {
- $date_array = array('datetimeoriginal', 'datetime', 'datetimedigitized');
+function exif_get_enabled_tags() {
+ static $tags = array();
- // Make the key lowercase as CCK field names must be
- $data = array_change_key_case($data, CASE_LOWER);
-
- foreach ($data as $key => &$value) {
- if (is_array($value)) {
- $value = array_change_key_case($value, CASE_LOWER);
+ if (!count($tags)) {
+ $result = db_query('SELECT * FROM {exif_tags} WHERE status = 1');
+ while ($tag = db_fetch_object($result)) {
+ $tags[] = $tag;
}
-
- // Check for individual keys
- switch ($key) {
- case 'gpslatitude':
- $value = _exif_DMS2D($value, $data['gpslatituderef']);
- break;
-
- case 'gpslongitude':
- $value = _exif_DMS2D($value, $data['gpslongituderef']);
- break;
-
- case 'gps_gpslatitude':
- $value = _exif_DMS2D($value, $data['gps_gpslatituderef']);
- break;
-
- case 'gps_gpslongitude':
- $value = _exif_DMS2D($value, $data['gps_gpslongituderef']);
- break;
-
+ if (!count($tags)) {
+ // Table is empty, get some defaults
+ $tags = exif_get_default_settings();
+ foreach ($tags as $key => $tag) {
+ if (!$tag->status) {
+ unset($tags[$key]);
+ }
+ }
}
+ usort($tags, '_exif_compare_tags');
}
- return $data;
+
+ return $tags;
}
/**
- * Helper function to change GPS co-ords into decimals.
+ * Return an array with all the valid tags and their settings.
*/
-function _exif_DMS2D($value, $ref) {
- $parts = split('/', $value[0]);
- $dec = (float) ((float) $parts[0] / (float) $parts[1]);
+function exif_load_settings() {
+ $tags = exif_get_default_settings();
- $parts = split('/', $value[1]);
- $dec += (float) (((float) $parts[0] / (float) $parts[1]) / 60);
+ $result = db_query('SELECT * FROM {exif_tags}');
+ while ($tag = db_fetch_object($result)) {
+ $tags["{$tag->ifd}_{$tag->tag}"] = $tag;
+ }
+ usort($tags, '_exif_compare_tags');
- $parts = split('/', $value[2]);
- $dec += (float) (((float) $parts[0] / (float) $parts[1]) / 3600);
+ return $tags;
+}
+
+function exif_save_settings($values) {
+ db_lock_table('exif_tags');
+ foreach ($values as $tag) {
+ if (!is_array($tag) || !isset($tag['ifd'])) {
+ continue; // Save only appropriate form values
+ }
+ db_query('DELETE FROM {exif_tags} WHERE ifd = %d AND tag = %d', $tag['ifd'], $tag['tag']);
+ db_query('INSERT INTO {exif_tags} (ifd, tag, status, weight) VALUES (%d, %d, %d, %d)', $tag['ifd'], $tag['tag'], $tag['status'], $tag['weight']);
+ }
+ db_unlock_tables();
+}
- if ($ref == 'S' || $ref == 'W') $dec *= -1;
- return $dec;
+function exif_reset_settings() {
+ db_query('DELETE FROM {exif_tags}');
}
/**
- * Helper function to get the exif class
- * @return Exif
+ * Return an array with all the valid tags, with some useful default settings.
*/
-function _exif_get_class() {
- include_once drupal_get_path('module', 'exif') .'/exif.class.php';
- $exif = Exif::getInstance();
- return $exif;
+function exif_get_default_settings() {
+ $tags = exif_get_valid_tags();
+ $tags[PelIfd::EXIF .'_'. PelTag::DATE_TIME_ORIGINAL]->status = 1;
+ $tags[PelIfd::EXIF .'_'. PelTag::DATE_TIME_ORIGINAL]->weight = -10;
+ $tags[PelIfd::IFD0 .'_'. PelTag::MODEL]->status = 1;
+ $tags[PelIfd::IFD0 .'_'. PelTag::MODEL]->weight = -8;
+ $tags[PelIfd::EXIF .'_'. PelTag::FOCAL_LENGTH]->status = 1;
+ $tags[PelIfd::EXIF .'_'. PelTag::FOCAL_LENGTH]->weight = -6;
+ $tags[PelIfd::EXIF .'_'. PelTag::APERTURE_VALUE]->status = 1;
+ $tags[PelIfd::EXIF .'_'. PelTag::APERTURE_VALUE]->weight = -4;
+ $tags[PelIfd::EXIF .'_'. PelTag::EXPOSURE_TIME]->status = 1;
+ $tags[PelIfd::EXIF .'_'. PelTag::EXPOSURE_TIME]->weight = -2;
+ $tags[PelIfd::EXIF .'_'. PelTag::ISO_SPEED_RATINGS]->status = 1;
+ $tags[PelIfd::EXIF .'_'. PelTag::ISO_SPEED_RATINGS]->weight = 0;
+ return $tags;
}
/**
- * Implementation of hook_hoken_list
- * @param array $type
+ * Helper function to return all the valid tags (well, at least those this module cares about).
+ *
+ * For convenience, each tag has a key in the form: "ifd_tag", where ifd and tag
+ * are standard Exif ids. Those ids can be found in PelIfd.php and PelTag.php.
*/
-function fast_gallery_token_list($type = 'node') {
- if ($type == 'node') {
- $exif = _exif_get_class();
- $ar_iptc = $exif->getHumanReadableIPTCkey();
- foreach ($ar_iptc as $iptc) {
- $tokens['iptc']['iptc_' . $iptc] = 'IPTC Field: ' . $iptc;
+function exif_get_valid_tags() {
+ $valid_tags = array();
+ $valid_tags = array_merge($valid_tags, _exif_get_valid_ifd_tags(PelIfd::IFD0, new PelIfd(PelIfd::IFD0)));
+ $valid_tags = array_merge($valid_tags, _exif_get_valid_ifd_tags(PelIfd::EXIF, new PelIfd(PelIfd::EXIF)));
+ $valid_tags = array_merge($valid_tags, _exif_get_valid_ifd_tags(PelIfd::GPS, new PelIfd(PelIfd::GPS)));
+ return $valid_tags;
+}
+
+function _exif_get_valid_ifd_tags($ifd_id, $ifd) {
+ $tags = array();
+ $pel_tags = $ifd->getValidTags();
+ foreach ($pel_tags as $pel_tag) {
+ $tag = new StdClass();
+ $tag->ifd = $ifd_id;
+ $tag->tag = $pel_tag;
+ $tags["{$tag->ifd}_{$tag->tag}"] = $tag;
+ }
+ return $tags;
+}
+
+function _exif_compare_tags($a, $b) {
+ $status = $b->status - $a->status;
+ // Separate enabled from disabled.
+ if ($status) {
+ return $status;
+ }
+ // Enabled tags
+ if ($a->status) {
+ $weight = $a->weight - $b->weight;
+ if ($weight) {
+ return $weight;
}
- return $tokens;
+ return $a->ifd - $b->ifd;
+ }
+ // Disabled tags
+ else {
+ return $a->ifd - $b->ifd;
}
}
-/**
- * implementation of hook_token_values
- * @param unknown_type $type
- * @param unknown_type $object
- * @param unknown_type $options
- */
-function fast_gallery_token_values($type, $object = NULL, $options = array()) {
- if ($type == 'node') {
- $node = $object;
- $exif = _exif_get_class();
- $ar_iptc = $exif->getHumanReadableIPTCkey();
-
- $info = content_types($node->type);
- $fields = $info['fields'];
- //get the path to the image
- $image_path = _exif_get_image_path($fields, $node);
-
- //dsm("start reading");
- $iptc_values = $exif->readIPTCTags($image_path, array(), array('style' => 'fullSmall'));
- //dsm($iptc_values);
-
- // TODO: needs to be finished
- foreach ($iptc_values as $key => $iptc) {
- $tokens['iptc_' . $key] = 'IPTC Field: ' . utf8_encode($iptc);
+function theme_exif_table($node) {
+ _exif_bootstrap();
+ // Retrieve the desired tag values from the file
+ $tags = exif_get_enabled_tags();
+ $rows = array();
+ $data = $node->exif_data;
+
+ foreach ($tags as $tag) {
+ if (!empty($data[$tag->ifd][$tag->tag])) {
+ $row = array();
+ $row[] = array('data' => check_plain(utf8_encode(PelTag::getTitle($tag->ifd, $tag->tag))), 'class' => 'exif-title');
+ $val = $data[$tag->ifd][$tag->tag];
+ switch($tag->tag) {
+ case PelTag::DATE_TIME:
+ case PelTag::DATE_TIME_ORIGINAL:
+ case PelTag::DATE_TIME_DIGITIZED:
+ // Use Drupal's date formatting instead of Pel's
+ $row[] = array('data' => format_date($val, 'medium', '', 0), 'class' => 'exif-value');
+ break;
+
+ default:
+ $row[] = array('data' => check_plain($val), 'class' => 'exif-value');
+ }
+ $rows[] = $row;
}
- //dsm($tokens);
- return $tokens;
}
+<<<<<<< exif.module
+}
+=======
+
+ if (empty($rows)) {
+ return '';
+ }
+ $header = array(array('data' => t('Image information'), 'colspan' => 2));
+ return theme('table', $header, $rows, array('class' => 'exif'));
}
+
+function theme_exif_admin_settings_form($form) {
+ $header = array(t('Tag'), t('Weight'), t('Type'));
+ $rows = array();
+ foreach (element_children($form['tags']) as $key) {
+ $row = array();
+ $row[] = drupal_render($form['tags'][$key]['status']);
+ $row[] = drupal_render($form['tags'][$key]['weight']);
+ $row[] = drupal_render($form['tags'][$key]['type']);
+ $rows[] = $row;
+ }
+ $output .= theme('table', $header, $rows, array('class' => 'admin-settings-exif'));
+ $output .= drupal_render($form);
+ return $output;
+}
+
+function _exif_bootstrap() {
+ include_once drupal_get_path('module', 'exif') .'/pel/PelJpeg.php';
+}
+
+>>>>>>> 1.9
diff --git a/exif_helper/CVS/Entries b/exif_helper/CVS/Entries
deleted file mode 100644
index 7c17ed2..0000000
--- a/exif_helper/CVS/Entries
+++ /dev/null
@@ -1,3 +0,0 @@
-/exif_helper.info/1.1.2.1/Thu Feb 5 20:11:53 2009/-kb/TDRUPAL-6--1
-/exif_helper.module/1.1.2.2/Fri Mar 19 22:17:00 2010//TDRUPAL-6--1
-D
diff --git a/exif_helper/CVS/Repository b/exif_helper/CVS/Repository
deleted file mode 100644
index 3908928..0000000
--- a/exif_helper/CVS/Repository
+++ /dev/null
@@ -1 +0,0 @@
-contributions/modules/exif/exif_helper
diff --git a/exif_helper/CVS/Root b/exif_helper/CVS/Root
deleted file mode 100644
index 127da18..0000000
--- a/exif_helper/CVS/Root
+++ /dev/null
@@ -1 +0,0 @@
-:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal-contrib
diff --git a/exif_helper/CVS/Tag b/exif_helper/CVS/Tag
deleted file mode 100644
index d7ee0a3..0000000
--- a/exif_helper/CVS/Tag
+++ /dev/null
@@ -1 +0,0 @@
-TDRUPAL-6--1
diff --git a/exif_helper/exif_helper.info b/exif_helper/exif_helper.info
deleted file mode 100644
index a63c51e..0000000
--- a/exif_helper/exif_helper.info
+++ /dev/null
@@ -1,5 +0,0 @@
-; $Id:
-name = Exif Helper
-description = "Some helper functions."
-package = Image
-core = 6.x \ No newline at end of file
diff --git a/exif_helper/exif_helper.module b/exif_helper/exif_helper.module
deleted file mode 100644
index e19ca5f..0000000
--- a/exif_helper/exif_helper.module
+++ /dev/null
@@ -1,80 +0,0 @@
-<?php
-// $Id: exif_helper.module,v 1.1.2.2 2010/03/19 22:17:00 rapsli Exp $
-
-/**
- * @file Intention of this little module: exif.module needs to have a weight of -10
- * at least it has to be processed before CCK is processed, so that EXIF information
- * can be taken from the fields and be written into the CCK fields.
- *
- * Problem: We don't want to display the emty fields on node creation, since they are
- * reserved for exif information -> we don't want to confuse users with this, so are
- * going to make them hidden -> Information needs to be processed AFTER CCK.
- *
- * Solution: Creating a new little module.
- */
-
-function exif_helper_menu() {
- $items['admin/settings/exif/visibility'] = array(
- 'title' => 'visibility',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('exif_helper_settings_form'),
- 'access arguments' => array('administer site configuration'),
- 'description' => t('Some visibility settings'),
- 'access callback' => 'user_access',
- 'type' => MENU_LOCAL_TASK,
- );
- return $items;
-}
-
-/**
- * implementation of hook_form_alter
- * @param $form_id
- * @param $form
- */
-function exif_helper_form_alter(&$form, $form_state, $form_id) {
-
- if ($form['#id'] != 'node-form') {
- return;
- }
-
- $ar_keys = array();
- foreach ($form as $key => $value) {
- $ar_keys[] = array('field_name' => $key);
- }
- $exif = _exif_get_class();
- $ar_exif_fields = $exif->getExifFields($ar_keys);
- $node = $form['#node'];
-
- if (($node->nid > 0 && variable_get('exif_helper_show_on_update', 0)==0) ||
- (!isset($node->nid) && variable_get('exif_helper_show_on_creation', 0) == 0)) {
- foreach ($ar_exif_fields as $variable) {
- $form["field_" . $variable['section'] . "_" . $variable['tag']]['#type'] = 'hidden';
- }
- }
-
-}
-
-/**
- * Form definition for the admin of the helper module
- */
-function exif_helper_settings_form() {
- $form['exif_helper'] = array(
- '#value' => t('When a user creates a node by default the CCK information will not be shown.
- This doesn\'t make any sense and would only confuse the user. The values for those fields
- is taken from the picture it-self. Nevertheless the information is visibile when you display
- the node just plain or through views or whatever. We are just talking here about the actual
- creation form'),
- );
- $form['exif_helper_show_on_creation'] = array(
- '#type' => 'checkbox',
- '#title' => t('Show CCK Fields on Node-Creation form'),
- '#default_value' => variable_get('exif_helper_show_on_creation', 0),
- );
-
- $form['exif_helper_show_on_update'] = array(
- '#type' => 'checkbox',
- '#title' => t('Show CCK Fields on Node-Update form'),
- '#default_value' => variable_get('exif_helper_show_on_update', 0),
- );
- return system_settings_form($form);
-} \ No newline at end of file
diff --git a/exif_location/CVS/Entries b/exif_location/CVS/Entries
index 46167ab..61c0fea 100644
--- a/exif_location/CVS/Entries
+++ b/exif_location/CVS/Entries
@@ -1,4 +1,4 @@
-/exif_location.info/1.1.2.2/Tue Jan 26 20:28:23 2010//TDRUPAL-6--1
-/exif_location.install/1.1.2.3/Fri Mar 19 22:17:00 2010//TDRUPAL-6--1
-/exif_location.module/1.1.2.3/Fri Mar 19 22:17:00 2010//TDRUPAL-6--1
+/exif_location.info/1.1/Thu Oct 7 21:44:03 2010//
+/exif_location.install/1.1/Thu Oct 7 21:44:03 2010//
+/exif_location.module/1.1/Thu Oct 7 21:44:03 2010//
D
diff --git a/exif_location/CVS/Tag b/exif_location/CVS/Tag
deleted file mode 100644
index d7ee0a3..0000000
--- a/exif_location/CVS/Tag
+++ /dev/null
@@ -1 +0,0 @@
-TDRUPAL-6--1
diff --git a/exif_location/exif_location.info b/exif_location/exif_location.info
index 3702dbb..1eaa37a 100644
--- a/exif_location/exif_location.info
+++ b/exif_location/exif_location.info
@@ -1,6 +1,5 @@
name = EXIF Location
description = "Sets a node location based on EXIF info in image."
core = 6.x
-version = "6.x-0.1"
dependencies[] = exif
diff --git a/exif_location/exif_location.install b/exif_location/exif_location.install
index 31fc3e8..a1fb871 100644
--- a/exif_location/exif_location.install
+++ b/exif_location/exif_location.install
@@ -1,9 +1,4 @@
<?php
-// $Id: exif_location.install,v 1.1.2.3 2010/03/19 22:17:00 rapsli Exp $
-
-/**
- * @file This is the exif location install part
- */
/*
* Hook sets weight must be less than exif module (zero by default).
@@ -13,3 +8,5 @@ function exif_location_install() {
$ret[] = db_query("UPDATE {system} SET weight = 2 WHERE name = 'exif_location'");
return $ret;
}
+
+?>
diff --git a/exif_location/exif_location.module b/exif_location/exif_location.module
index 98b081d..f0d5093 100644
--- a/exif_location/exif_location.module
+++ b/exif_location/exif_location.module
@@ -1,15 +1,11 @@
<?php
-// $Id: exif_location.module,v 1.1.2.3 2010/03/19 22:17:00 rapsli Exp $
-/**
- * implementation of hook_nodeapi
- * @param stdClass $node
- * @param string $op
- * @param string $a3
- * @param string $a4
+/*
+ * Hook nodeapi.
*/
+
function exif_location_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
- switch ($op) {
+ switch($op) {
case 'presave':
$lid = 0;
/* Go get the location from EXIF fields */
@@ -24,8 +20,7 @@ function exif_location_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
*/
$node->locations[$lid]['longitude'] = $longitude;
$node->locations[$lid]['latitude'] = $latitude;
- }
- else {
+ } else {
$node->locations[$lid] =
array(
'longitude' => $longitude,
@@ -45,12 +40,10 @@ function exif_location_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
}
}
-/**
- * Implementation of hook_form_alter
- * @param array $form
- * @param array $form_state
- * @param array $form_id
+/*
+ * Hook form_alter.
*/
+
function exif_location_form_alter(&$form, $form_state, $form_id) {
/* Comment out the return below to enable this */
return;
@@ -61,3 +54,5 @@ function exif_location_form_alter(&$form, $form_state, $form_id) {
$form['locations']['#access'] = FALSE;
}
}
+
+?>
diff --git a/sample.jpg b/sample.jpg
deleted file mode 100644
index efa94ad..0000000
--- a/sample.jpg
+++ /dev/null
Binary files differ