aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.cvsignore2
-rw-r--r--.gitignore1
-rw-r--r--CHANGES.txt51
-rw-r--r--LICENSE.txt274
-rwxr-xr-xREADME.txt63
-rw-r--r--exif.class.php185
-rw-r--r--exif.css3
-rw-r--r--exif.info16
-rwxr-xr-xexif.install26
-rwxr-xr-xexif.module367
-rw-r--r--exif_helper/exif_helper.info11
-rw-r--r--exif_helper/exif_helper.module80
-rw-r--r--exif_location/exif_location.info13
-rw-r--r--exif_location/exif_location.install15
-rw-r--r--exif_location/exif_location.module63
-rw-r--r--sample.jpgbin0 -> 24802 bytes
16 files changed, 1170 insertions, 0 deletions
diff --git a/.cvsignore b/.cvsignore
new file mode 100644
index 0000000..f592eba
--- /dev/null
+++ b/.cvsignore
@@ -0,0 +1,2 @@
+.project
+.buildpath
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..1377554
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+*.swp
diff --git a/CHANGES.txt b/CHANGES.txt
new file mode 100644
index 0000000..3906bdb
--- /dev/null
+++ b/CHANGES.txt
@@ -0,0 +1,51 @@
+// $Id:
+
+FAST GALLERY MODULE CHANGES
+---------------------------
+
+ACKNOWLEDGEMENTS
+----------------
+ * rapsli (Raphael Schär)
+
+
+CHANGES LOG
+-----------
+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/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..2c095c8
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,274 @@
+GNU GENERAL PUBLIC LICENSE
+
+ Version 2, June 1991
+
+Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave,
+Cambridge, MA 02139, USA. Everyone is permitted to copy and distribute
+verbatim copies of this license document, but changing it is not allowed.
+
+ Preamble
+
+The licenses for most software are designed to take away your freedom to
+share and change it. By contrast, the GNU General Public License is
+intended to guarantee your freedom to share and change free software--to
+make sure the software is free for all its users. This General Public License
+applies to most of the Free Software Foundation's software and to any other
+program whose authors commit to using it. (Some other Free Software
+Foundation software is covered by the GNU Library General Public License
+instead.) You can apply it to your programs, too.
+
+When we speak of free software, we are referring to freedom, not price. Our
+General Public Licenses are designed to make sure that you have the
+freedom to distribute copies of free software (and charge for this service if
+you wish), that you receive source code or can get it if you want it, that you
+can change the software or use pieces of it in new free programs; and that
+you know you can do these things.
+
+To protect your rights, we need to make restrictions that forbid anyone to
+deny you these rights or to ask you to surrender the rights. These restrictions
+translate to certain responsibilities for you if you distribute copies of the
+software, or if you modify it.
+
+For example, if you distribute copies of such a program, whether gratis or for
+a fee, you must give the recipients all the rights that you have. You must make
+sure that they, too, receive or can get the source code. And you must show
+them these terms so they know their rights.
+
+We protect your rights with two steps: (1) copyright the software, and (2)
+offer you this license which gives you legal permission to copy, distribute
+and/or modify the software.
+
+Also, for each author's protection and ours, we want to make certain that
+everyone understands that there is no warranty for this free software. If the
+software is modified by someone else and passed on, we want its recipients
+to know that what they have is not the original, so that any problems
+introduced by others will not reflect on the original authors' reputations.
+
+Finally, any free program is threatened constantly by software patents. We
+wish to avoid the danger that redistributors of a free program will individually
+obtain patent licenses, in effect making the program proprietary. To prevent
+this, we have made it clear that any patent must be licensed for everyone's
+free use or not licensed at all.
+
+The precise terms and conditions for copying, distribution and modification
+follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND
+ MODIFICATION
+
+0. This License applies to any program or other work which contains a notice
+placed by the copyright holder saying it may be distributed under the terms
+of this General Public License. The "Program", below, refers to any such
+program or work, and a "work based on the Program" means either the
+Program or any derivative work under copyright law: that is to say, a work
+containing the Program or a portion of it, either verbatim or with
+modifications and/or translated into another language. (Hereinafter, translation
+is included without limitation in the term "modification".) Each licensee is
+addressed as "you".
+
+Activities other than copying, distribution and modification are not covered
+by this License; they are outside its scope. The act of running the Program is
+not restricted, and the output from the Program is covered only if its contents
+constitute a work based on the Program (independent of having been made
+by running the Program). Whether that is true depends on what the Program
+does.
+
+1. You may copy and distribute verbatim copies of the Program's source
+code as you receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice and
+disclaimer of warranty; keep intact all the notices that refer to this License
+and to the absence of any warranty; and give any other recipients of the
+Program a copy of this License along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and you
+may at your option offer warranty protection in exchange for a fee.
+
+2. You may modify your copy or copies of the Program or any portion of it,
+thus forming a work based on the Program, and copy and distribute such
+modifications or work under the terms of Section 1 above, provided that you
+also meet all of these conditions:
+
+a) You must cause the modified files to carry prominent notices stating that
+you changed the files and the date of any change.
+
+b) You must cause any work that you distribute or publish, that in whole or in
+part contains or is derived from the Program or any part thereof, to be
+licensed as a whole at no charge to all third parties under the terms of this
+License.
+
+c) If the modified program normally reads commands interactively when run,
+you must cause it, when started running for such interactive use in the most
+ordinary way, to print or display an announcement including an appropriate
+copyright notice and a notice that there is no warranty (or else, saying that
+you provide a warranty) and that users may redistribute the program under
+these conditions, and telling the user how to view a copy of this License.
+(Exception: if the Program itself is interactive but does not normally print such
+an announcement, your work based on the Program is not required to print
+an announcement.)
+
+These requirements apply to the modified work as a whole. If identifiable
+sections of that work are not derived from the Program, and can be
+reasonably considered independent and separate works in themselves, then
+this License, and its terms, do not apply to those sections when you distribute
+them as separate works. But when you distribute the same sections as part
+of a whole which is a work based on the Program, the distribution of the
+whole must be on the terms of this License, whose permissions for other
+licensees extend to the entire whole, and thus to each and every part
+regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest your rights to
+work written entirely by you; rather, the intent is to exercise the right to
+control the distribution of derivative or collective works based on the
+Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of a
+storage or distribution medium does not bring the other work under the scope
+of this License.
+
+3. You may copy and distribute the Program (or a work based on it, under
+Section 2) in object code or executable form under the terms of Sections 1
+and 2 above provided that you also do one of the following:
+
+a) Accompany it with the complete corresponding machine-readable source
+code, which must be distributed under the terms of Sections 1 and 2 above
+on a medium customarily used for software interchange; or,
+
+b) Accompany it with a written offer, valid for at least three years, to give
+any third party, for a charge no more than your cost of physically performing
+source distribution, a complete machine-readable copy of the corresponding
+source code, to be distributed under the terms of Sections 1 and 2 above on
+a medium customarily used for software interchange; or,
+
+c) Accompany it with the information you received as to the offer to distribute
+corresponding source code. (This alternative is allowed only for
+noncommercial distribution and only if you received the program in object
+code or executable form with such an offer, in accord with Subsection b
+above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source code
+means all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation and
+installation of the executable. However, as a special exception, the source
+code distributed need not include anything that is normally distributed (in
+either source or binary form) with the major components (compiler, kernel,
+and so on) of the operating system on which the executable runs, unless that
+component itself accompanies the executable.
+
+If distribution of executable or object code is made by offering access to
+copy from a designated place, then offering equivalent access to copy the
+source code from the same place counts as distribution of the source code,
+even though third parties are not compelled to copy the source along with the
+object code.
+
+4. You may not copy, modify, sublicense, or distribute the Program except as
+expressly provided under this License. Any attempt otherwise to copy,
+modify, sublicense or distribute the Program is void, and will automatically
+terminate your rights under this License. However, parties who have received
+copies, or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+5. You are not required to accept this License, since you have not signed it.
+However, nothing else grants you permission to modify or distribute the
+Program or its derivative works. These actions are prohibited by law if you
+do not accept this License. Therefore, by modifying or distributing the
+Program (or any work based on the Program), you indicate your acceptance
+of this License to do so, and all its terms and conditions for copying,
+distributing or modifying the Program or works based on it.
+
+6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the original
+licensor to copy, distribute or modify the Program subject to these terms and
+conditions. You may not impose any further restrictions on the recipients'
+exercise of the rights granted herein. You are not responsible for enforcing
+compliance by third parties to this License.
+
+7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues), conditions
+are imposed on you (whether by court order, agreement or otherwise) that
+contradict the conditions of this License, they do not excuse you from the
+conditions of this License. If you cannot distribute so as to satisfy
+simultaneously your obligations under this License and any other pertinent
+obligations, then as a consequence you may not distribute the Program at all.
+For example, if a patent license would not permit royalty-free redistribution
+of the Program by all those who receive copies directly or indirectly through
+you, then the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply and
+the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any patents or
+other property right claims or to contest validity of any such claims; this
+section has the sole purpose of protecting the integrity of the free software
+distribution system, which is implemented by public license practices. Many
+people have made generous contributions to the wide range of software
+distributed through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing to
+distribute software through any other system and a licensee cannot impose
+that choice.
+
+This section is intended to make thoroughly clear what is believed to be a
+consequence of the rest of this License.
+
+8. If the distribution and/or use of the Program is restricted in certain
+countries either by patents or by copyrighted interfaces, the original copyright
+holder who places the Program under this License may add an explicit
+geographical distribution limitation excluding those countries, so that
+distribution is permitted only in or among countries not thus excluded. In such
+case, this License incorporates the limitation as if written in the body of this
+License.
+
+9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will be
+similar in spirit to the present version, but may differ in detail to address new
+problems or concerns.
+
+Each version is given a distinguishing version number. If the Program specifies
+a version number of this License which applies to it and "any later version",
+you have the option of following the terms and conditions either of that
+version or of any later version published by the Free Software Foundation. If
+the Program does not specify a version number of this License, you may
+choose any version ever published by the Free Software Foundation.
+
+10. If you wish to incorporate parts of the Program into other free programs
+whose distribution conditions are different, write to the author to ask for
+permission. For software which is copyrighted by the Free Software
+Foundation, write to the Free Software Foundation; we sometimes make
+exceptions for this. Our decision will be guided by the two goals of
+preserving the free status of all derivatives of our free software and of
+promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE,
+THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT
+PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
+STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
+WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
+PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
+NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR
+AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR
+ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE
+LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL,
+SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
+ARISING OUT OF THE USE OR INABILITY TO USE THE
+PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA
+OR DATA BEING RENDERED INACCURATE OR LOSSES
+SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE
+PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN
+IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
diff --git a/README.txt b/README.txt
new file mode 100755
index 0000000..a0d5173
--- /dev/null
+++ b/README.txt
@@ -0,0 +1,63 @@
+// $Id:
+
+README file for the Exif Drupal module.
+
+
+Description
+***********
+
+The Exif module allows to display Exif metadata on image nodes. Exif is a
+specification for the image file format used by digital cameras.
+
+The metadata tags defined in the Exif standard cover a broad spectrum including [1]:
+
+ * Date and time information. Digital cameras will record the current date and
+ time and save this in the metadata.
+ * Camera settings. This includes static information such as the camera model
+ and make, and information that varies with each image such as orientation,
+ aperture, shutter speed, focal length, metering mode, and film speed
+ information.
+ * Location information, which could come from a GPS receiver connected to the
+ camera.
+ * Descriptions and copyright information.
+
+Administrators can choose via CCK fields which Exif information are read.
+
+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
+****************************
+
+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!
+
+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.
+
+
+Usage
+************
+
+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:
+
+Example:
+#1 field_exif_exposuretime -> this would read the ExposureTime of the image and save it
+in this field.
+
+#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.
+
+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.class.php b/exif.class.php
new file mode 100644
index 0000000..92c18fc
--- /dev/null
+++ b/exif.class.php
@@ -0,0 +1,185 @@
+<?php
+//$Id:
+
+/**
+ *
+ * @author Raphael Schär
+ * This is a helper class to handle the whole data processing of exif
+ *
+ */
+Class Exif {
+ static private $instance = NULL;
+
+ /**
+ * We are implementing a singleton pattern
+ */
+ private function __construct() {
+ }
+
+ public function getInstance() {
+ if(is_null(self::$instance)) {
+ self::$instance = new self;
+ }
+ return self::$instance;
+ }
+
+ /**
+ * Going through all the fields that have been created for a given node type
+ * and try to figure out which match the naming convention -> so that we know
+ * which exif information we have to read
+ *
+ * Naming convention are: field_exif_xxx (xxx would be the name of the exif
+ * tag to read
+ *
+ * @param $arCckFields array of CCK fields
+ * @return array a list of exif tags to read for this image
+ */
+ public function getExifFields($arCckFields=array()) {
+ $arSections = array('exif', 'file', 'computed', 'ifd0', 'gps', 'winxp', 'iptc');
+ $arExif = array();
+
+ foreach ($arCckFields as $field) {
+ $ar = explode("_", $field['field_name']);
+ if ($ar[0] == 'field' && isset($ar[1]) && in_array($ar[1], $arSections)) {
+ unset($ar[0]);
+ $section = $ar[1];
+ unset($ar[1]);
+ $arExif[] = array('section'=>$section, 'tag'=>implode("_", $ar));
+ }
+ }
+ return $arExif;
+ }
+
+ /**
+ * Read the Information from a picture according to the fields specified in CCK
+ * @param $file
+ * @param $arTagNames
+ * @return array
+ */
+ public function readExifTags($file, $arTagNames=array()) {
+ if (!file_exists($file)) {
+ return array();
+ }
+
+ $ar_supported_types = array('jpg', 'jpeg');
+ if (!in_array(strtolower($this->getFileType($file)), $ar_supported_types)) {
+ return array();
+ }
+ $exif = exif_read_data($file, 0);
+ $arSmallExif = array();
+ foreach ((array)$exif as $key => $value) {
+ $arSmallExif[strtolower($key)] = $value;
+ }
+ $info = array();
+
+ foreach ($arTagNames as $tagName) {
+ if ($tagName['section'] != 'iptc' && !empty($arSmallExif[$tagName['tag']])) {
+ $info[$tagName['section'] .'_'. $tagName['tag']] = $arSmallExif[$tagName['tag']];
+ }
+ }
+ return $info;
+ }
+
+ private function getFileType($file) {
+ $ar = explode('.', $file);
+ $ending = $ar[count($ar)-1];
+ return $ending;
+ }
+
+ public function readIPTCTags($file, $arTagNames=array()) {
+ $humanReadableKey = $this->getHumanReadableIPTCkey();
+ $size = GetImageSize ($file, $infoImage);
+ $iptc = empty($infoImage["APP13"]) ? array() : iptcparse($infoImage["APP13"]);
+ $arSmallIPTC = array();
+ if (is_array($iptc)) {
+ foreach($iptc as $key => $value)
+ {
+ $resultTag = "";
+ foreach($value as $innerkey => $innervalue)
+ {
+ if( ($innerkey+1) != count($value) ) {
+ $resultTag .= $innervalue . ", ";
+ }
+ else {
+ $resultTag .= $innervalue;
+ }
+ }
+ $arSmallIPTC[$humanReadableKey[$key]] = $resultTag;
+ }
+ }
+ $info = array();
+ foreach ($arTagNames as $tagName) {
+ if ($tagName['section'] == "iptc") {
+ $info[$tagName['section'] .'_'. $tagName['tag']] = $arSmallIPTC[$tagName['tag']];
+ }
+ }
+ return $info;
+ }
+
+ /**
+ * Just some little helper function to get the iptc fields
+ * @return array
+ *
+ */
+ public function getHumanReadableIPTCkey() {
+ return array(
+ "2#202" => "object_data_preview_data",
+ "2#201" => "object_data_preview_file_format_version",
+ "2#200" => "object_data_preview_file_format",
+ "2#154" => "audio_outcue",
+ "2#153" => "audio_duration",
+ "2#152" => "audio_sampling_resolution",
+ "2#151" => "audio_sampling_rate",
+ "2#150" => "audio_type",
+ "2#135" => "language_identifier",
+ "2#131" => "image_orientation",
+ "2#130" => "image_type",
+ "2#125" => "rasterized_caption",
+ "2#122" => "writer",
+ "2#120" => "caption",
+ "2#118" => "contact",
+ "2#116" => "copyright_notice",
+ "2#115" => "source",
+ "2#110" => "credit",
+ "2#105" => "headline",
+ "2#103" => "original_transmission_reference",
+ "2#101" => "country_name",
+ "2#100" => "country_code",
+ "2#095" => "state",
+ "2#092" => "sublocation",
+ "2#090" => "city",
+ "2#085" => "by_line_title",
+ "2#080" => "by_line",
+ "2#075" => "object_cycle",
+ "2#070" => "program_version",
+ "2#065" => "originating_program",
+ "2#063" => "digital_creation_time",
+ "2#062" => "digital_creation_date",
+ "2#060" => "creation_time",
+ "2#055" => "creation_date",
+ "2#050" => "reference_number",
+ "2#047" => "reference_date",
+ "2#045" => "reference_service",
+ "2#042" => "action_advised",
+ "2#040" => "special_instruction",
+ "2#038" => "expiration_time",
+ "2#037" => "expiration_date",
+ "2#035" => "release_time",
+ "2#030" => "release_date",
+ "2#027" => "content_location_name",
+ "2#026" => "content_location_code",
+ "2#025" => "keywords",
+ "2#022" => "fixture_identifier",
+ "2#020" => "supplemental_category",
+ "2#015" => "category",
+ "2#010" => "subject_reference",
+ "2#010" => "urgency",
+ "2#008" => "editorial_update",
+ "2#007" => "edit_status",
+ "2#005" => "object_name",
+ "2#004" => "object_attribute_reference",
+ "2#003" => "object_type_reference",
+ "2#000" => "record_version"
+ );
+ }
+} \ No newline at end of file
diff --git a/exif.css b/exif.css
new file mode 100644
index 0000000..37686fa
--- /dev/null
+++ b/exif.css
@@ -0,0 +1,3 @@
+.tag_type{
+ background-color: gray !important;
+} \ No newline at end of file
diff --git a/exif.info b/exif.info
new file mode 100644
index 0000000..fa51805
--- /dev/null
+++ b/exif.info
@@ -0,0 +1,16 @@
+; $Id: exif.info,v 1.4.2.2 2009/02/05 20:11:54 rapsli Exp $
+name = Exif
+description = "Display Exif metadata on image nodes."
+dependencies[] = content
+dependencies[] = text
+dependencies[] = exif_helper
+package = Image
+core = 6.x
+
+
+; Information added by drupal.org packaging script on 2010-03-19
+version = "6.x-1.3-alpha1"
+core = "6.x"
+project = "exif"
+datestamp = "1269037207"
+
diff --git a/exif.install b/exif.install
new file mode 100755
index 0000000..0071310
--- /dev/null
+++ b/exif.install
@@ -0,0 +1,26 @@
+<?php
+// $Id: exif.install,v 1.4.2.5 2010/03/19 22:17:00 rapsli Exp $
+/**
+ * @file the install part of the module
+*/
+
+/**
+ * Implementation of hook_install().
+ */
+function exif_install() {
+ db_query("UPDATE {system} SET weight = %d WHERE name = '%s'", -10, 'exif');
+}
+
+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,
+ );
+ }
+ }
+ return $requirements;
+} \ No newline at end of file
diff --git a/exif.module b/exif.module
new file mode 100755
index 0000000..cdbcd23
--- /dev/null
+++ b/exif.module
@@ -0,0 +1,367 @@
+<?php
+// $Id: exif.module,v 1.9.2.13 2010/03/19 22:17:00 rapsli Exp $:
+
+/**
+ * @file implementing the drupal api
+ */
+/**
+ * @author: Raphael Schär - www.rapsli.ch
+ */
+
+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',
+ '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',
+ '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',
+ 'type' => MENU_LOCAL_TASK,
+ );
+ return $items;
+}
+
+/**
+ * The form definition for the admin settings
+ * @return array
+ * form definition
+ */
+function exif_admin_settings_form() {
+ $forms = array();
+ /*$forms['exif_granularity'] = array(
+ '#type' => 'select',
+ '#title' => t('Granularity'),
+ '#options' => array(0 => t('Default'), 1 => ('Day')),
+ '#default_value' => variable_get('exif_granularity', 0),
+ '#description' => t('If a timestamp is select (for example the date the picture was taken), you can specify here how granular the timestamp should be. If you select default it will just take whatever is available in the picture. If you select Day, the Date saved will look something like 13-12-2008. This can be useful if you want to use some kind of grouping on the data.'),
+ );*/
+
+ $all_nodetypes = node_get_types();
+ $all_nt = array();
+ foreach ($all_nodetypes as $item) {
+ $all_nt[$item->type] = $item->name;
+ }
+ $forms['exif_nodetypes'] = array(
+ '#type' => 'checkboxes',
+ '#title' => t('Nodetypes'),
+ '#options' => $all_nt,
+ '#default_value' => variable_get('exif_nodetypes', array()),
+ '#description' => t('Select nodetypes which should be checked for exif data. Incase the nodetypes contains more than one filefield, make sure that the imagefield is the first one!!!!'),
+ );
+
+ $forms['exif_update'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Refresh on node update'),
+ '#default_value' => variable_get('exif_update', TRUE),
+ '#description' => t('If you enable this option, Exif data is being updated when the node is being updated.'),
+ );
+ return system_settings_form($forms);
+}
+/**
+ * implementation of hook_nodeapi
+ */
+function exif_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
+
+ if ($teaser) {
+ return;
+ }
+
+ switch ($op) {
+
+ case 'update':
+ //we are only going to update if we have said so
+ if (!variable_get('exif_update', TRUE)) {
+ break;
+ }
+ case 'insert':
+ if (! _exif_check_for_exif_data($node->type)) {
+ return;
+ }
+ $info = content_types($node->type);
+ $fields = $info['fields'];
+ $exif = _exif_get_class();
+
+ //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);
+ $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) {
+ $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;
+ }
+}
+
+/**
+ * Date API hook.
+ *
+ * Make exif a date format in Date API. This makes it possible to alter the
+ * format exif dates is parsed as.
+ */
+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',
+ ),
+ );
+}
+
+/**
+ * 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);
+ }
+
+ 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));
+ }
+
+ // 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
+ */
+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;
+ }
+ }
+ if (in_array($node_type, $new_types)) {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+/**
+ * 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
+ */
+function _exif_get_image_path($fields, &$node) {
+ if ($node->type == 'image') {
+ return $node->images[IMAGE_ORIGINAL];
+ }
+
+ foreach ($fields as $field) {
+ if ($field['type'] == 'filefield') {
+ $tmp = $node->$field['field_name'];
+ return $tmp[0]['filepath'];
+ }
+ }
+ return NULL;
+}
+
+/**
+ * Just some help page. Gives you an overview over the available tags
+ * @return string html
+ */
+function exif_admin_settings() {
+ drupal_add_css(drupal_get_path('module', 'exif') .'/exif.css');
+ $filepath = drupal_get_path('module', 'exif') .'/sample.jpg';
+ $exif = _exif_get_class();
+ $ar_exif = read_exif_data($filepath, 0, TRUE);
+ // CCK field names must be lowercase
+ $ar_exif = array_change_key_case($ar_exif, CASE_LOWER);
+
+ $out = t('This is an overview over the most common data that is extracted with the exif module. How to read this table: The grey table header would be the key identifier and the following attributes would be the field to read.');
+ $out .= ' ' . t('For example: If you want to import datetimeoriginal into an CCK field, you would name the CCK field field_exif_datetimeoriginal. Since this is a date field you can use a datetime field.');
+ $rows1 = array();
+ $help = t('This would be the keyword for your CCK field.');
+ foreach ($ar_exif as $key => $value) {
+ if (is_array($value)) {
+ $value = _exif_reformat($value);
+ $rows1[] = array('data' => array($key, $help), 'class' => 'tag_type');
+ foreach ($value as $key2 => $value2) {
+ $rows1[] = array('data' => array($key2, check_plain(utf8_encode($value2))));
+ }
+ }
+
+ }
+ $human_readable_key = $exif->getHumanReadableIPTCkey();
+ $size = GetImageSize($filepath, $info_image);
+ $iptc = iptcparse($info_image["APP13"]);
+ $rows2 = array();
+ $help = t('This would be the keyword for your CCK field.');
+ if (is_array($iptc)) {
+ $rows2[] = array('data' => array('IPTC', $help), 'class' => 'tag_type');
+ foreach ($iptc as $key => $value) {
+ $result_tag = "";
+ foreach ($value as $innerkey => $innervalue) {
+ if ( ($innerkey+1) != count($value) ) {
+ $result_tag .= $innervalue .", ";
+ }
+ else {
+ $result_tag .= $innervalue;
+ }
+ }
+ $rows2[] = array('data' => array($human_readable_key[$key], check_plain(utf8_encode($result_tag))));
+ }
+ }
+
+
+ $rows = array_merge($rows1, $rows2);
+ $header = array(t('Key'), t('Value'));
+ $out .= theme('table', $header, $rows, array('id' => 'exif-fields'));
+ // TODO Prevent binary data values from busting the page layout
+ return $out;
+}
+
+
+
+/**
+ * Helper function to reformat fields where required.
+ *
+ * Some values (lat/lon) break down into structures, not strings.
+ */
+function _exif_reformat($data) {
+ $date_array = array('datetimeoriginal', 'datetime', 'datetimedigitized');
+
+ // 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 ($key == 'gps_latitude') {
+ $value = _exif_DMS2D($value, $data['gps_gpslatituderef']);
+ }
+ elseif ($key == 'gps_longitude') {
+ $value = _exif_DMS2D($value, $data['gps_gpslongituderef']);
+ }
+ }
+ return $data;
+}
+
+/**
+ * Helper function to change GPS co-ords into decimals.
+ */
+function _exif_DMS2D($value, $ref) {
+ $parts = split('/', $value[0]);
+ $dec = $parts[0] / $parts[1];
+
+ $parts = split('/', $value[1]);
+ $dec += ($parts[0] / $parts[1]) / 60;
+
+ $parts = split('/', $value[2]);
+ $dec += ($parts[0] / $parts[1]) / 3600;
+
+ if ($ref == 'S' || $ref == 'W') $dec *= -1;
+ return $dec;
+}
+
+/**
+ * Helper function to get the exif class
+ * @return Exif
+ */
+function _exif_get_class() {
+ include_once drupal_get_path('module', 'exif') .'/exif.class.php';
+ $exif = Exif::getInstance();
+ return $exif;
+}
diff --git a/exif_helper/exif_helper.info b/exif_helper/exif_helper.info
new file mode 100644
index 0000000..9222f0d
--- /dev/null
+++ b/exif_helper/exif_helper.info
@@ -0,0 +1,11 @@
+; $Id:
+name = Exif Helper
+description = "Some helper functions."
+package = Image
+core = 6.x
+; Information added by drupal.org packaging script on 2010-03-19
+version = "6.x-1.3-alpha1"
+core = "6.x"
+project = "exif"
+datestamp = "1269037207"
+
diff --git a/exif_helper/exif_helper.module b/exif_helper/exif_helper.module
new file mode 100644
index 0000000..e19ca5f
--- /dev/null
+++ b/exif_helper/exif_helper.module
@@ -0,0 +1,80 @@
+<?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/exif_location.info b/exif_location/exif_location.info
new file mode 100644
index 0000000..867009e
--- /dev/null
+++ b/exif_location/exif_location.info
@@ -0,0 +1,13 @@
+name = EXIF Location
+description = "Sets a node location based on EXIF info in image."
+core = 6.x
+version = "6.x-0.1"
+dependencies[] = exif
+
+
+; Information added by drupal.org packaging script on 2010-03-19
+version = "6.x-1.3-alpha1"
+core = "6.x"
+project = "exif"
+datestamp = "1269037207"
+
diff --git a/exif_location/exif_location.install b/exif_location/exif_location.install
new file mode 100644
index 0000000..31fc3e8
--- /dev/null
+++ b/exif_location/exif_location.install
@@ -0,0 +1,15 @@
+<?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).
+ */
+function exif_location_install() {
+ $ret = array();
+ $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
new file mode 100644
index 0000000..98b081d
--- /dev/null
+++ b/exif_location/exif_location.module
@@ -0,0 +1,63 @@
+<?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
+ */
+function exif_location_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
+ switch ($op) {
+ case 'presave':
+ $lid = 0;
+ /* Go get the location from EXIF fields */
+ if (is_array($node->field_gps_gpslongitude) &&
+ is_array($node->field_gps_gpslatitude)) {
+ $longitude = $node->field_gps_gpslongitude[0]['value'];
+ $latitude = $node->field_gps_gpslatitude[0]['value'];
+ if (is_array($node->locations) && array_key_exists($lid, $node->locations)) {
+ /*
+ * We cannot just overwrite existing locations or they will
+ * be created and not ammended by the loction module.
+ */
+ $node->locations[$lid]['longitude'] = $longitude;
+ $node->locations[$lid]['latitude'] = $latitude;
+ }
+ else {
+ $node->locations[$lid] =
+ array(
+ 'longitude' => $longitude,
+ 'latitude,' => $latitude,
+ );
+ }
+ $lid++;
+
+ /* Remove any other locations */
+ while (array_key_exists($lid, $node->locations)) {
+ $node->locations[$lid]['longitude'] = '';
+ $node->locations[$lid]['latitude'] = '';
+ $lid++;
+ }
+ }
+ break;
+ }
+}
+
+/**
+ * Implementation of hook_form_alter
+ * @param array $form
+ * @param array $form_state
+ * @param array $form_id
+ */
+function exif_location_form_alter(&$form, $form_state, $form_id) {
+ /* Comment out the return below to enable this */
+ return;
+ /* Remove the location element from the node form */
+ if (isset($form['#node']) &&
+ $form['#node']->type == 'image' &&
+ $form_id == $form['#node']->type .'_node_form') {
+ $form['locations']['#access'] = FALSE;
+ }
+}
diff --git a/sample.jpg b/sample.jpg
new file mode 100644
index 0000000..efa94ad
--- /dev/null
+++ b/sample.jpg
Binary files differ