NextGEN Gallery – WordPress Gallery Plugin - Version 2.2.14

Version Description

  • 09.18.2017 =
  • NEW: EXIF and IPTC metadata are copied to new images when generating thumbnails, watermarks, or new sizes
  • Fixed: Metadata is read and preserved when "Resized images after upload" feature is enabled
Download this release

Release Info

Developer photocrati
Plugin Icon 128x128 NextGEN Gallery – WordPress Gallery Plugin
Version 2.2.14
Comparing to
See all releases

Code changes from version 2.2.12 to 2.2.14

Files changed (54) hide show
  1. changelog.txt +4 -0
  2. nggallery.php +2 -2
  3. products/photocrati_nextgen/modules/nextgen_basic_album/package.module.nextgen_basic_album.php +2 -10
  4. products/photocrati_nextgen/modules/nextgen_basic_gallery/package.module.nextgen_basic_gallery.php +3 -11
  5. products/photocrati_nextgen/modules/nextgen_basic_tagcloud/package.module.nextgen_basic_tagcloud.php +1 -6
  6. products/photocrati_nextgen/modules/nextgen_basic_templates/package.module.nextgen_basic_templates.php +2 -6
  7. products/photocrati_nextgen/modules/nextgen_data/module.nextgen_data.php +1 -0
  8. products/photocrati_nextgen/modules/nextgen_data/package.module.nextgen_data.php +60 -47
  9. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/AUTHORS +53 -0
  10. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/COPYING +340 -0
  11. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/autoload.php +36 -0
  12. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/class.exif_writer.php +106 -0
  13. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/Pel.php +365 -0
  14. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelConvert.php +418 -0
  15. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelDataWindow.php +567 -0
  16. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelDataWindowOffsetException.php +35 -0
  17. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelDataWindowWindowException.php +43 -0
  18. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelEntry.php +253 -0
  19. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelEntryAscii.php +142 -0
  20. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelEntryByte.php +99 -0
  21. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelEntryCopyright.php +191 -0
  22. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelEntryException.php +87 -0
  23. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelEntryLong.php +115 -0
  24. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelEntryNumber.php +285 -0
  25. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelEntryRational.php +175 -0
  26. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelEntrySByte.php +99 -0
  27. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelEntrySLong.php +99 -0
  28. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelEntrySRational.php +153 -0
  29. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelEntrySShort.php +97 -0
  30. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelEntryShort.php +534 -0
  31. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelEntryTime.php +352 -0
  32. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelEntryUndefined.php +173 -0
  33. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelEntryUserComment.php +156 -0
  34. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelEntryVersion.php +182 -0
  35. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelEntryWindowsString.php +161 -0
  36. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelException.php +62 -0
  37. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelExif.php +159 -0
  38. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelFormat.php +227 -0
  39. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelIfd.php +1221 -0
  40. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelIfdException.php +46 -0
  41. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelInvalidArgumentException.php +47 -0
  42. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelInvalidDataException.php +47 -0
  43. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelJpeg.php +663 -0
  44. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelJpegComment.php +118 -0
  45. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelJpegContent.php +78 -0
  46. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelJpegInvalidMarkerException.php +55 -0
  47. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelJpegMarker.php +542 -0
  48. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelOverflowException.php +68 -0
  49. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelTag.php +1723 -0
  50. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelTiff.php +314 -0
  51. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelUnexpectedFormatException.php +80 -0
  52. products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelWrongComponentCountException.php +81 -0
  53. products/photocrati_nextgen/modules/nextgen_gallery_display/package.module.nextgen_gallery_display.php +32 -0
  54. readme.txt +6 -2
changelog.txt CHANGED
@@ -1,6 +1,10 @@
1
  NextGEN Gallery
2
  by Imagely
3
 
 
 
 
 
4
  = V2.2.12 - 08.01.2017 =
5
  * Secured: Disabled Flash backend in plupload
6
  * Changed: Upgraded PHP-Parser version used when building plugin zips
1
  NextGEN Gallery
2
  by Imagely
3
 
4
+ = V2.2.14 - 09.18.2017 =
5
+ * NEW: EXIF and IPTC metadata are copied to new images when generating thumbnails, watermarks, or new sizes
6
+ * Fixed: Metadata is read and preserved when "Resized images after upload" feature is enabled
7
+
8
  = V2.2.12 - 08.01.2017 =
9
  * Secured: Disabled Flash backend in plupload
10
  * Changed: Upgraded PHP-Parser version used when building plugin zips
nggallery.php CHANGED
@@ -4,7 +4,7 @@ if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You
4
  /**
5
  * Plugin Name: NextGEN Gallery
6
  * Description: The most popular gallery plugin for WordPress and one of the most popular plugins of all time with over 18 million downloads.
7
- * Version: 2.2.12
8
  * Author: Imagely
9
  * Plugin URI: https://www.imagely.com/wordpress-gallery-plugin/nextgen-gallery/
10
  * Author URI: https://www.imagely.com
@@ -644,7 +644,7 @@ class C_NextGEN_Bootstrap
644
  define('NGG_PRODUCT_URL', path_join(str_replace("\\", '/', NGG_PLUGIN_URL), 'products'));
645
  define('NGG_MODULE_URL', path_join(str_replace("\\", '/', NGG_PRODUCT_URL), 'photocrati_nextgen/modules'));
646
  define('NGG_PLUGIN_STARTED_AT', microtime());
647
- define('NGG_PLUGIN_VERSION', '2.2.12');
648
 
649
  if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG)
650
  define('NGG_SCRIPT_VERSION', (string)mt_rand(0, mt_getrandmax()));
4
  /**
5
  * Plugin Name: NextGEN Gallery
6
  * Description: The most popular gallery plugin for WordPress and one of the most popular plugins of all time with over 18 million downloads.
7
+ * Version: 2.2.14
8
  * Author: Imagely
9
  * Plugin URI: https://www.imagely.com/wordpress-gallery-plugin/nextgen-gallery/
10
  * Author URI: https://www.imagely.com
644
  define('NGG_PRODUCT_URL', path_join(str_replace("\\", '/', NGG_PLUGIN_URL), 'products'));
645
  define('NGG_MODULE_URL', path_join(str_replace("\\", '/', NGG_PRODUCT_URL), 'photocrati_nextgen/modules'));
646
  define('NGG_PLUGIN_STARTED_AT', microtime());
647
+ define('NGG_PLUGIN_VERSION', '2.2.14');
648
 
649
  if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG)
650
  define('NGG_SCRIPT_VERSION', (string)mt_rand(0, mt_getrandmax()));
products/photocrati_nextgen/modules/nextgen_basic_album/package.module.nextgen_basic_album.php CHANGED
@@ -884,11 +884,7 @@ class A_NextGen_Basic_Extended_Album_Form extends Mixin_NextGen_Basic_Album_Form
884
  */
885
  function enqueue_static_resources()
886
  {
887
- wp_enqueue_script('nextgen_basic_extended_albums_settings_script', $this->object->get_static_url('photocrati-nextgen_basic_album#extended_settings.js'), array('jquery.nextgen_radio_toggle'), NGG_SCRIPT_VERSION);
888
- $atp = C_Attach_Controller::get_instance();
889
- if ($atp != null) {
890
- $atp->mark_script('nextgen_basic_extended_albums_settings_script');
891
- }
892
  }
893
  }
894
  /**
@@ -916,10 +912,6 @@ class A_NextGen_Basic_Compact_Album_Form extends Mixin_NextGen_Basic_Album_Form
916
  */
917
  function enqueue_static_resources()
918
  {
919
- wp_enqueue_script('nextgen_basic_compact_albums_settings_script', $this->object->get_static_url('photocrati-nextgen_basic_album#compact_settings.js'), array('jquery.nextgen_radio_toggle'), NGG_SCRIPT_VERSION);
920
- $atp = C_Attach_Controller::get_instance();
921
- if ($atp != null) {
922
- $atp->mark_script('nextgen_basic_compact_albums_settings_script');
923
- }
924
  }
925
  }
884
  */
885
  function enqueue_static_resources()
886
  {
887
+ $this->object->enqueue_script('nextgen_basic_extended_albums_settings_script', $this->object->get_static_url('photocrati-nextgen_basic_album#extended_settings.js'), array('jquery.nextgen_radio_toggle'));
 
 
 
 
888
  }
889
  }
890
  /**
912
  */
913
  function enqueue_static_resources()
914
  {
915
+ $this->object->enqueue_script('nextgen_basic_compact_albums_settings_script', $this->object->get_static_url('photocrati-nextgen_basic_album#compact_settings.js'), array('jquery.nextgen_radio_toggle'));
 
 
 
 
916
  }
917
  }
products/photocrati_nextgen/modules/nextgen_basic_gallery/package.module.nextgen_basic_gallery.php CHANGED
@@ -295,11 +295,7 @@ class A_NextGen_Basic_Slideshow_Form extends Mixin_Display_Type_Form
295
  }
296
  function enqueue_static_resources()
297
  {
298
- wp_enqueue_script('nextgen_basic_slideshow_settings-js', $this->get_static_url('photocrati-nextgen_basic_gallery#slideshow/nextgen_basic_slideshow_settings.js'), array('jquery.nextgen_radio_toggle'), NGG_SCRIPT_VERSION);
299
- $atp = C_Attach_Controller::get_instance();
300
- if ($atp != null) {
301
- $atp->mark_script('nextgen_basic_slideshow_settings-js');
302
- }
303
  }
304
  /**
305
  * Returns a list of fields to render on the settings page
@@ -357,12 +353,8 @@ class A_NextGen_Basic_Thumbnail_Form extends Mixin_Display_Type_Form
357
  */
358
  function enqueue_static_resources()
359
  {
360
- wp_enqueue_style('nextgen_basic_thumbnails_settings', $this->object->get_static_url('photocrati-nextgen_basic_gallery#thumbnails/nextgen_basic_thumbnails_settings.css'), FALSE, NGG_SCRIPT_VERSION);
361
- wp_enqueue_script('nextgen_basic_thumbnails_settings', $this->object->get_static_url('photocrati-nextgen_basic_gallery#thumbnails/nextgen_basic_thumbnails_settings.js'), array('jquery.nextgen_radio_toggle'), NGG_SCRIPT_VERSION);
362
- $atp = C_Attach_Controller::get_instance();
363
- if ($atp != null) {
364
- $atp->mark_script('nextgen_basic_thumbnails_settings');
365
- }
366
  }
367
  /**
368
  * Returns a list of fields to render on the settings page
295
  }
296
  function enqueue_static_resources()
297
  {
298
+ $this->object->enqueue_script('nextgen_basic_slideshow_settings-js', $this->get_static_url('photocrati-nextgen_basic_gallery#slideshow/nextgen_basic_slideshow_settings.js'), array('jquery.nextgen_radio_toggle'));
 
 
 
 
299
  }
300
  /**
301
  * Returns a list of fields to render on the settings page
353
  */
354
  function enqueue_static_resources()
355
  {
356
+ $this->object->enqueue_style('nextgen_basic_thumbnails_settings', $this->object->get_static_url('photocrati-nextgen_basic_gallery#thumbnails/nextgen_basic_thumbnails_settings.css'));
357
+ $this->object->enqueue_script('nextgen_basic_thumbnails_settings', $this->object->get_static_url('photocrati-nextgen_basic_gallery#thumbnails/nextgen_basic_thumbnails_settings.js'), array('jquery.nextgen_radio_toggle'));
 
 
 
 
358
  }
359
  /**
360
  * Returns a list of fields to render on the settings page
products/photocrati_nextgen/modules/nextgen_basic_tagcloud/package.module.nextgen_basic_tagcloud.php CHANGED
@@ -89,12 +89,7 @@ class A_NextGen_Basic_Tagcloud_Form extends Mixin_Display_Type_Form
89
  }
90
  function enqueue_static_resources()
91
  {
92
- $path = 'photocrati-nextgen_basic_tagcloud#settings.css';
93
- wp_enqueue_style('nextgen_basic_tagcloud_settings-css', $this->get_static_url($path), FALSE, NGG_SCRIPT_VERSION);
94
- $atp = C_Attach_Controller::get_instance();
95
- if (!is_null($atp)) {
96
- $atp->mark_script($path);
97
- }
98
  }
99
  function _render_nextgen_basic_tagcloud_number_field($display_type)
100
  {
89
  }
90
  function enqueue_static_resources()
91
  {
92
+ $this->object->enqueue_style('nextgen_basic_tagcloud_settings-css', $this->get_static_url('photocrati-nextgen_basic_tagcloud#settings.css'));
 
 
 
 
 
93
  }
94
  function _render_nextgen_basic_tagcloud_number_field($display_type)
95
  {
products/photocrati_nextgen/modules/nextgen_basic_templates/package.module.nextgen_basic_templates.php CHANGED
@@ -168,13 +168,9 @@ class A_NextGen_Basic_Template_Form extends Mixin
168
  }
169
  function enqueue_static_resources()
170
  {
171
- wp_enqueue_style('ngg_template_settings', $this->get_static_url('photocrati-nextgen_basic_templates#ngg_template_settings.css'), FALSE, NGG_SCRIPT_VERSION);
172
- wp_enqueue_script('ngg_template_settings', $this->get_static_url('photocrati-nextgen_basic_templates#ngg_template_settings.js'), array('ngg_select2'), NGG_SCRIPT_VERSION, TRUE);
173
  wp_localize_script('ngg_template_settings', 'ngg_template_settings', array('placeholder_text' => __('No template selected')));
174
- $atp = C_Attach_Controller::get_instance();
175
- if ($atp != null) {
176
- $atp->mark_script('ngg_template_settings');
177
- }
178
  }
179
  }
180
  /**
168
  }
169
  function enqueue_static_resources()
170
  {
171
+ wp_enqueue_style('ngg_template_settings', $this->get_static_url('photocrati-nextgen_basic_templates#ngg_template_settings.css'));
172
+ wp_enqueue_script('ngg_template_settings', $this->get_static_url('photocrati-nextgen_basic_templates#ngg_template_settings.js'), array('ngg_select2'), TRUE);
173
  wp_localize_script('ngg_template_settings', 'ngg_template_settings', array('placeholder_text' => __('No template selected')));
 
 
 
 
174
  }
175
  }
176
  /**
products/photocrati_nextgen/modules/nextgen_data/module.nextgen_data.php CHANGED
@@ -50,6 +50,7 @@ class M_NextGen_Data extends C_Base_Module
50
  function get_type_list()
51
  {
52
  return array(
 
53
  'A_Attachment_Datamapper' => 'adapter.attachment_datamapper.php',
54
  'A_Customtable_Sorting_Datamapper' => 'adapter.customtable_sorting_datamapper.php',
55
  'A_Nextgen_Data_Factory' => 'adapter.nextgen_data_factory.php',
50
  function get_type_list()
51
  {
52
  return array(
53
+ 'C_Exif_Writer_Wrapper' => 'class.exif_writer_wrapper.php',
54
  'A_Attachment_Datamapper' => 'adapter.attachment_datamapper.php',
55
  'A_Customtable_Sorting_Datamapper' => 'adapter.customtable_sorting_datamapper.php',
56
  'A_Nextgen_Data_Factory' => 'adapter.nextgen_data_factory.php',
products/photocrati_nextgen/modules/nextgen_data/package.module.nextgen_data.php CHANGED
@@ -235,6 +235,19 @@ class Mixin_Album_Mapper extends Mixin
235
  }
236
  }
237
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
238
  class Mixin_NextGen_Gallery_Validation
239
  {
240
  /**
@@ -1206,46 +1219,51 @@ class Mixin_GalleryStorage_Driver_Base extends Mixin
1206
  if (!is_writable($upload_dir)) {
1207
  throw new E_InsufficientWriteAccessException(FALSE, $upload_dir, FALSE);
1208
  }
1209
- // Save the image
1210
- if ($image_id = $this->object->_image_mapper->save($image)) {
1211
- try {
1212
- // Try writing the image
1213
- $fp = fopen($abs_filename, 'wb');
1214
- fwrite($fp, $this->maybe_base64_decode($data));
1215
- fclose($fp);
1216
- if ($settings->imgBackup) {
1217
- $this->object->backup_image($image);
1218
- }
1219
- if ($settings->imgAutoResize) {
1220
- $this->object->generate_image_clone($abs_filename, $abs_filename, $this->object->get_image_size_params($image_id, 'full'));
1221
- }
1222
- // Ensure that fullsize dimensions are added to metadata array
1223
- $dimensions = getimagesize($abs_filename);
1224
- $full_meta = array('width' => $dimensions[0], 'height' => $dimensions[1], 'md5' => $this->object->get_image_checksum($image, 'full'));
1225
- if (!isset($image->meta_data) or is_string($image->meta_data) && strlen($image->meta_data) == 0) {
1226
- $image->meta_data = array();
1227
- }
1228
- $image->meta_data = array_merge($image->meta_data, $full_meta);
1229
- $image->meta_data['full'] = $full_meta;
1230
- // Generate a thumbnail for the image
1231
- $this->object->generate_thumbnail($image);
1232
- // Set gallery preview image if missing
1233
- C_Gallery_Mapper::get_instance()->set_preview_image($gallery, $image_id, TRUE);
1234
- // Notify other plugins that an image has been added
1235
- do_action('ngg_added_new_image', $image);
1236
- // delete dirsize after adding new images
1237
- delete_transient('dirsize_cache');
1238
- // Seems redundant to above hook. Maintaining for legacy purposes
1239
- do_action('ngg_after_new_images_added', $gallery_id, array($image->{$image_key}));
1240
- } catch (E_No_Image_Library_Exception $ex) {
1241
- throw $ex;
1242
- } catch (E_Clean_Exit $ex) {
1243
- // pass
1244
- } catch (Exception $ex) {
1245
- throw new E_InsufficientWriteAccessException(FALSE, $abs_filename, FALSE, $ex);
1246
  }
1247
- } else {
1248
- throw new E_InvalidEntityException();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1249
  }
1250
  } else {
1251
  throw new E_EntityNotFoundException();
@@ -1643,6 +1661,7 @@ class Mixin_GalleryStorage_Driver_Base extends Mixin
1643
  * @param string $image_path
1644
  * @param string $clone_path
1645
  * @param array $params
 
1646
  * @return object
1647
  */
1648
  function generate_image_clone($image_path, $clone_path, $params)
@@ -1777,13 +1796,7 @@ class Mixin_GalleryStorage_Driver_Base extends Mixin
1777
  }
1778
  $thumbnail = apply_filters('ngg_before_save_thumbnail', $thumbnail);
1779
  $thumbnail->save($destpath, $quality);
1780
- // IF the original contained IPTC metadata we should attempt to copy it
1781
- if (isset($detailed_size['APP13']) && function_exists('iptcembed')) {
1782
- $metadata = @iptcembed($detailed_size['APP13'], $destpath);
1783
- $fp = @fopen($destpath, 'wb');
1784
- @fwrite($fp, $metadata);
1785
- @fclose($fp);
1786
- }
1787
  }
1788
  }
1789
  return $thumbnail;
@@ -1958,7 +1971,7 @@ class Mixin_Gallery_Image_Mapper extends Mixin
1958
  function _save_entity($entity)
1959
  {
1960
  $entity->updated_at = time();
1961
- // If successfully saved, then import metadata and
1962
  $retval = $this->call_parent('_save_entity', $entity);
1963
  if ($retval) {
1964
  include_once NGGALLERY_ABSPATH . '/admin/functions.php';
235
  }
236
  }
237
  }
238
+ class C_Exif_Writer_Wrapper
239
+ {
240
+ // Because our C_Exif_Writer class relies on PEL (a library which uses namespaces) we wrap
241
+ // its use through this method which performs a PHP version check before loading the class file
242
+ public static function copy_metadata($old_file, $new_file)
243
+ {
244
+ if (version_compare(phpversion(), '5.3.0', '<')) {
245
+ return;
246
+ }
247
+ require_once __DIR__ . DIRECTORY_SEPARATOR . 'pel-0.9.6' . DIRECTORY_SEPARATOR . 'class.exif_writer.php';
248
+ C_Exif_Writer::copy_metadata($old_file, $new_file);
249
+ }
250
+ }
251
  class Mixin_NextGen_Gallery_Validation
252
  {
253
  /**
1219
  if (!is_writable($upload_dir)) {
1220
  throw new E_InsufficientWriteAccessException(FALSE, $upload_dir, FALSE);
1221
  }
1222
+ try {
1223
+ // Try writing the image
1224
+ $fp = fopen($abs_filename, 'wb');
1225
+ fwrite($fp, $this->maybe_base64_decode($data));
1226
+ fclose($fp);
1227
+ // Save the image
1228
+ $image_id = $this->object->_image_mapper->save($image);
1229
+ if (!$image_id) {
1230
+ throw new E_InvalidEntityException();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1231
  }
1232
+ if ($settings->imgBackup) {
1233
+ $this->object->backup_image($image);
1234
+ }
1235
+ if ($settings->imgAutoResize) {
1236
+ $this->object->generate_image_clone($abs_filename, $abs_filename, $this->object->get_image_size_params($image_id, 'full'));
1237
+ }
1238
+ $this->object->_image_mapper->_use_cache = FALSE;
1239
+ $image = $this->object->_image_mapper->find($image_id);
1240
+ $this->object->_image_mapper->_use_cache = TRUE;
1241
+ // Ensure that fullsize dimensions are added to metadata array
1242
+ $dimensions = getimagesize($abs_filename);
1243
+ $full_meta = array('width' => $dimensions[0], 'height' => $dimensions[1], 'md5' => $this->object->get_image_checksum($image, 'full'));
1244
+ if (!isset($image->meta_data) or is_string($image->meta_data) && strlen($image->meta_data) == 0) {
1245
+ $image->meta_data = array();
1246
+ }
1247
+ $image->meta_data = array_merge($image->meta_data, $full_meta);
1248
+ $image->meta_data['full'] = $full_meta;
1249
+ // Don't forget to append the 'full' entry in meta_data in the db
1250
+ $this->object->_image_mapper->save($image);
1251
+ // Generate a thumbnail for the image
1252
+ $this->object->generate_thumbnail($image);
1253
+ // Set gallery preview image if missing
1254
+ C_Gallery_Mapper::get_instance()->set_preview_image($gallery, $image_id, TRUE);
1255
+ // Notify other plugins that an image has been added
1256
+ do_action('ngg_added_new_image', $image);
1257
+ // delete dirsize after adding new images
1258
+ delete_transient('dirsize_cache');
1259
+ // Seems redundant to above hook. Maintaining for legacy purposes
1260
+ do_action('ngg_after_new_images_added', $gallery_id, array($image->{$image_key}));
1261
+ } catch (E_No_Image_Library_Exception $ex) {
1262
+ throw $ex;
1263
+ } catch (E_Clean_Exit $ex) {
1264
+ // pass
1265
+ } catch (Exception $ex) {
1266
+ throw new E_InsufficientWriteAccessException(FALSE, $abs_filename, FALSE, $ex);
1267
  }
1268
  } else {
1269
  throw new E_EntityNotFoundException();
1661
  * @param string $image_path
1662
  * @param string $clone_path
1663
  * @param array $params
1664
+ * @param bool $save Whether to call the image save() method
1665
  * @return object
1666
  */
1667
  function generate_image_clone($image_path, $clone_path, $params)
1796
  }
1797
  $thumbnail = apply_filters('ngg_before_save_thumbnail', $thumbnail);
1798
  $thumbnail->save($destpath, $quality);
1799
+ C_Exif_Writer_Wrapper::copy_metadata($image_path, $destpath);
 
 
 
 
 
 
1800
  }
1801
  }
1802
  return $thumbnail;
1971
  function _save_entity($entity)
1972
  {
1973
  $entity->updated_at = time();
1974
+ // If successfully saved then import metadata
1975
  $retval = $this->call_parent('_save_entity', $entity);
1976
  if ($retval) {
1977
  include_once NGGALLERY_ABSPATH . '/admin/functions.php';
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/AUTHORS ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ AUTHORS file for PEL: PHP Exif Library. A library with support for
2
+ reading and writing Exif headers in JPEG and TIFF images using PHP.
3
+
4
+ Copyright (C) 2004, 2005, 2006, 2007 Martin Geisler.
5
+ Copyright (c) 2008, 2009 Lars Olesen
6
+ Copyright (c) 2015 Johannes Weberhofer
7
+ Licensed under the GNU GPL, see COPYING for details.
8
+
9
+
10
+ Credits
11
+ *******
12
+
13
+ PEL is written by Martin Geisler <mgeisler@users.sourceforge.net> and
14
+ is now maintained by Lars Olesen <lars@intraface.dk>
15
+ and <jweberhofer@weberhofer.at>
16
+
17
+ The source started out as a port of the nice, clean C code found in
18
+ libexif. Most of the translations included with PEL also originates
19
+ from the libexif project, see below for details.
20
+
21
+
22
+ Test Image Contributors
23
+ ***********************
24
+
25
+ Bernhard Bittel: Nikon E950 and E5000 test images.
26
+
27
+ Stéphanie Bittel: Canon IXUS II test image.
28
+
29
+ Lars Geisler: Nikon Coolscan IV ED test image.
30
+
31
+ Mikkel Krøigård: Canon PowerShot S60 test image.
32
+
33
+ Paul Mitchum: Pentax *ist DS and Olympus C-5050z test images.
34
+
35
+ Lisbeth Nygaard Pedersen: Leica D-LUX test image.
36
+
37
+ Thomas B. Pedersen: Olympus C-50z and C-765z test images.
38
+
39
+
40
+ Translators
41
+ ***********
42
+
43
+ Danish: Martin Geisler.
44
+
45
+ French: Arnaud Launay (for libexif) and David Lesieur.
46
+
47
+ German: Hans Ulrich Niedermann, Lutz Möller (for libexif).
48
+
49
+ Japanese: Tadashi Jokagi.
50
+
51
+ Polish: Jakub Bogusz (for libexif).
52
+
53
+ Spanish: Fabian Mandelbaum (for libexif).
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/COPYING ADDED
@@ -0,0 +1,340 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
5
+ 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+ Preamble
10
+
11
+ The licenses for most software are designed to take away your
12
+ freedom to share and change it. By contrast, the GNU General Public
13
+ License is intended to guarantee your freedom to share and change free
14
+ software--to make sure the software is free for all its users. This
15
+ General Public License applies to most of the Free Software
16
+ Foundation's software and to any other program whose authors commit to
17
+ using it. (Some other Free Software Foundation software is covered by
18
+ the GNU Library General Public License instead.) You can apply it to
19
+ your programs, too.
20
+
21
+ When we speak of free software, we are referring to freedom, not
22
+ price. Our General Public Licenses are designed to make sure that you
23
+ have the freedom to distribute copies of free software (and charge for
24
+ this service if you wish), that you receive source code or can get it
25
+ if you want it, that you can change the software or use pieces of it
26
+ in new free programs; and that you know you can do these things.
27
+
28
+ To protect your rights, we need to make restrictions that forbid
29
+ anyone to deny you these rights or to ask you to surrender the rights.
30
+ These restrictions translate to certain responsibilities for you if you
31
+ distribute copies of the software, or if you modify it.
32
+
33
+ For example, if you distribute copies of such a program, whether
34
+ gratis or for a fee, you must give the recipients all the rights that
35
+ you have. You must make sure that they, too, receive or can get the
36
+ source code. And you must show them these terms so they know their
37
+ rights.
38
+
39
+ We protect your rights with two steps: (1) copyright the software, and
40
+ (2) offer you this license which gives you legal permission to copy,
41
+ distribute and/or modify the software.
42
+
43
+ Also, for each author's protection and ours, we want to make certain
44
+ that everyone understands that there is no warranty for this free
45
+ software. If the software is modified by someone else and passed on, we
46
+ want its recipients to know that what they have is not the original, so
47
+ that any problems introduced by others will not reflect on the original
48
+ authors' reputations.
49
+
50
+ Finally, any free program is threatened constantly by software
51
+ patents. We wish to avoid the danger that redistributors of a free
52
+ program will individually obtain patent licenses, in effect making the
53
+ program proprietary. To prevent this, we have made it clear that any
54
+ patent must be licensed for everyone's free use or not licensed at all.
55
+
56
+ The precise terms and conditions for copying, distribution and
57
+ modification follow.
58
+
59
+ GNU GENERAL PUBLIC LICENSE
60
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
+
62
+ 0. This License applies to any program or other work which contains
63
+ a notice placed by the copyright holder saying it may be distributed
64
+ under the terms of this General Public License. The "Program", below,
65
+ refers to any such program or work, and a "work based on the Program"
66
+ means either the Program or any derivative work under copyright law:
67
+ that is to say, a work containing the Program or a portion of it,
68
+ either verbatim or with modifications and/or translated into another
69
+ language. (Hereinafter, translation is included without limitation in
70
+ the term "modification".) Each licensee is addressed as "you".
71
+
72
+ Activities other than copying, distribution and modification are not
73
+ covered by this License; they are outside its scope. The act of
74
+ running the Program is not restricted, and the output from the Program
75
+ is covered only if its contents constitute a work based on the
76
+ Program (independent of having been made by running the Program).
77
+ Whether that is true depends on what the Program does.
78
+
79
+ 1. You may copy and distribute verbatim copies of the Program's
80
+ source code as you receive it, in any medium, provided that you
81
+ conspicuously and appropriately publish on each copy an appropriate
82
+ copyright notice and disclaimer of warranty; keep intact all the
83
+ notices that refer to this License and to the absence of any warranty;
84
+ and give any other recipients of the Program a copy of this License
85
+ along with the Program.
86
+
87
+ You may charge a fee for the physical act of transferring a copy, and
88
+ you may at your option offer warranty protection in exchange for a fee.
89
+
90
+ 2. You may modify your copy or copies of the Program or any portion
91
+ of it, thus forming a work based on the Program, and copy and
92
+ distribute such modifications or work under the terms of Section 1
93
+ above, provided that you also meet all of these conditions:
94
+
95
+ a) You must cause the modified files to carry prominent notices
96
+ stating that you changed the files and the date of any change.
97
+
98
+ b) You must cause any work that you distribute or publish, that in
99
+ whole or in part contains or is derived from the Program or any
100
+ part thereof, to be licensed as a whole at no charge to all third
101
+ parties under the terms of this License.
102
+
103
+ c) If the modified program normally reads commands interactively
104
+ when run, you must cause it, when started running for such
105
+ interactive use in the most ordinary way, to print or display an
106
+ announcement including an appropriate copyright notice and a
107
+ notice that there is no warranty (or else, saying that you provide
108
+ a warranty) and that users may redistribute the program under
109
+ these conditions, and telling the user how to view a copy of this
110
+ License. (Exception: if the Program itself is interactive but
111
+ does not normally print such an announcement, your work based on
112
+ the Program is not required to print an announcement.)
113
+
114
+ These requirements apply to the modified work as a whole. If
115
+ identifiable sections of that work are not derived from the Program,
116
+ and can be reasonably considered independent and separate works in
117
+ themselves, then this License, and its terms, do not apply to those
118
+ sections when you distribute them as separate works. But when you
119
+ distribute the same sections as part of a whole which is a work based
120
+ on the Program, the distribution of the whole must be on the terms of
121
+ this License, whose permissions for other licensees extend to the
122
+ entire whole, and thus to each and every part regardless of who wrote it.
123
+
124
+ Thus, it is not the intent of this section to claim rights or contest
125
+ your rights to work written entirely by you; rather, the intent is to
126
+ exercise the right to control the distribution of derivative or
127
+ collective works based on the Program.
128
+
129
+ In addition, mere aggregation of another work not based on the Program
130
+ with the Program (or with a work based on the Program) on a volume of
131
+ a storage or distribution medium does not bring the other work under
132
+ the scope of this License.
133
+
134
+ 3. You may copy and distribute the Program (or a work based on it,
135
+ under Section 2) in object code or executable form under the terms of
136
+ Sections 1 and 2 above provided that you also do one of the following:
137
+
138
+ a) Accompany it with the complete corresponding machine-readable
139
+ source code, which must be distributed under the terms of Sections
140
+ 1 and 2 above on a medium customarily used for software interchange; or,
141
+
142
+ b) Accompany it with a written offer, valid for at least three
143
+ years, to give any third party, for a charge no more than your
144
+ cost of physically performing source distribution, a complete
145
+ machine-readable copy of the corresponding source code, to be
146
+ distributed under the terms of Sections 1 and 2 above on a medium
147
+ customarily used for software interchange; or,
148
+
149
+ c) Accompany it with the information you received as to the offer
150
+ to distribute corresponding source code. (This alternative is
151
+ allowed only for noncommercial distribution and only if you
152
+ received the program in object code or executable form with such
153
+ an offer, in accord with Subsection b above.)
154
+
155
+ The source code for a work means the preferred form of the work for
156
+ making modifications to it. For an executable work, complete source
157
+ code means all the source code for all modules it contains, plus any
158
+ associated interface definition files, plus the scripts used to
159
+ control compilation and installation of the executable. However, as a
160
+ special exception, the source code distributed need not include
161
+ anything that is normally distributed (in either source or binary
162
+ form) with the major components (compiler, kernel, and so on) of the
163
+ operating system on which the executable runs, unless that component
164
+ itself accompanies the executable.
165
+
166
+ If distribution of executable or object code is made by offering
167
+ access to copy from a designated place, then offering equivalent
168
+ access to copy the source code from the same place counts as
169
+ distribution of the source code, even though third parties are not
170
+ compelled to copy the source along with the object code.
171
+
172
+ 4. You may not copy, modify, sublicense, or distribute the Program
173
+ except as expressly provided under this License. Any attempt
174
+ otherwise to copy, modify, sublicense or distribute the Program is
175
+ void, and will automatically terminate your rights under this License.
176
+ However, parties who have received copies, or rights, from you under
177
+ this License will not have their licenses terminated so long as such
178
+ parties remain in full compliance.
179
+
180
+ 5. You are not required to accept this License, since you have not
181
+ signed it. However, nothing else grants you permission to modify or
182
+ distribute the Program or its derivative works. These actions are
183
+ prohibited by law if you do not accept this License. Therefore, by
184
+ modifying or distributing the Program (or any work based on the
185
+ Program), you indicate your acceptance of this License to do so, and
186
+ all its terms and conditions for copying, distributing or modifying
187
+ the Program or works based on it.
188
+
189
+ 6. Each time you redistribute the Program (or any work based on the
190
+ Program), the recipient automatically receives a license from the
191
+ original licensor to copy, distribute or modify the Program subject to
192
+ these terms and conditions. You may not impose any further
193
+ restrictions on the recipients' exercise of the rights granted herein.
194
+ You are not responsible for enforcing compliance by third parties to
195
+ this License.
196
+
197
+ 7. If, as a consequence of a court judgment or allegation of patent
198
+ infringement or for any other reason (not limited to patent issues),
199
+ conditions are imposed on you (whether by court order, agreement or
200
+ otherwise) that contradict the conditions of this License, they do not
201
+ excuse you from the conditions of this License. If you cannot
202
+ distribute so as to satisfy simultaneously your obligations under this
203
+ License and any other pertinent obligations, then as a consequence you
204
+ may not distribute the Program at all. For example, if a patent
205
+ license would not permit royalty-free redistribution of the Program by
206
+ all those who receive copies directly or indirectly through you, then
207
+ the only way you could satisfy both it and this License would be to
208
+ refrain entirely from distribution of the Program.
209
+
210
+ If any portion of this section is held invalid or unenforceable under
211
+ any particular circumstance, the balance of the section is intended to
212
+ apply and the section as a whole is intended to apply in other
213
+ circumstances.
214
+
215
+ It is not the purpose of this section to induce you to infringe any
216
+ patents or other property right claims or to contest validity of any
217
+ such claims; this section has the sole purpose of protecting the
218
+ integrity of the free software distribution system, which is
219
+ implemented by public license practices. Many people have made
220
+ generous contributions to the wide range of software distributed
221
+ through that system in reliance on consistent application of that
222
+ system; it is up to the author/donor to decide if he or she is willing
223
+ to distribute software through any other system and a licensee cannot
224
+ impose that choice.
225
+
226
+ This section is intended to make thoroughly clear what is believed to
227
+ be a consequence of the rest of this License.
228
+
229
+ 8. If the distribution and/or use of the Program is restricted in
230
+ certain countries either by patents or by copyrighted interfaces, the
231
+ original copyright holder who places the Program under this License
232
+ may add an explicit geographical distribution limitation excluding
233
+ those countries, so that distribution is permitted only in or among
234
+ countries not thus excluded. In such case, this License incorporates
235
+ the limitation as if written in the body of this License.
236
+
237
+ 9. The Free Software Foundation may publish revised and/or new versions
238
+ of the General Public License from time to time. Such new versions will
239
+ be similar in spirit to the present version, but may differ in detail to
240
+ address new problems or concerns.
241
+
242
+ Each version is given a distinguishing version number. If the Program
243
+ specifies a version number of this License which applies to it and "any
244
+ later version", you have the option of following the terms and conditions
245
+ either of that version or of any later version published by the Free
246
+ Software Foundation. If the Program does not specify a version number of
247
+ this License, you may choose any version ever published by the Free Software
248
+ Foundation.
249
+
250
+ 10. If you wish to incorporate parts of the Program into other free
251
+ programs whose distribution conditions are different, write to the author
252
+ to ask for permission. For software which is copyrighted by the Free
253
+ Software Foundation, write to the Free Software Foundation; we sometimes
254
+ make exceptions for this. Our decision will be guided by the two goals
255
+ of preserving the free status of all derivatives of our free software and
256
+ of promoting the sharing and reuse of software generally.
257
+
258
+ NO WARRANTY
259
+
260
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266
+ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267
+ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
+ REPAIR OR CORRECTION.
269
+
270
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
+ OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
+ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
+ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
+ POSSIBILITY OF SUCH DAMAGES.
279
+
280
+ END OF TERMS AND CONDITIONS
281
+
282
+ How to Apply These Terms to Your New Programs
283
+
284
+ If you develop a new program, and you want it to be of the greatest
285
+ possible use to the public, the best way to achieve this is to make it
286
+ free software which everyone can redistribute and change under these terms.
287
+
288
+ To do so, attach the following notices to the program. It is safest
289
+ to attach them to the start of each source file to most effectively
290
+ convey the exclusion of warranty; and each file should have at least
291
+ the "copyright" line and a pointer to where the full notice is found.
292
+
293
+ <one line to give the program's name and a brief idea of what it does.>
294
+ Copyright (C) <year> <name of author>
295
+
296
+ This program is free software; you can redistribute it and/or modify
297
+ it under the terms of the GNU General Public License as published by
298
+ the Free Software Foundation; either version 2 of the License, or
299
+ (at your option) any later version.
300
+
301
+ This program is distributed in the hope that it will be useful,
302
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
303
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304
+ GNU General Public License for more details.
305
+
306
+ You should have received a copy of the GNU General Public License
307
+ along with this program; if not, write to the Free Software
308
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
309
+
310
+
311
+ Also add information on how to contact you by electronic and paper mail.
312
+
313
+ If the program is interactive, make it output a short notice like this
314
+ when it starts in an interactive mode:
315
+
316
+ Gnomovision version 69, Copyright (C) year name of author
317
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
318
+ This is free software, and you are welcome to redistribute it
319
+ under certain conditions; type `show c' for details.
320
+
321
+ The hypothetical commands `show w' and `show c' should show the appropriate
322
+ parts of the General Public License. Of course, the commands you use may
323
+ be called something other than `show w' and `show c'; they could even be
324
+ mouse-clicks or menu items--whatever suits your program.
325
+
326
+ You should also get your employer (if you work as a programmer) or your
327
+ school, if any, to sign a "copyright disclaimer" for the program, if
328
+ necessary. Here is a sample; alter the names:
329
+
330
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
331
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
332
+
333
+ <signature of Ty Coon>, 1 April 1989
334
+ Ty Coon, President of Vice
335
+
336
+ This General Public License does not permit incorporating your program into
337
+ proprietary programs. If your program is a subroutine library, you may
338
+ consider it more useful to permit linking proprietary applications with the
339
+ library. If this is what you want to do, use the GNU Library General
340
+ Public License instead of this License.
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/autoload.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PEL: PHP Exif Library.
4
+ * A library with support for reading and
5
+ * writing all Exif headers in JPEG and TIFF images using PHP.
6
+ *
7
+ * Copyright (C) 2015, Johannes Weberhofer.
8
+ *
9
+ * This program is free software; you can redistribute it and/or modify
10
+ * it under the terms of the GNU General Public License as published by
11
+ * the Free Software Foundation; either version 2 of the License, or
12
+ * (at your option) any later version.
13
+ *
14
+ * This program is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ * GNU General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU General Public License
20
+ * along with this program in the file COPYING; if not, write to the
21
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
22
+ * Boston, MA 02110-1301 USA
23
+ */
24
+
25
+ /**
26
+ * Register autoloader for pel
27
+ */
28
+ spl_autoload_register(function ($class) {
29
+ if (substr_compare($class, 'lsolesen\\pel\\', 0, 13) === 0) {
30
+ $classname = str_replace('lsolesen\\pel\\', '', $class);
31
+ $load = realpath(__DIR__ . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . $classname . '.php');
32
+ if ($load !== false) {
33
+ include_once realpath($load);
34
+ }
35
+ }
36
+ });
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/class.exif_writer.php ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // This file resides in the PEL directory so that it is not processed during the NextGen
4
+ // build process as the NGG package files cannot contain PHP 5.3+ code yet. See the
5
+ // C_Exif_Writer_Wrapper class which loads this file outside of the POPE module system.
6
+
7
+ require_once('autoload.php');
8
+
9
+ use lsolesen\pel\PelDataWindow;
10
+ use lsolesen\pel\PelJpeg;
11
+ use lsolesen\pel\PelTiff;
12
+ use lsolesen\pel\PelExif;
13
+ use lsolesen\pel\PelIfd;
14
+
15
+ class C_Exif_Writer
16
+ {
17
+ static public function copy_metadata($old_file, $new_file)
18
+ {
19
+ $data = new PelDataWindow(@file_get_contents($old_file));
20
+ $exif = new PelExif();
21
+
22
+ if (PelJpeg::isValid($data))
23
+ {
24
+ $jpeg = $file = new PelJpeg();
25
+ $jpeg->load($data);
26
+ $exif = $jpeg->getExif();
27
+
28
+ if ($exif === NULL)
29
+ {
30
+ $exif = new PelExif();
31
+ $jpeg->setExif($exif);
32
+
33
+ $tiff = new PelTiff();
34
+ $exif->setTiff($tiff);
35
+ }
36
+ else {
37
+ $tiff = $exif->getTiff();
38
+ }
39
+
40
+ }
41
+ elseif (PelTiff::isValid($data)) {
42
+ $tiff = $file = new PellTiff();
43
+ $tiff->load($data);
44
+ }
45
+ else {
46
+ return;
47
+ }
48
+
49
+ $ifd0 = $tiff->getIfd();
50
+ if ($ifd0 === NULL)
51
+ {
52
+ $ifd0 = new PelIfd(PelIfd::IFD0);
53
+ $tiff->setIfd($ifd0);
54
+ }
55
+
56
+ // Copy EXIF data to the new image and write it
57
+ $new_image = new PelJpeg($new_file);
58
+ $tiff->setIfd($ifd0);
59
+ $exif->setTiff($tiff);
60
+ $new_image->setExif($exif);
61
+ $new_image->saveFile($new_file);
62
+
63
+ // IF the original contained IPTC metadata we should copy it
64
+ getimagesize($old_file, $iptc);
65
+ if (isset($iptc['APP13']) && function_exists('iptcembed'))
66
+ {
67
+ $parsed = iptcparse($iptc['APP13']);
68
+ $newiptc = '';
69
+ foreach ($parsed as $key => $value) {
70
+ $tag = str_replace("2#", '', $key);
71
+ $newiptc .= self::build_iptc_tag($tag, $value[0]);
72
+ }
73
+
74
+ $metadata = iptcembed($newiptc, $new_file);
75
+ $fp = fopen($new_file, 'wb');
76
+ fwrite($fp, $metadata);
77
+ fclose($fp);
78
+ }
79
+ }
80
+
81
+ public static function build_iptc_tag($tag, $value)
82
+ {
83
+ $length = strlen($value);
84
+ if ($length >= 0x8000)
85
+ {
86
+ return chr(0x1c)
87
+ . chr(2)
88
+ . chr($tag)
89
+ . chr(0x80)
90
+ . chr(0x04)
91
+ . chr(($length >> 24) & 0xff)
92
+ . chr(($length >> 16) & 0xff)
93
+ . chr(($length >> 8 ) & 0xff)
94
+ . chr(($length ) & 0xff)
95
+ . $value;
96
+ }
97
+ else {
98
+ return chr(0x1c)
99
+ . chr(2)
100
+ . chr($tag)
101
+ . chr($length >> 8)
102
+ . chr($length & 0xff)
103
+ . $value;
104
+ }
105
+ }
106
+ }
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/Pel.php ADDED
@@ -0,0 +1,365 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * PEL: PHP Exif Library.
5
+ * A library with support for reading and
6
+ * writing all Exif headers in JPEG and TIFF images using PHP.
7
+ *
8
+ * Copyright (C) 2004, 2005, 2006, 2007 Martin Geisler.
9
+ *
10
+ * This program is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program in the file COPYING; if not, write to the
22
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23
+ * Boston, MA 02110-1301 USA
24
+ */
25
+ namespace lsolesen\pel;
26
+
27
+ /**
28
+ * Class with miscellaneous static methods.
29
+ *
30
+ * This class will contain various methods that govern the overall
31
+ * behavior of PEL.
32
+ *
33
+ * Debugging output from PEL can be turned on and off by assigning
34
+ * true or false to {@link Pel::$debug}.
35
+ *
36
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
37
+ * @package PEL
38
+ */
39
+ class Pel
40
+ {
41
+
42
+ /**
43
+ * Flag that controls if dgettext can be used.
44
+ * Is set to true or fals at the first access
45
+ *
46
+ * @var boolean|NULL
47
+ */
48
+ private static $hasdgetext = null;
49
+
50
+ /**
51
+ * Flag for controlling debug information.
52
+ *
53
+ * The methods producing debug information ({@link debug()} and
54
+ * {@link warning()}) will only output something if this variable is
55
+ * set to true.
56
+ *
57
+ * @var boolean
58
+ */
59
+ private static $debug = false;
60
+
61
+ /**
62
+ * Flag for strictness of parsing.
63
+ *
64
+ * If this variable is set to true, then most errors while loading
65
+ * images will result in exceptions being thrown. Otherwise a
66
+ * warning will be emitted (using {@link Pel::warning}) and the
67
+ * exceptions will be appended to {@link Pel::$exceptions}.
68
+ *
69
+ * Some errors will still be fatal and result in thrown exceptions,
70
+ * but an effort will be made to skip over as much garbage as
71
+ * possible.
72
+ *
73
+ * @var boolean
74
+ */
75
+ private static $strict = false;
76
+
77
+ /**
78
+ * Stored exceptions.
79
+ *
80
+ * When {@link Pel::$strict} is set to false exceptions will be
81
+ * accumulated here instead of being thrown.
82
+ */
83
+ private static $exceptions = array();
84
+
85
+ /**
86
+ * Quality setting for encoding JPEG images.
87
+ *
88
+ * This controls the quality used then PHP image resources are
89
+ * encoded into JPEG images. This happens when you create a
90
+ * {@link PelJpeg} object based on an image resource.
91
+ *
92
+ * The default is 75 for average quality images, but you can change
93
+ * this to an integer between 0 and 100.
94
+ *
95
+ * @var int
96
+ */
97
+ private static $quality = 75;
98
+
99
+ /**
100
+ * Set the JPEG encoding quality.
101
+ *
102
+ * @param int $quality
103
+ * an integer between 0 and 100 with 75 being
104
+ * average quality and 95 very good quality.
105
+ */
106
+ public static function setJPEGQuality($quality)
107
+ {
108
+ self::$quality = $quality;
109
+ }
110
+
111
+ /**
112
+ * Get current setting for JPEG encoding quality.
113
+ *
114
+ * @return int the quality.
115
+ */
116
+ public static function getJPEGQuality()
117
+ {
118
+ return self::$quality;
119
+ }
120
+
121
+ /**
122
+ * Return list of stored exceptions.
123
+ *
124
+ * When PEL is parsing in non-strict mode, it will store most
125
+ * exceptions instead of throwing them. Use this method to get hold
126
+ * of them when a call returns.
127
+ *
128
+ * Code for using this could look like this:
129
+ *
130
+ * <code>
131
+ * Pel::setStrictParsing(true);
132
+ * Pel::clearExceptions();
133
+ *
134
+ * $jpeg = new PelJpeg($file);
135
+ *
136
+ * // Check for exceptions.
137
+ * foreach (Pel::getExceptions() as $e) {
138
+ * printf("Exception: %s\n", $e->getMessage());
139
+ * if ($e instanceof PelEntryException) {
140
+ * // Warn about entries that couldn't be loaded.
141
+ * printf("Warning: Problem with %s.\n",
142
+ * PelTag::getName($e->getType(), $e->getTag()));
143
+ * }
144
+ * }
145
+ * </code>
146
+ *
147
+ * This gives applications total control over the amount of error
148
+ * messages shown and (hopefully) provides the necessary information
149
+ * for proper error recovery.
150
+ *
151
+ * @return array the exceptions.
152
+ */
153
+ public static function getExceptions()
154
+ {
155
+ return self::$exceptions;
156
+ }
157
+
158
+ /**
159
+ * Clear list of stored exceptions.
160
+ *
161
+ * Use this function before a call to some method if you intend to
162
+ * check for exceptions afterwards.
163
+ */
164
+ public static function clearExceptions()
165
+ {
166
+ self::$exceptions = array();
167
+ }
168
+
169
+ /**
170
+ * Conditionally throw an exception.
171
+ *
172
+ * This method will throw the passed exception when strict parsing
173
+ * in effect (see {@link setStrictParsing()}). Otherwise the
174
+ * exception is stored (it can be accessed with {@link
175
+ * getExceptions()}) and a warning is issued (with {@link
176
+ * Pel::warning}).
177
+ *
178
+ * @param PelException $e
179
+ * the exceptions.
180
+ */
181
+ public static function maybeThrow(PelException $e)
182
+ {
183
+ if (self::$strict) {
184
+ throw $e;
185
+ } else {
186
+ self::$exceptions[] = $e;
187
+ self::warning('%s (%s:%s)', $e->getMessage(), basename($e->getFile()), $e->getLine());
188
+ }
189
+ }
190
+
191
+ /**
192
+ * Enable/disable strict parsing.
193
+ *
194
+ * If strict parsing is enabled, then most errors while loading
195
+ * images will result in exceptions being thrown. Otherwise a
196
+ * warning will be emitted (using {@link Pel::warning}) and the
197
+ * exceptions will be stored for later use via {@link
198
+ * getExceptions()}.
199
+ *
200
+ * Some errors will still be fatal and result in thrown exceptions,
201
+ * but an effort will be made to skip over as much garbage as
202
+ * possible.
203
+ *
204
+ * @param boolean $flag
205
+ * use true to enable strict parsing, false to
206
+ * diable.
207
+ */
208
+ public static function setStrictParsing($flag)
209
+ {
210
+ self::$strict = $flag;
211
+ }
212
+
213
+ /**
214
+ * Get current setting for strict parsing.
215
+ *
216
+ * @return boolean true if strict parsing is in effect, false
217
+ * otherwise.
218
+ */
219
+ public static function getStrictParsing()
220
+ {
221
+ return self::$strict;
222
+ }
223
+
224
+ /**
225
+ * Enable/disable debugging output.
226
+ *
227
+ * @param boolean $flag
228
+ * use true to enable debug output, false to
229
+ * diable.
230
+ */
231
+ public static function setDebug($flag)
232
+ {
233
+ self::$debug = $flag;
234
+ }
235
+
236
+ /**
237
+ * Get current setting for debug output.
238
+ *
239
+ * @return boolean true if debug is enabled, false otherwise.
240
+ */
241
+ public static function getDebug()
242
+ {
243
+ return self::$debug;
244
+ }
245
+
246
+ /**
247
+ * Conditionally output debug information.
248
+ *
249
+ * This method works just like printf() except that it always
250
+ * terminates the output with a newline, and that it only outputs
251
+ * something if the {@link Pel::$debug} is true.
252
+ *
253
+ * @param string $format
254
+ * the format string.
255
+ *
256
+ * @param mixed ...$args
257
+ * any number of arguments can be given. The
258
+ * arguments will be available for the format string as usual with
259
+ * sprintf().
260
+ */
261
+ public static function debug($format)
262
+ {
263
+ if (self::$debug) {
264
+ $args = func_get_args();
265
+ $str = array_shift($args);
266
+ vprintf($str . "\n", $args);
267
+ }
268
+ }
269
+
270
+ /**
271
+ * Conditionally output a warning.
272
+ *
273
+ * This method works just like printf() except that it prepends the
274
+ * output with the string 'Warning: ', terminates the output with a
275
+ * newline, and that it only outputs something if the PEL_DEBUG
276
+ * defined to some true value.
277
+ *
278
+ * @param string $format
279
+ * the format string.
280
+ *
281
+ * @param mixed ...$args
282
+ * any number of arguments can be given. The
283
+ * arguments will be available for the format string as usual with
284
+ * sprintf().
285
+ */
286
+ public static function warning($format)
287
+ {
288
+ if (self::$debug) {
289
+ $args = func_get_args();
290
+ $str = array_shift($args);
291
+ vprintf('Warning: ' . $str . "\n", $args);
292
+ }
293
+ }
294
+
295
+ /**
296
+ * Translate a string.
297
+ *
298
+ * This static function will use Gettext to translate a string. By
299
+ * always using this function for static string one is assured that
300
+ * the translation will be taken from the correct text domain.
301
+ * Dynamic strings should be passed to {@link fmt} instead.
302
+ *
303
+ * @param string $str
304
+ * the string that should be translated.
305
+ *
306
+ * @return string the translated string, or the original string if
307
+ * no translation could be found.
308
+ */
309
+ public static function tra($str)
310
+ {
311
+ return self::dgettextWrapper('pel', $str);
312
+ }
313
+
314
+ /**
315
+ * Translate and format a string.
316
+ *
317
+ * This static function will first use Gettext to translate a format
318
+ * string, which will then have access to any extra arguments. By
319
+ * always using this function for dynamic string one is assured that
320
+ * the translation will be taken from the correct text domain. If
321
+ * the string is static, use {@link tra} instead as it will be
322
+ * faster.
323
+ *
324
+ * @param string $format
325
+ * the format string. This will be translated
326
+ * before being used as a format string.
327
+ *
328
+ * @param mixed ...$args
329
+ * any number of arguments can be given. The
330
+ * arguments will be available for the format string as usual with
331
+ * sprintf().
332
+ *
333
+ * @return string the translated string, or the original string if
334
+ * no translation could be found.
335
+ */
336
+ public static function fmt($format)
337
+ {
338
+ $args = func_get_args();
339
+ $str = array_shift($args);
340
+ return vsprintf(self::dgettextWrapper('pel', $str), $args);
341
+ }
342
+
343
+ /**
344
+ * Warapper for dgettext.
345
+ * The untranslated stub will be return in the case that dgettext is not available.
346
+ *
347
+ * @param string $domain
348
+ * @param string $str
349
+ * @return string
350
+ */
351
+ private static function dgettextWrapper($domain, $str)
352
+ {
353
+ if (self::$hasdgetext === null) {
354
+ self::$hasdgetext = function_exists('dgettext');
355
+ if (self::$hasdgetext === true) {
356
+ bindtextdomain('pel', __DIR__ . '/locale');
357
+ }
358
+ }
359
+ if (self::$hasdgetext) {
360
+ return dgettext($domain, $str);
361
+ } else {
362
+ return $str;
363
+ }
364
+ }
365
+ }
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelConvert.php ADDED
@@ -0,0 +1,418 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * PEL: PHP Exif Library.
5
+ * A library with support for reading and
6
+ * writing all Exif headers in JPEG and TIFF images using PHP.
7
+ *
8
+ * Copyright (C) 2004, 2005 Martin Geisler.
9
+ *
10
+ * This program is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program in the file COPYING; if not, write to the
22
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23
+ * Boston, MA 02110-1301 USA
24
+ */
25
+ namespace lsolesen\pel;
26
+
27
+ /**
28
+ * Routines for converting back and forth between bytes and integers.
29
+ *
30
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
31
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
32
+ * License (GPL)
33
+ * @package PEL
34
+ */
35
+
36
+ /**
37
+ * Conversion functions to and from bytes and integers.
38
+ *
39
+ * The functions found in this class are used to convert bytes into
40
+ * integers of several sizes ({@link bytesToShort}, {@link
41
+ * bytesToLong}, and {@link bytesToRational}) and convert integers of
42
+ * several sizes into bytes ({@link shortToBytes} and {@link
43
+ * longToBytes}).
44
+ *
45
+ * All the methods are static and they all rely on an argument that
46
+ * specifies the byte order to be used, this must be one of the class
47
+ * constants {@link LITTLE_ENDIAN} or {@link BIG_ENDIAN}. These
48
+ * constants will be referred to as the pseudo type PelByteOrder
49
+ * throughout the documentation.
50
+ *
51
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
52
+ * @package PEL
53
+ */
54
+ class PelConvert
55
+ {
56
+
57
+ /**
58
+ * Little-endian (Intel) byte order.
59
+ *
60
+ * Data stored in little-endian byte order store the least
61
+ * significant byte first, so the number 0x12345678 becomes 0x78
62
+ * 0x56 0x34 0x12 when stored with little-endian byte order.
63
+ */
64
+ const LITTLE_ENDIAN = true;
65
+
66
+ /**
67
+ * Big-endian (Motorola) byte order.
68
+ *
69
+ * Data stored in big-endian byte order store the most significant
70
+ * byte first, so the number 0x12345678 becomes 0x12 0x34 0x56 0x78
71
+ * when stored with big-endian byte order.
72
+ */
73
+ const BIG_ENDIAN = false;
74
+
75
+ /**
76
+ * Convert an unsigned short into two bytes.
77
+ *
78
+ * @param integer $value
79
+ * the unsigned short that will be converted. The lower
80
+ * two bytes will be extracted regardless of the actual size passed.
81
+ *
82
+ * @param integer $endian
83
+ * one of {@link LITTLE_ENDIAN} and {@link
84
+ * BIG_ENDIAN}.
85
+ *
86
+ * @return string the bytes representing the unsigned short.
87
+ */
88
+ public static function shortToBytes($value, $endian)
89
+ {
90
+ if ($endian == self::LITTLE_ENDIAN) {
91
+ return chr($value) . chr($value >> 8);
92
+ } else {
93
+ return chr($value >> 8) . chr($value);
94
+ }
95
+ }
96
+
97
+ /**
98
+ * Convert a signed short into two bytes.
99
+ *
100
+ * @param integer $value
101
+ * the signed short that will be converted. The lower
102
+ * two bytes will be extracted regardless of the actual size passed.
103
+ *
104
+ * @param integer $endian
105
+ * one of {@link LITTLE_ENDIAN} and {@link
106
+ * BIG_ENDIAN}.
107
+ *
108
+ * @return string the bytes representing the signed short.
109
+ */
110
+ public static function sShortToBytes($value, $endian)
111
+ {
112
+ /*
113
+ * We can just use shortToBytes, since signed shorts fits well
114
+ * within the 32 bit signed integers used in PHP.
115
+ */
116
+ return self::shortToBytes($value, $endian);
117
+ }
118
+
119
+ /**
120
+ * Convert an unsigned long into four bytes.
121
+ *
122
+ * Because PHP limits the size of integers to 32 bit signed, one
123
+ * cannot really have an unsigned integer in PHP. But integers
124
+ * larger than 2^31-1 will be promoted to 64 bit signed floating
125
+ * point numbers, and so such large numbers can be handled too.
126
+ *
127
+ * @param integer $value
128
+ * the unsigned long that will be converted. The
129
+ * argument will be treated as an unsigned 32 bit integer and the
130
+ * lower four bytes will be extracted. Treating the argument as an
131
+ * unsigned integer means that the absolute value will be used. Use
132
+ * {@link sLongToBytes} to convert signed integers.
133
+ *
134
+ * @param integer $endian
135
+ * one of {@link LITTLE_ENDIAN} and {@link
136
+ * BIG_ENDIAN}.
137
+ *
138
+ * @return string the bytes representing the unsigned long.
139
+ */
140
+ public static function longToBytes($value, $endian)
141
+ {
142
+ /*
143
+ * We cannot convert the number to bytes in the normal way (using
144
+ * shifts and modulo calculations) because the PHP operator >> and
145
+ * function chr() clip their arguments to 2^31-1, which is the
146
+ * largest signed integer known to PHP. But luckily base_convert
147
+ * handles such big numbers.
148
+ */
149
+ $hex = str_pad(base_convert($value, 10, 16), 8, '0', STR_PAD_LEFT);
150
+ if ($endian == self::LITTLE_ENDIAN) {
151
+ return (chr(hexdec($hex{6} . $hex{7})) . chr(hexdec($hex{4} . $hex{5})) . chr(hexdec($hex{2} . $hex{3})) .
152
+ chr(hexdec($hex{0} . $hex{1})));
153
+ } else {
154
+ return (chr(hexdec($hex{0} . $hex{1})) . chr(hexdec($hex{2} . $hex{3})) . chr(hexdec($hex{4} . $hex{5})) .
155
+ chr(hexdec($hex{6} . $hex{7})));
156
+ }
157
+ }
158
+
159
+ /**
160
+ * Convert a signed long into four bytes.
161
+ *
162
+ * @param integer $value
163
+ * the signed long that will be converted. The argument
164
+ * will be treated as a signed 32 bit integer, from which the lower
165
+ * four bytes will be extracted.
166
+ *
167
+ * @param integer $endian
168
+ * one of {@link LITTLE_ENDIAN} and {@link
169
+ * BIG_ENDIAN}.
170
+ *
171
+ * @return string the bytes representing the signed long.
172
+ */
173
+ public static function sLongToBytes($value, $endian)
174
+ {
175
+ /*
176
+ * We can convert the number into bytes in the normal way using
177
+ * shifts and modulo calculations here (in contrast with
178
+ * longToBytes) because PHP automatically handles 32 bit signed
179
+ * integers for us.
180
+ */
181
+ if ($endian == self::LITTLE_ENDIAN) {
182
+ return (chr($value) . chr($value >> 8) . chr($value >> 16) . chr($value >> 24));
183
+ } else {
184
+ return (chr($value >> 24) . chr($value >> 16) . chr($value >> 8) . chr($value));
185
+ }
186
+ }
187
+
188
+ /**
189
+ * Extract an unsigned byte from a string of bytes.
190
+ *
191
+ * @param string $bytes
192
+ * the bytes.
193
+ *
194
+ * @param integer $offset
195
+ * The byte found at the offset will be
196
+ * returned as an integer. The must be at least one byte available
197
+ * at offset.
198
+ *
199
+ * @return integer $offset the unsigned byte found at offset, e.g., an integer
200
+ * in the range 0 to 255.
201
+ */
202
+ public static function bytesToByte($bytes, $offset)
203
+ {
204
+ return ord($bytes{$offset});
205
+ }
206
+
207
+ /**
208
+ * Extract a signed byte from bytes.
209
+ *
210
+ * @param string $bytes
211
+ * the bytes.
212
+ *
213
+ * @param integer $offset
214
+ * the offset. The byte found at the offset will be
215
+ * returned as an integer. The must be at least one byte available
216
+ * at offset.
217
+ *
218
+ * @return integer the signed byte found at offset, e.g., an integer in
219
+ * the range -128 to 127.
220
+ */
221
+ public static function bytesToSByte($bytes, $offset)
222
+ {
223
+ $n = self::bytesToByte($bytes, $offset);
224
+ if ($n > 127) {
225
+ return $n - 256;
226
+ } else {
227
+ return $n;
228
+ }
229
+ }
230
+
231
+ /**
232
+ * Extract an unsigned short from bytes.
233
+ *
234
+ * @param string $bytes
235
+ * the bytes.
236
+ *
237
+ * @param integer $offset
238
+ * the offset. The short found at the offset will be
239
+ * returned as an integer. There must be at least two bytes
240
+ * available beginning at the offset given.
241
+ * @param integer $endian
242
+ * one of {@link LITTLE_ENDIAN} and {@link
243
+ * BIG_ENDIAN}.
244
+ * @return integer the unsigned short found at offset, e.g., an integer
245
+ * in the range 0 to 65535.
246
+ *
247
+ */
248
+ public static function bytesToShort($bytes, $offset, $endian)
249
+ {
250
+ if ($endian == self::LITTLE_ENDIAN) {
251
+ return (ord($bytes{$offset + 1}) * 256 + ord($bytes{$offset}));
252
+ } else {
253
+ return (ord($bytes{$offset}) * 256 + ord($bytes{$offset + 1}));
254
+ }
255
+ }
256
+
257
+ /**
258
+ * Extract a signed short from bytes.
259
+ *
260
+ * @param string $bytes
261
+ *
262
+ * @param integer $offset
263
+ * The short found at offset will be returned
264
+ * as an integer. There must be at least two bytes available
265
+ * beginning at the offset given.
266
+ * @param integer $endian
267
+ * one of {@link LITTLE_ENDIAN} and {@link
268
+ * BIG_ENDIAN}.
269
+ * @return integer the signed byte found at offset, e.g., an integer in
270
+ * the range -32768 to 32767.
271
+ *
272
+ */
273
+ public static function bytesToSShort($bytes, $offset, $endian)
274
+ {
275
+ $n = self::bytesToShort($bytes, $offset, $endian);
276
+ if ($n > 32767) {
277
+ return $n - 65536;
278
+ } else {
279
+ return $n;
280
+ }
281
+ }
282
+
283
+ /**
284
+ * Extract an unsigned long from bytes.
285
+ *
286
+ * @param string $bytes
287
+ *
288
+ * @param integer $offset
289
+ * The long found at offset will be returned
290
+ * as an integer. There must be at least four bytes available
291
+ * beginning at the offset given.
292
+ * @param integer $endian
293
+ * one of {@link LITTLE_ENDIAN} and {@link
294
+ * BIG_ENDIAN}.
295
+ * @return integer the unsigned long found at offset, e.g., an integer
296
+ * in the range 0 to 4294967295.
297
+ *
298
+ */
299
+ public static function bytesToLong($bytes, $offset, $endian)
300
+ {
301
+ if ($endian == self::LITTLE_ENDIAN) {
302
+ return (ord($bytes{$offset + 3}) * 16777216 + ord($bytes{$offset + 2}) * 65536 +
303
+ ord($bytes{$offset + 1}) * 256 + ord($bytes{$offset}));
304
+ } else {
305
+ return (ord($bytes{$offset}) * 16777216 + ord($bytes{$offset + 1}) * 65536 + ord($bytes{$offset + 2}) * 256 +
306
+ ord($bytes{$offset + 3}));
307
+ }
308
+ }
309
+
310
+ /**
311
+ * Extract a signed long from bytes.
312
+ *
313
+ * @param string $bytes
314
+ *
315
+ * @param integer $offset
316
+ * The long found at offset will be returned
317
+ * as an integer. There must be at least four bytes available
318
+ * beginning at the offset given.
319
+ * @param integer $endian
320
+ * one of {@link LITTLE_ENDIAN} and {@link
321
+ * BIG_ENDIAN}. *
322
+ * @return integer the signed long found at offset, e.g., an integer in
323
+ * the range -2147483648 to 2147483647.
324
+ *
325
+ */
326
+ public static function bytesToSLong($bytes, $offset, $endian)
327
+ {
328
+ $n = self::bytesToLong($bytes, $offset, $endian);
329
+ if ($n > 2147483647) {
330
+ return $n - 4294967296;
331
+ } else {
332
+ return $n;
333
+ }
334
+ }
335
+
336
+ /**
337
+ * Extract an unsigned rational from bytes.
338
+ *
339
+ * @param string $bytes
340
+ *
341
+ * @param integer $offset
342
+ * The rational found at offset will be
343
+ * returned as an array. There must be at least eight bytes
344
+ * available beginning at the offset given.
345
+ * @param integer $endian
346
+ * one of {@link LITTLE_ENDIAN} and {@link
347
+ * BIG_ENDIAN}. *
348
+ * @return array the unsigned rational found at offset, e.g., an
349
+ * array with two integers in the range 0 to 4294967295.
350
+ *
351
+ */
352
+ public static function bytesToRational($bytes, $offset, $endian)
353
+ {
354
+ return array(
355
+ self::bytesToLong($bytes, $offset, $endian),
356
+ self::bytesToLong($bytes, $offset + 4, $endian)
357
+ );
358
+ }
359
+
360
+ /**
361
+ * Extract a signed rational from bytes.
362
+ *
363
+ * @param string $bytes
364
+ *
365
+ * @param integer $offset
366
+ * The rational found at offset will be
367
+ * returned as an array. There must be at least eight bytes
368
+ * available beginning at the offset given.
369
+ * @param integer $endian
370
+ * one of {@link LITTLE_ENDIAN} and {@link
371
+ * BIG_ENDIAN}.
372
+ * @return array the signed rational found at offset, e.g., an array
373
+ * with two integers in the range -2147483648 to 2147483647.
374
+ *
375
+ */
376
+ public static function bytesToSRational($bytes, $offset, $endian)
377
+ {
378
+ return array(
379
+ self::bytesToSLong($bytes, $offset, $endian),
380
+ self::bytesToSLong($bytes, $offset + 4, $endian)
381
+ );
382
+ }
383
+
384
+ /**
385
+ * Format bytes for dumping.
386
+ *
387
+ * This method is for debug output, it will format a string as a
388
+ * hexadecimal dump suitable for display on a terminal. The output
389
+ * is printed directly to standard out.
390
+ *
391
+ * @param string $bytes
392
+ * the bytes that will be dumped.
393
+ *
394
+ * @param integer $max
395
+ * the maximum number of bytes to dump. If this is left
396
+ * out (or left to the default of 0), then the entire string will be
397
+ * dumped.
398
+ * @return void
399
+ */
400
+ public static function bytesToDump($bytes, $max = 0)
401
+ {
402
+ $s = strlen($bytes);
403
+
404
+ if ($max > 0) {
405
+ $s = min($max, $s);
406
+ }
407
+ $line = 24;
408
+
409
+ for ($i = 0; $i < $s; $i ++) {
410
+ printf('%02X ', ord($bytes{$i}));
411
+
412
+ if (($i + 1) % $line == 0) {
413
+ print("\n");
414
+ }
415
+ }
416
+ print("\n");
417
+ }
418
+ }
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelDataWindow.php ADDED
@@ -0,0 +1,567 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * PEL: PHP Exif Library.
5
+ * A library with support for reading and
6
+ * writing all Exif headers in JPEG and TIFF images using PHP.
7
+ *
8
+ * Copyright (C) 2004, 2005, 2006, 2007 Martin Geisler.
9
+ *
10
+ * This program is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program in the file COPYING; if not, write to the
22
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23
+ * Boston, MA 02110-1301 USA
24
+ */
25
+ namespace lsolesen\pel;
26
+
27
+ /**
28
+ * The window.
29
+ *
30
+ * @package PEL
31
+ */
32
+ class PelDataWindow
33
+ {
34
+
35
+ /**
36
+ * The data held by this window.
37
+ *
38
+ * The string can contain any kind of data, including binary data.
39
+ *
40
+ * @var string
41
+ */
42
+ private $data = '';
43
+
44
+ /**
45
+ * The byte order currently in use.
46
+ *
47
+ * This will be the byte order used when data is read using the for
48
+ * example the {@link getShort} function. It must be one of {@link
49
+ * PelConvert::LITTLE_ENDIAN} and {@link PelConvert::BIG_ENDIAN}.
50
+ *
51
+ * @var PelByteOrder
52
+ * @see setByteOrder, getByteOrder
53
+ */
54
+ private $order;
55
+
56
+ /**
57
+ * The start of the current window.
58
+ *
59
+ * All offsets used for access into the data will count from this
60
+ * offset, effectively limiting access to a window starting at this
61
+ * byte.
62
+ *
63
+ * @var int
64
+ * @see setWindowStart
65
+ */
66
+ private $start = 0;
67
+
68
+ /**
69
+ * The size of the current window.
70
+ *
71
+ * All offsets used for access into the data will be limited by this
72
+ * variable. A valid offset must be strictly less than this
73
+ * variable.
74
+ *
75
+ * @var int
76
+ * @see setWindowSize
77
+ */
78
+ private $size = 0;
79
+
80
+ /**
81
+ * Construct a new data window with the data supplied.
82
+ *
83
+ * @param mixed $data
84
+ * the data that this window will contain. This can
85
+ * either be given as a string (interpreted litteraly as a sequence
86
+ * of bytes) or a PHP image resource handle. The data will be copied
87
+ * into the new data window.
88
+ *
89
+ * @param boolean $endianess
90
+ * the initial byte order of the window. This must
91
+ * be either {@link PelConvert::LITTLE_ENDIAN} or {@link
92
+ * PelConvert::BIG_ENDIAN}. This will be used when integers are
93
+ * read from the data, and it can be changed later with {@link
94
+ * setByteOrder()}.
95
+ */
96
+ public function __construct($data = '', $endianess = PelConvert::LITTLE_ENDIAN)
97
+ {
98
+ if (is_string($data)) {
99
+ $this->data = $data;
100
+ } elseif (is_resource($data) && get_resource_type($data) == 'gd') {
101
+ /*
102
+ * The ImageJpeg() function insists on printing the bytes
103
+ * instead of returning them in a more civil way as a string, so
104
+ * we have to buffer the output...
105
+ */
106
+ ob_start();
107
+ ImageJpeg($data, null, Pel::getJPEGQuality());
108
+ $this->data = ob_get_clean();
109
+ } else {
110
+ throw new PelInvalidArgumentException('Bad type for $data: %s', gettype($data));
111
+ }
112
+
113
+ $this->order = $endianess;
114
+ $this->size = strlen($this->data);
115
+ }
116
+
117
+ /**
118
+ * Get the size of the data window.
119
+ *
120
+ * @return integer the number of bytes covered by the window. The
121
+ * allowed offsets go from 0 up to this number minus one.
122
+ *
123
+ * @see getBytes()
124
+ */
125
+ public function getSize()
126
+ {
127
+ return $this->size;
128
+ }
129
+
130
+ /**
131
+ * Change the byte order of the data.
132
+ *
133
+ * @param integer $order
134
+ * the new byte order. This must be either
135
+ * {@link PelConvert::LITTLE_ENDIAN} or {@link
136
+ * PelConvert::BIG_ENDIAN}.
137
+ */
138
+ public function setByteOrder($order)
139
+ {
140
+ $this->order = $order;
141
+ }
142
+
143
+ /**
144
+ * Get the currently used byte order.
145
+ *
146
+ * @return integer this will be either {@link
147
+ * PelConvert::LITTLE_ENDIAN} or {@link PelConvert::BIG_ENDIAN}.
148
+ */
149
+ public function getByteOrder()
150
+ {
151
+ return $this->order;
152
+ }
153
+
154
+ /**
155
+ * Move the start of the window forward.
156
+ *
157
+ * @param integer $start
158
+ * the new start of the window. All new offsets will be
159
+ * calculated from this new start offset, and the size of the window
160
+ * will shrink to keep the end of the window in place.
161
+ */
162
+ public function setWindowStart($start)
163
+ {
164
+ if ($start < 0 || $start > $this->size) {
165
+ throw new PelDataWindowWindowException(
166
+ 'Window [%d, %d] does ' . 'not fit in window [0, %d]',
167
+ $start,
168
+ $this->size,
169
+ $this->size);
170
+ }
171
+ $this->start += $start;
172
+ $this->size -= $start;
173
+ }
174
+
175
+ /**
176
+ * Adjust the size of the window.
177
+ * The size can only be made smaller.
178
+ *
179
+ * @param integer $size
180
+ * the desired size of the window. If the argument is
181
+ * negative, the window will be shrunk by the argument.
182
+ */
183
+ public function setWindowSize($size)
184
+ {
185
+ if ($size < 0) {
186
+ $size += $this->size;
187
+ }
188
+ if ($size < 0 || $size > $this->size) {
189
+ throw new PelDataWindowWindowException(
190
+ 'Window [0, %d] ' . 'does not fit in window [0, %d]',
191
+ $size,
192
+ $this->size);
193
+ }
194
+ $this->size = $size;
195
+ }
196
+
197
+ /**
198
+ * Make a new data window with the same data as the this window.
199
+ *
200
+ * @param integer|NULL $start
201
+ * if an integer is supplied, then it will be the start
202
+ * of the window in the clone. If left unspecified, then the clone
203
+ * will inherit the start from this object.
204
+ *
205
+ * @param integer|NULL $size
206
+ * if an integer is supplied, then it will be the size
207
+ * of the window in the clone. If left unspecified, then the clone
208
+ * will inherit the size from this object.
209
+ *
210
+ * @return PelDataWindow a new window that operates on the same data
211
+ * as this window, but (optionally) with a smaller window size.
212
+ */
213
+ public function getClone($start = null, $size = null)
214
+ {
215
+ $c = clone $this;
216
+
217
+ if (is_int($start)) {
218
+ $c->setWindowStart($start);
219
+ }
220
+ if (is_int($size)) {
221
+ $c->setWindowSize($size);
222
+ }
223
+ return $c;
224
+ }
225
+
226
+ /**
227
+ * Validate an offset against the current window.
228
+ *
229
+ * @param integer $offset
230
+ * the offset to be validated. If the offset is negative
231
+ * or if it is greater than or equal to the current window size,
232
+ * then a {@link PelDataWindowOffsetException} is thrown.
233
+ *
234
+ * @return void if the offset is valid nothing is returned, if it is
235
+ * invalid a new {@link PelDataWindowOffsetException} is thrown.
236
+ * @throws PelDataWindowOffsetException
237
+ */
238
+ private function validateOffset($offset)
239
+ {
240
+ if ($offset < 0 || $offset >= $this->size) {
241
+ throw new PelDataWindowOffsetException('Offset %d not within [%d, %d]', $offset, 0, $this->size - 1);
242
+ }
243
+ }
244
+
245
+ /**
246
+ * Return some or all bytes visible in the window.
247
+ *
248
+ * This method works just like the standard {@link substr()}
249
+ * function in PHP with the exception that it works within the
250
+ * window of accessible bytes and does strict range checking.
251
+ *
252
+ * @param integer|NULL $start
253
+ * the offset to the first byte returned. If a negative
254
+ * number is given, then the counting will be from the end of the
255
+ * window. Invalid offsets will result in a {@link
256
+ * PelDataWindowOffsetException} being thrown.
257
+ *
258
+ * @param integer|NUL $size
259
+ * the size of the sub-window. If a negative number is
260
+ * given, then that many bytes will be omitted from the result.
261
+ *
262
+ * @return string a subset of the bytes in the window. This will
263
+ * always return no more than {@link getSize()} bytes.
264
+ * @throws PelDataWindowOffsetException
265
+ */
266
+ public function getBytes($start = null, $size = null)
267
+ {
268
+ if (is_int($start)) {
269
+ if ($start < 0) {
270
+ $start += $this->size;
271
+ }
272
+
273
+ $this->validateOffset($start);
274
+ } else {
275
+ $start = 0;
276
+ }
277
+
278
+ if (is_int($size)) {
279
+ if ($size <= 0) {
280
+ $size += $this->size - $start;
281
+ }
282
+
283
+ $this->validateOffset($start + $size);
284
+ } else {
285
+ $size = $this->size - $start;
286
+ }
287
+
288
+ return substr($this->data, $this->start + $start, $size);
289
+ }
290
+
291
+ /**
292
+ * Return an unsigned byte from the data.
293
+ *
294
+ * @param integer $offset
295
+ * the offset into the data. An offset of zero will
296
+ * return the first byte in the current allowed window. The last
297
+ * valid offset is equal to {@link getSize()}-1. Invalid offsets
298
+ * will result in a {@link PelDataWindowOffsetException} being
299
+ * thrown.
300
+ *
301
+ * @return integer the unsigned byte found at offset.
302
+ * @throws PelDataWindowOffsetException
303
+ */
304
+ public function getByte($offset = 0)
305
+ {
306
+ /*
307
+ * Validate the offset --- this throws an exception if offset is
308
+ * out of range.
309
+ */
310
+ $this->validateOffset($offset);
311
+
312
+ /* Translate the offset into an offset into the data. */
313
+ $offset += $this->start;
314
+
315
+ /* Return an unsigned byte. */
316
+ return PelConvert::bytesToByte($this->data, $offset);
317
+ }
318
+
319
+ /**
320
+ * Return a signed byte from the data.
321
+ *
322
+ * @param integer $offset
323
+ * the offset into the data. An offset of zero will
324
+ * return the first byte in the current allowed window. The last
325
+ * valid offset is equal to {@link getSize()}-1. Invalid offsets
326
+ * will result in a {@link PelDataWindowOffsetException} being
327
+ * thrown.
328
+ *
329
+ * @return integer the signed byte found at offset.
330
+ * @throws PelDataWindowOffsetException
331
+ */
332
+ public function getSByte($offset = 0)
333
+ {
334
+ /*
335
+ * Validate the offset --- this throws an exception if offset is
336
+ * out of range.
337
+ */
338
+ $this->validateOffset($offset);
339
+
340
+ /* Translate the offset into an offset into the data. */
341
+ $offset += $this->start;
342
+
343
+ /* Return a signed byte. */
344
+ return PelConvert::bytesToSByte($this->data, $offset);
345
+ }
346
+
347
+ /**
348
+ * Return an unsigned short read from the data.
349
+ *
350
+ * @param integer $offset
351
+ * the offset into the data. An offset of zero will
352
+ * return the first short available in the current allowed window.
353
+ * The last valid offset is equal to {@link getSize()}-2. Invalid
354
+ * offsets will result in a {@link PelDataWindowOffsetException}
355
+ * being thrown.
356
+ *
357
+ * @return integer the unsigned short found at offset.
358
+ * @throws PelDataWindowOffsetException
359
+ */
360
+ public function getShort($offset = 0)
361
+ {
362
+ /*
363
+ * Validate the offset+1 to see if we can safely get two bytes ---
364
+ * this throws an exception if offset is out of range.
365
+ */
366
+ $this->validateOffset($offset);
367
+ $this->validateOffset($offset + 1);
368
+
369
+ /* Translate the offset into an offset into the data. */
370
+ $offset += $this->start;
371
+
372
+ /* Return an unsigned short. */
373
+ return PelConvert::bytesToShort($this->data, $offset, $this->order);
374
+ }
375
+
376
+ /**
377
+ * Return a signed short read from the data.
378
+ *
379
+ * @param integer $offset
380
+ * the offset into the data. An offset of zero will
381
+ * return the first short available in the current allowed window.
382
+ * The last valid offset is equal to {@link getSize()}-2. Invalid
383
+ * offsets will result in a {@link PelDataWindowOffsetException}
384
+ * being thrown.
385
+ *
386
+ * @return integer the signed short found at offset.
387
+ * @throws PelDataWindowOffsetException
388
+ */
389
+ public function getSShort($offset = 0)
390
+ {
391
+ /*
392
+ * Validate the offset+1 to see if we can safely get two bytes ---
393
+ * this throws an exception if offset is out of range.
394
+ */
395
+ $this->validateOffset($offset);
396
+ $this->validateOffset($offset + 1);
397
+
398
+ /* Translate the offset into an offset into the data. */
399
+ $offset += $this->start;
400
+
401
+ /* Return a signed short. */
402
+ return PelConvert::bytesToSShort($this->data, $offset, $this->order);
403
+ }
404
+
405
+ /**
406
+ * Return an unsigned long read from the data.
407
+ *
408
+ * @param integer $offset
409
+ * the offset into the data. An offset of zero will
410
+ * return the first long available in the current allowed window.
411
+ * The last valid offset is equal to {@link getSize()}-4. Invalid
412
+ * offsets will result in a {@link PelDataWindowOffsetException}
413
+ * being thrown.
414
+ *
415
+ * @return integer the unsigned long found at offset.
416
+ * @throws PelDataWindowOffsetException
417
+ */
418
+ public function getLong($offset = 0)
419
+ {
420
+ /*
421
+ * Validate the offset+3 to see if we can safely get four bytes
422
+ * --- this throws an exception if offset is out of range.
423
+ */
424
+ $this->validateOffset($offset);
425
+ $this->validateOffset($offset + 3);
426
+
427
+ /* Translate the offset into an offset into the data. */
428
+ $offset += $this->start;
429
+
430
+ /* Return an unsigned long. */
431
+ return PelConvert::bytesToLong($this->data, $offset, $this->order);
432
+ }
433
+
434
+ /**
435
+ * Return a signed long read from the data.
436
+ *
437
+ * @param integer $offset
438
+ * the offset into the data. An offset of zero will
439
+ * return the first long available in the current allowed window.
440
+ * The last valid offset is equal to {@link getSize()}-4. Invalid
441
+ * offsets will result in a {@link PelDataWindowOffsetException}
442
+ * being thrown.
443
+ *
444
+ * @return integer the signed long found at offset.
445
+ * @throws PelDataWindowOffsetException
446
+ */
447
+ public function getSLong($offset = 0)
448
+ {
449
+ /*
450
+ * Validate the offset+3 to see if we can safely get four bytes
451
+ * --- this throws an exception if offset is out of range.
452
+ */
453
+ $this->validateOffset($offset);
454
+ $this->validateOffset($offset + 3);
455
+
456
+ /* Translate the offset into an offset into the data. */
457
+ $offset += $this->start;
458
+
459
+ /* Return a signed long. */
460
+ return PelConvert::bytesToSLong($this->data, $offset, $this->order);
461
+ }
462
+
463
+ /**
464
+ * Return an unsigned rational read from the data.
465
+ *
466
+ * @param integer $offset
467
+ * the offset into the data. An offset of zero will
468
+ * return the first rational available in the current allowed
469
+ * window. The last valid offset is equal to {@link getSize()}-8.
470
+ * Invalid offsets will result in a {@link
471
+ * PelDataWindowOffsetException} being thrown.
472
+ *
473
+ * @return array the unsigned rational found at offset. A rational
474
+ * number is represented as an array of two numbers: the enumerator
475
+ * and denominator. Both of these numbers will be unsigned longs.
476
+ * @throws PelDataWindowOffsetException
477
+ */
478
+ public function getRational($offset = 0)
479
+ {
480
+ return array(
481
+ $this->getLong($offset),
482
+ $this->getLong($offset + 4)
483
+ );
484
+ }
485
+
486
+ /**
487
+ * Return a signed rational read from the data.
488
+ *
489
+ * @param integer $offset
490
+ * the offset into the data. An offset of zero will
491
+ * return the first rational available in the current allowed
492
+ * window. The last valid offset is equal to {@link getSize()}-8.
493
+ * Invalid offsets will result in a {@link
494
+ * PelDataWindowOffsetException} being thrown.
495
+ *
496
+ * @return array the signed rational found at offset. A rational
497
+ * number is represented as an array of two numbers: the enumerator
498
+ * and denominator. Both of these numbers will be signed longs.
499
+ * @throws PelDataWindowOffsetException
500
+ */
501
+ public function getSRational($offset = 0)
502
+ {
503
+ return array(
504
+ $this->getSLong($offset),
505
+ $this->getSLong($offset + 4)
506
+ );
507
+ }
508
+
509
+ /**
510
+ * String comparison on substrings.
511
+ *
512
+ * @param integer $offset
513
+ * the offset into the data. An offset of zero will make
514
+ * the comparison start with the very first byte available in the
515
+ * window. The last valid offset is equal to {@link getSize()}
516
+ * minus the length of the string. If the string is too long, then
517
+ * a {@link PelDataWindowOffsetException} will be thrown.
518
+ *
519
+ * @param string $str
520
+ * the string to compare with.
521
+ *
522
+ * @return boolean true if the string given matches the data in the
523
+ * window, at the specified offset, false otherwise. The comparison
524
+ * will stop as soon as a mismatch if found.
525
+ * @throws PelDataWindowOffsetException
526
+ */
527
+ public function strcmp($offset, $str)
528
+ {
529
+ /*
530
+ * Validate the offset of the final character we might have to
531
+ * check.
532
+ */
533
+ $s = strlen($str);
534
+ $this->validateOffset($offset);
535
+ $this->validateOffset($offset + $s - 1);
536
+
537
+ /* Translate the offset into an offset into the data. */
538
+ $offset += $this->start;
539
+
540
+ /* Check each character, return as soon as the answer is known. */
541
+ for ($i = 0; $i < $s; $i ++) {
542
+ if ($this->data{$offset + $i} != $str{$i}) {
543
+ return false;
544
+ }
545
+ }
546
+
547
+ /* All characters matches each other, return true. */
548
+ return true;
549
+ }
550
+
551
+ /**
552
+ * Return a string representation of the data window.
553
+ *
554
+ * @return string a description of the window with information about
555
+ * the number of bytes accessible, the total number of bytes, and
556
+ * the window start and stop.
557
+ */
558
+ public function __toString()
559
+ {
560
+ return Pel::fmt(
561
+ 'DataWindow: %d bytes in [%d, %d] of %d bytes',
562
+ $this->size,
563
+ $this->start,
564
+ $this->start + $this->size,
565
+ strlen($this->data));
566
+ }
567
+ }
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelDataWindowOffsetException.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * PEL: PHP Exif Library.
5
+ * A library with support for reading and
6
+ * writing all Exif headers in JPEG and TIFF images using PHP.
7
+ *
8
+ * Copyright (C) 2004, 2005, 2006, 2007 Martin Geisler.
9
+ *
10
+ * This program is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program in the file COPYING; if not, write to the
22
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23
+ * Boston, MA 02110-1301 USA
24
+ */
25
+ namespace lsolesen\pel;
26
+
27
+ /**
28
+ * An exception thrown when an invalid offset is encountered.
29
+ *
30
+ * @package PEL
31
+ * @subpackage Exception
32
+ */
33
+ class PelDataWindowOffsetException extends PelException
34
+ {
35
+ }
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelDataWindowWindowException.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * PEL: PHP Exif Library.
5
+ * A library with support for reading and
6
+ * writing all Exif headers in JPEG and TIFF images using PHP.
7
+ *
8
+ * Copyright (C) 2004, 2005, 2006, 2007 Martin Geisler.
9
+ *
10
+ * This program is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program in the file COPYING; if not, write to the
22
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23
+ * Boston, MA 02110-1301 USA
24
+ */
25
+ namespace lsolesen\pel;
26
+
27
+ /**
28
+ * A container for bytes with a limited window of accessible bytes.
29
+ *
30
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
31
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public License (GPL)
32
+ * @package PEL
33
+ */
34
+
35
+ /**
36
+ * An exception thrown when an invalid window is encountered.
37
+ *
38
+ * @package PEL
39
+ * @subpackage Exception
40
+ */
41
+ class PelDataWindowWindowException extends PelException
42
+ {
43
+ }
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelEntry.php ADDED
@@ -0,0 +1,253 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * PEL: PHP Exif Library.
5
+ * A library with support for reading and
6
+ * writing all Exif headers in JPEG and TIFF images using PHP.
7
+ *
8
+ * Copyright (C) 2004, 2005, 2006 Martin Geisler.
9
+ *
10
+ * This program is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program in the file COPYING; if not, write to the
22
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23
+ * Boston, MA 02110-1301 USA
24
+ */
25
+ namespace lsolesen\pel;
26
+
27
+ /**
28
+ * Classes for dealing with Exif entries.
29
+ *
30
+ * This file defines two exception classes and the abstract class
31
+ * {@link PelEntry} which provides the basic methods that all Exif
32
+ * entries will have. All Exif entries will be represented by
33
+ * descendants of the {@link PelEntry} class --- the class itself is
34
+ * abstract and so it cannot be instantiated.
35
+ *
36
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
37
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
38
+ * License (GPL)
39
+ * @package PEL
40
+ */
41
+
42
+ /**
43
+ * Common ancestor class of all {@link PelIfd} entries.
44
+ *
45
+ * As this class is abstract you cannot instantiate objects from it.
46
+ * It only serves as a common ancestor to define the methods common to
47
+ * all entries. The most important methods are {@link getValue()} and
48
+ * {@link setValue()}, both of which is abstract in this class. The
49
+ * descendants will give concrete implementations for them.
50
+ *
51
+ * If you have some data coming from an image (some raw bytes), then
52
+ * the static method {@link newFromData()} is helpful --- it will look
53
+ * at the data and give you a proper decendent of {@link PelEntry}
54
+ * back.
55
+ *
56
+ * If you instead want to have an entry for some data which take the
57
+ * form of an integer, a string, a byte, or some other PHP type, then
58
+ * don't use this class. You should instead create an object of the
59
+ * right subclass ({@link PelEntryShort} for short integers, {@link
60
+ * PelEntryAscii} for strings, and so on) directly.
61
+ *
62
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
63
+ * @package PEL
64
+ */
65
+ abstract class PelEntry
66
+ {
67
+
68
+ /**
69
+ * Type of IFD containing this tag.
70
+ *
71
+ * This must be one of the constants defined in {@link PelIfd}:
72
+ * {@link PelIfd::IFD0} for the main image IFD, {@link PelIfd::IFD1}
73
+ * for the thumbnail image IFD, {@link PelIfd::EXIF} for the Exif
74
+ * sub-IFD, {@link PelIfd::GPS} for the GPS sub-IFD, or {@link
75
+ * PelIfd::INTEROPERABILITY} for the interoperability sub-IFD.
76
+ *
77
+ * @var int
78
+ */
79
+ protected $ifd_type;
80
+
81
+ /**
82
+ * The bytes representing this entry.
83
+ *
84
+ * Subclasses must either override {@link getBytes()} or, if
85
+ * possible, maintain this property so that it always contains a
86
+ * true representation of the entry.
87
+ *
88
+ * @var string
89
+ */
90
+ protected $bytes = '';
91
+
92
+ /**
93
+ * The {@link PelTag} of this entry.
94
+ *
95
+ * @var PelTag
96
+ */
97
+ protected $tag;
98
+
99
+ /**
100
+ * The {@link PelFormat} of this entry.
101
+ *
102
+ * @var PelFormat
103
+ */
104
+ protected $format;
105
+
106
+ /**
107
+ * The number of components of this entry.
108
+ *
109
+ * @var int
110
+ */
111
+ protected $components;
112
+
113
+ /**
114
+ * Return the tag of this entry.
115
+ *
116
+ * @return PelTag the tag of this entry.
117
+ */
118
+ public function getTag()
119
+ {
120
+ return $this->tag;
121
+ }
122
+
123
+ /**
124
+ * Return the type of IFD which holds this entry.
125
+ *
126
+ * @return int one of the constants defined in {@link PelIfd}:
127
+ * {@link PelIfd::IFD0} for the main image IFD, {@link PelIfd::IFD1}
128
+ * for the thumbnail image IFD, {@link PelIfd::EXIF} for the Exif
129
+ * sub-IFD, {@link PelIfd::GPS} for the GPS sub-IFD, or {@link
130
+ * PelIfd::INTEROPERABILITY} for the interoperability sub-IFD.
131
+ */
132
+ public function getIfdType()
133
+ {
134
+ return $this->ifd_type;
135
+ }
136
+
137
+ /**
138
+ * Update the IFD type.
139
+ *
140
+ * @param
141
+ * int must be one of the constants defined in {@link
142
+ * PelIfd}: {@link PelIfd::IFD0} for the main image IFD, {@link
143
+ * PelIfd::IFD1} for the thumbnail image IFD, {@link PelIfd::EXIF}
144
+ * for the Exif sub-IFD, {@link PelIfd::GPS} for the GPS sub-IFD, or
145
+ * {@link PelIfd::INTEROPERABILITY} for the interoperability
146
+ * sub-IFD.
147
+ */
148
+ public function setIfdType($type)
149
+ {
150
+ $this->ifd_type = $type;
151
+ }
152
+
153
+ /**
154
+ * Return the format of this entry.
155
+ *
156
+ * @return PelFormat the format of this entry.
157
+ */
158
+ public function getFormat()
159
+ {
160
+ return $this->format;
161
+ }
162
+
163
+ /**
164
+ * Return the number of components of this entry.
165
+ *
166
+ * @return int the number of components of this entry.
167
+ */
168
+ public function getComponents()
169
+ {
170
+ return $this->components;
171
+ }
172
+
173
+ /**
174
+ * Turn this entry into bytes.
175
+ *
176
+ * @param
177
+ * PelByteOrder the desired byte order, which must be either
178
+ * {@link Convert::LITTLE_ENDIAN} or {@link Convert::BIG_ENDIAN}.
179
+ *
180
+ * @return string bytes representing this entry.
181
+ */
182
+ public function getBytes($o)
183
+ {
184
+ return $this->bytes;
185
+ }
186
+
187
+ /**
188
+ * Get the value of this entry as text.
189
+ *
190
+ * The value will be returned in a format suitable for presentation,
191
+ * e.g., rationals will be returned as 'x/y', ASCII strings will be
192
+ * returned as themselves etc.
193
+ *
194
+ * @param
195
+ * boolean some values can be returned in a long or more
196
+ * brief form, and this parameter controls that.
197
+ *
198
+ * @return string the value as text.
199
+ */
200
+ abstract public function getText($brief = false);
201
+
202
+ /**
203
+ * Get the value of this entry.
204
+ *
205
+ * The value returned will generally be the same as the one supplied
206
+ * to the constructor or with {@link setValue()}. For a formatted
207
+ * version of the value, one should use {@link getText()} instead.
208
+ *
209
+ * @return mixed the unformatted value.
210
+ */
211
+ abstract public function getValue();
212
+
213
+ /**
214
+ * Set the value of this entry.
215
+ *
216
+ * The value should be in the same format as for the constructor.
217
+ *
218
+ * @param
219
+ * mixed the new value.
220
+ *
221
+ * @abstract
222
+ *
223
+ */
224
+ public function setValue($value)
225
+ {
226
+ /*
227
+ * This (fake) abstract method is here to make it possible for the
228
+ * documentation to refer to PelEntry::setValue().
229
+ * It cannot declared abstract in the proper PHP way, for then PHP
230
+ * wont allow subclasses to define it with two arguments (which is
231
+ * what PelEntryCopyright does).
232
+ */
233
+ throw new PelException('setValue() is abstract.');
234
+ }
235
+
236
+ /**
237
+ * Turn this entry into a string.
238
+ *
239
+ * @return string a string representation of this entry. This is
240
+ * mostly for debugging.
241
+ */
242
+ public function __toString()
243
+ {
244
+ $str = Pel::fmt(" Tag: 0x%04X (%s)\n", $this->tag, PelTag::getName($this->ifd_type, $this->tag));
245
+ $str .= Pel::fmt(" Format : %d (%s)\n", $this->format, PelFormat::getName($this->format));
246
+ $str .= Pel::fmt(" Components: %d\n", $this->components);
247
+ if ($this->getTag() != PelTag::MAKER_NOTE && $this->getTag() != PelTag::PRINT_IM) {
248
+ $str .= Pel::fmt(" Value : %s\n", print_r($this->getValue(), true));
249
+ }
250
+ $str .= Pel::fmt(" Text : %s\n", $this->getText());
251
+ return $str;
252
+ }
253
+ }
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelEntryAscii.php ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * PEL: PHP Exif Library.
5
+ * A library with support for reading and
6
+ * writing all Exif headers in JPEG and TIFF images using PHP.
7
+ *
8
+ * Copyright (C) 2004, 2005, 2006, 2007 Martin Geisler.
9
+ *
10
+ * This program is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program in the file COPYING; if not, write to the
22
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23
+ * Boston, MA 02110-1301 USA
24
+ */
25
+ namespace lsolesen\pel;
26
+
27
+ /**
28
+ * Classes used to hold ASCII strings.
29
+ *
30
+ * The classes defined here are to be used for Exif entries holding
31
+ * ASCII strings, such as {@link PelTag::MAKE}, {@link
32
+ * PelTag::SOFTWARE}, and {@link PelTag::DATE_TIME}. For
33
+ * entries holding normal textual ASCII strings the class {@link
34
+ * PelEntryAscii} should be used, but for entries holding
35
+ * timestamps the class {@link PelEntryTime} would be more
36
+ * convenient instead. Copyright information is handled by the {@link
37
+ * PelEntryCopyright} class.
38
+ *
39
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
40
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
41
+ * License (GPL)
42
+ * @package PEL
43
+ */
44
+
45
+ /**
46
+ * Class for holding a plain ASCII string.
47
+ *
48
+ * This class can hold a single ASCII string, and it will be used as in
49
+ * <code>
50
+ * $entry = $ifd->getEntry(PelTag::IMAGE_DESCRIPTION);
51
+ * print($entry->getValue());
52
+ * $entry->setValue('This is my image. I like it.');
53
+ * </code>
54
+ *
55
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
56
+ * @package PEL
57
+ */
58
+ class PelEntryAscii extends PelEntry
59
+ {
60
+
61
+ /**
62
+ * The string hold by this entry.
63
+ *
64
+ * This is the string that was given to the {@link __construct
65
+ * constructor} or later to {@link setValue}, without any final NULL
66
+ * character.
67
+ *
68
+ * @var string
69
+ */
70
+ private $str;
71
+
72
+ /**
73
+ * Make a new PelEntry that can hold an ASCII string.
74
+ *
75
+ * @param int $tag
76
+ * the tag which this entry represents. This should be
77
+ * one of the constants defined in {@link PelTag}, e.g., {@link
78
+ * PelTag::IMAGE_DESCRIPTION}, {@link PelTag::MODEL}, or any other
79
+ * tag with format {@link PelFormat::ASCII}.
80
+ *
81
+ * @param string $str
82
+ * the string that this entry will represent. The
83
+ * string must obey the same rules as the string argument to {@link
84
+ * setValue}, namely that it should be given without any trailing
85
+ * NULL character and that it must be plain 7-bit ASCII.
86
+ */
87
+ public function __construct($tag, $str = '')
88
+ {
89
+ $this->tag = $tag;
90
+ $this->format = PelFormat::ASCII;
91
+ self::setValue($str);
92
+ }
93
+
94
+ /**
95
+ * Give the entry a new ASCII value.
96
+ *
97
+ * This will overwrite the previous value. The value can be
98
+ * retrieved later with the {@link getValue} method.
99
+ *
100
+ * @param
101
+ * string the new value of the entry. This should be given
102
+ * without any trailing NULL character. The string must be plain
103
+ * 7-bit ASCII, the string should contain no high bytes.
104
+ *
105
+ * @todo Implement check for high bytes?
106
+ */
107
+ public function setValue($str)
108
+ {
109
+ $this->components = strlen($str) + 1;
110
+ $this->str = $str;
111
+ $this->bytes = $str . chr(0x00);
112
+ }
113
+
114
+ /**
115
+ * Return the ASCII string of the entry.
116
+ *
117
+ * @return string the string held, without any final NULL character.
118
+ * The string will be the same as the one given to {@link setValue}
119
+ * or to the {@link __construct constructor}.
120
+ */
121
+ public function getValue()
122
+ {
123
+ return $this->str;
124
+ }
125
+
126
+ /**
127
+ * Return the ASCII string of the entry.
128
+ *
129
+ * This methods returns the same as {@link getValue}.
130
+ *
131
+ * @param
132
+ * boolean not used with ASCII entries.
133
+ *
134
+ * @return string the string held, without any final NULL character.
135
+ * The string will be the same as the one given to {@link setValue}
136
+ * or to the {@link __construct constructor}.
137
+ */
138
+ public function getText($brief = false)
139
+ {
140
+ return $this->str;
141
+ }
142
+ }
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelEntryByte.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * PEL: PHP Exif Library.
5
+ * A library with support for reading and
6
+ * writing all Exif headers in JPEG and TIFF images using PHP.
7
+ *
8
+ * Copyright (C) 2004, 2005, 2006, 2007 Martin Geisler.
9
+ *
10
+ * This program is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program in the file COPYING; if not, write to the
22
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23
+ * Boston, MA 02110-1301 USA
24
+ */
25
+ namespace lsolesen\pel;
26
+
27
+ /**
28
+ * Classes used to hold bytes, both signed and unsigned.
29
+ * The {@link
30
+ * PelEntryWindowsString} class is used to manipulate strings in the
31
+ * format Windows XP needs.
32
+ *
33
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
34
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
35
+ * License (GPL)
36
+ * @package PEL
37
+ */
38
+
39
+ /**
40
+ * Class for holding unsigned bytes.
41
+ *
42
+ * This class can hold bytes, either just a single byte or an array of
43
+ * bytes. The class will be used to manipulate any of the Exif tags
44
+ * which has format {@link PelFormat::BYTE}.
45
+ *
46
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
47
+ * @package PEL
48
+ */
49
+ class PelEntryByte extends PelEntryNumber
50
+ {
51
+
52
+ /**
53
+ * Make a new entry that can hold an unsigned byte.
54
+ *
55
+ * The method accept several integer arguments. The {@link
56
+ * getValue} method will always return an array except for when a
57
+ * single integer argument is given here.
58
+ *
59
+ * @param PelTag $tag
60
+ * the tag which this entry represents. This
61
+ * should be one of the constants defined in {@link PelTag}
62
+ * which has format {@link PelFormat::BYTE}.
63
+ *
64
+ * @param int $value...
65
+ * the byte(s) that this entry will represent.
66
+ * The argument passed must obey the same rules as the argument to
67
+ * {@link setValue}, namely that it should be within range of an
68
+ * unsigned byte, that is between 0 and 255 (inclusive). If not,
69
+ * then a {@link PelOverflowException} will be thrown.
70
+ */
71
+ public function __construct($tag, $value = null)
72
+ {
73
+ $this->tag = $tag;
74
+ $this->min = 0;
75
+ $this->max = 255;
76
+ $this->format = PelFormat::BYTE;
77
+
78
+ $value = func_get_args();
79
+ array_shift($value);
80
+ $this->setValueArray($value);
81
+ }
82
+
83
+ /**
84
+ * Convert a number into bytes.
85
+ *
86
+ * @param int $number
87
+ * the number that should be converted.
88
+ *
89
+ * @param PelByteOrder $order
90
+ * one of {@link PelConvert::LITTLE_ENDIAN} and
91
+ * {@link PelConvert::BIG_ENDIAN}, specifying the target byte order.
92
+ *
93
+ * @return string bytes representing the number given.
94
+ */
95
+ public function numberToBytes($number, $order)
96
+ {
97
+ return chr($number);
98
+ }
99
+ }
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelEntryCopyright.php ADDED
@@ -0,0 +1,191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * PEL: PHP Exif Library.
5
+ * A library with support for reading and
6
+ * writing all Exif headers in JPEG and TIFF images using PHP.
7
+ *
8
+ * Copyright (C) 2004, 2005, 2006, 2007 Martin Geisler.
9
+ *
10
+ * This program is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program in the file COPYING; if not, write to the
22
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23
+ * Boston, MA 02110-1301 USA
24
+ */
25
+ namespace lsolesen\pel;
26
+
27
+ /**
28
+ * Classes used to hold ASCII strings.
29
+ *
30
+ * The classes defined here are to be used for Exif entries holding
31
+ * ASCII strings, such as {@link PelTag::MAKE}, {@link
32
+ * PelTag::SOFTWARE}, and {@link PelTag::DATE_TIME}. For
33
+ * entries holding normal textual ASCII strings the class {@link
34
+ * PelEntryAscii} should be used, but for entries holding
35
+ * timestamps the class {@link PelEntryTime} would be more
36
+ * convenient instead. Copyright information is handled by the {@link
37
+ * PelEntryCopyright} class.
38
+ *
39
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
40
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
41
+ * License (GPL)
42
+ * @package PEL
43
+ */
44
+
45
+ /**
46
+ * Class for holding copyright information.
47
+ *
48
+ * The Exif standard specifies a certain format for copyright
49
+ * information where the one {@link PelTag::COPYRIGHT copyright
50
+ * tag} holds both the photographer and editor copyrights, separated
51
+ * by a NULL character.
52
+ *
53
+ * This class is used to manipulate that tag so that the format is
54
+ * kept to the standard. A common use would be to add a new copyright
55
+ * tag to an image, since most cameras do not add this tag themselves.
56
+ * This would be done like this:
57
+ *
58
+ * <code>
59
+ * $entry = new PelEntryCopyright('Copyright, Martin Geisler, 2004');
60
+ * $ifd0->addEntry($entry);
61
+ * </code>
62
+ *
63
+ * Here we only set the photographer copyright, use the optional
64
+ * second argument to specify the editor copyright. If there is only
65
+ * an editor copyright, then let the first argument be the empty
66
+ * string.
67
+ *
68
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
69
+ * @package PEL
70
+ */
71
+ class PelEntryCopyright extends PelEntryAscii
72
+ {
73
+
74
+ /**
75
+ * The photographer copyright.
76
+ *
77
+ * @var string
78
+ */
79
+ private $photographer;
80
+
81
+ /**
82
+ * The editor copyright.
83
+ *
84
+ * @var string
85
+ */
86
+ private $editor;
87
+
88
+ /**
89
+ * Make a new entry for holding copyright information.
90
+ *
91
+ * @param
92
+ * string the photographer copyright. Use the empty string
93
+ * if there is no photographer copyright.
94
+ *
95
+ * @param
96
+ * string the editor copyright. Use the empty string if
97
+ * there is no editor copyright.
98
+ */
99
+ public function __construct($photographer = '', $editor = '')
100
+ {
101
+ parent::__construct(PelTag::COPYRIGHT);
102
+ $this->setValue($photographer, $editor);
103
+ }
104
+
105
+ /**
106
+ * Update the copyright information.
107
+ *
108
+ * @param
109
+ * string the photographer copyright. Use the empty string
110
+ * if there is no photographer copyright.
111
+ *
112
+ * @param
113
+ * string the editor copyright. Use the empty string if
114
+ * there is no editor copyright.
115
+ */
116
+ public function setValue($photographer = '', $editor = '')
117
+ {
118
+ $this->photographer = $photographer;
119
+ $this->editor = $editor;
120
+
121
+ if ($photographer == '' && $editor != '') {
122
+ $photographer = ' ';
123
+ }
124
+
125
+ if ($editor == '') {
126
+ parent::setValue($photographer);
127
+ } else {
128
+ parent::setValue($photographer . chr(0x00) . $editor);
129
+ }
130
+ }
131
+
132
+ /**
133
+ * Retrive the copyright information.
134
+ *
135
+ * The strings returned will be the same as the one used previously
136
+ * with either {@link __construct the constructor} or with {@link
137
+ * setValue}.
138
+ *
139
+ * @return array an array with two strings, the photographer and
140
+ * editor copyrights. The two fields will be returned in that
141
+ * order, so that the first array index will be the photographer
142
+ * copyright, and the second will be the editor copyright.
143
+ */
144
+ public function getValue()
145
+ {
146
+ return array(
147
+ $this->photographer,
148
+ $this->editor
149
+ );
150
+ }
151
+
152
+ /**
153
+ * Return a text string with the copyright information.
154
+ *
155
+ * The photographer and editor copyright fields will be returned
156
+ * with a '-' in between if both copyright fields are present,
157
+ * otherwise only one of them will be returned.
158
+ *
159
+ * @param
160
+ * boolean if false, then the strings '(Photographer)' and
161
+ * '(Editor)' will be appended to the photographer and editor
162
+ * copyright fields (if present), otherwise the fields will be
163
+ * returned as is.
164
+ *
165
+ * @return string the copyright information in a string.
166
+ */
167
+ public function getText($brief = false)
168
+ {
169
+ if ($brief) {
170
+ $p = '';
171
+ $e = '';
172
+ } else {
173
+ $p = ' ' . Pel::tra('(Photographer)');
174
+ $e = ' ' . Pel::tra('(Editor)');
175
+ }
176
+
177
+ if ($this->photographer != '' && $this->editor != '') {
178
+ return $this->photographer . $p . ' - ' . $this->editor . $e;
179
+ }
180
+
181
+ if ($this->photographer != '') {
182
+ return $this->photographer . $p;
183
+ }
184
+
185
+ if ($this->editor != '') {
186
+ return $this->editor . $e;
187
+ }
188
+
189
+ return '';
190
+ }
191
+ }
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelEntryException.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * PEL: PHP Exif Library.
5
+ * A library with support for reading and
6
+ * writing all Exif headers in JPEG and TIFF images using PHP.
7
+ *
8
+ * Copyright (C) 2004, 2005, 2006 Martin Geisler.
9
+ *
10
+ * This program is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program in the file COPYING; if not, write to the
22
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23
+ * Boston, MA 02110-1301 USA
24
+ */
25
+ namespace lsolesen\pel;
26
+
27
+ /**
28
+ * Classes for dealing with Exif entries.
29
+ *
30
+ * This file defines two exception classes and the abstract class
31
+ * {@link PelEntry} which provides the basic methods that all Exif
32
+ * entries will have. All Exif entries will be represented by
33
+ * descendants of the {@link PelEntry} class --- the class itself is
34
+ * abstract and so it cannot be instantiated.
35
+ *
36
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
37
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
38
+ * License (GPL)
39
+ * @package PEL
40
+ */
41
+
42
+ /**
43
+ * Exception indicating a problem with an entry.
44
+ *
45
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
46
+ * @package PEL
47
+ * @subpackage Exception
48
+ */
49
+ class PelEntryException extends PelException
50
+ {
51
+
52
+ /**
53
+ * The IFD type (if known).
54
+ *
55
+ * @var int
56
+ */
57
+ protected $type;
58
+
59
+ /**
60
+ * The tag of the entry (if known).
61
+ *
62
+ * @var PelTag
63
+ */
64
+ protected $tag;
65
+
66
+ /**
67
+ * Get the IFD type associated with the exception.
68
+ *
69
+ * @return int one of {@link PelIfd::IFD0}, {@link PelIfd::IFD1},
70
+ * {@link PelIfd::EXIF}, {@link PelIfd::GPS}, or {@link
71
+ * PelIfd::INTEROPERABILITY}. If no type is set, null is returned.
72
+ */
73
+ public function getIfdType()
74
+ {
75
+ return $this->type;
76
+ }
77
+
78
+ /**
79
+ * Get the tag associated with the exception.
80
+ *
81
+ * @return PelTag the tag. If no tag is set, null is returned.
82
+ */
83
+ public function getTag()
84
+ {
85
+ return $this->tag;
86
+ }
87
+ }
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelEntryLong.php ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * PEL: PHP Exif Library.
5
+ * A library with support for reading and
6
+ * writing all Exif headers in JPEG and TIFF images using PHP.
7
+ *
8
+ * Copyright (C) 2004, 2005, 2006 Martin Geisler.
9
+ *
10
+ * This program is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program in the file COPYING; if not, write to the
22
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23
+ * Boston, MA 02110-1301 USA
24
+ */
25
+ namespace lsolesen\pel;
26
+
27
+ /**
28
+ * Classes used to hold longs, both signed and unsigned.
29
+ *
30
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
31
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
32
+ * License (GPL)
33
+ * @package PEL
34
+ */
35
+
36
+ /**
37
+ * Class for holding unsigned longs.
38
+ *
39
+ * This class can hold longs, either just a single long or an array of
40
+ * longs. The class will be used to manipulate any of the Exif tags
41
+ * which can have format {@link PelFormat::LONG} like in this
42
+ * example:
43
+ * <code>
44
+ * $w = $ifd->getEntry(PelTag::EXIF_IMAGE_WIDTH);
45
+ * $w->setValue($w->getValue() / 2);
46
+ * $h = $ifd->getEntry(PelTag::EXIF_IMAGE_HEIGHT);
47
+ * $h->setValue($h->getValue() / 2);
48
+ * </code>
49
+ * Here the width and height is updated to 50% of their original
50
+ * values.
51
+ *
52
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
53
+ * @package PEL
54
+ */
55
+ class PelEntryLong extends PelEntryNumber
56
+ {
57
+
58
+ /**
59
+ * Make a new entry that can hold an unsigned long.
60
+ *
61
+ * The method accept its arguments in two forms: several integer
62
+ * arguments or a single array argument. The {@link getValue}
63
+ * method will always return an array except for when a single
64
+ * integer argument is given here, or when an array with just a
65
+ * single integer is given.
66
+ *
67
+ * This means that one can conveniently use objects like this:
68
+ * <code>
69
+ * $a = new PelEntryLong(PelTag::EXIF_IMAGE_WIDTH, 123456);
70
+ * $b = $a->getValue() - 654321;
71
+ * </code>
72
+ * where the call to {@link getValue} will return an integer instead
73
+ * of an array with one integer element, which would then have to be
74
+ * extracted.
75
+ *
76
+ * @param
77
+ * PelTag the tag which this entry represents. This
78
+ * should be one of the constants defined in {@link PelTag},
79
+ * e.g., {@link PelTag::IMAGE_WIDTH}, or any other tag which can
80
+ * have format {@link PelFormat::LONG}.
81
+ * @param int $value...
82
+ * the long(s) that this entry will
83
+ * represent or an array of longs. The argument passed must obey
84
+ * the same rules as the argument to {@link setValue}, namely that
85
+ * it should be within range of an unsigned long (32 bit), that is
86
+ * between 0 and 4294967295 (inclusive). If not, then a {@link
87
+ * PelExifOverflowException} will be thrown.
88
+ */
89
+ public function __construct($tag, $value = null)
90
+ {
91
+ $this->tag = $tag;
92
+ $this->min = 0;
93
+ $this->max = 4294967295;
94
+ $this->format = PelFormat::LONG;
95
+
96
+ $value = func_get_args();
97
+ array_shift($value);
98
+ $this->setValueArray($value);
99
+ }
100
+
101
+ /**
102
+ * Convert a number into bytes.
103
+ *
104
+ * @param
105
+ * int the number that should be converted.
106
+ * @param
107
+ * PelByteOrder one of {@link PelConvert::LITTLE_ENDIAN} and
108
+ * {@link PelConvert::BIG_ENDIAN}, specifying the target byte order.
109
+ * @return string bytes representing the number given.
110
+ */
111
+ public function numberToBytes($number, $order)
112
+ {
113
+ return PelConvert::longToBytes($number, $order);
114
+ }
115
+ }
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelEntryNumber.php ADDED
@@ -0,0 +1,285 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * PEL: PHP Exif Library.
5
+ * A library with support for reading and
6
+ * writing all Exif headers in JPEG and TIFF images using PHP.
7
+ *
8
+ * Copyright (C) 2004, 2005, 2006 Martin Geisler.
9
+ *
10
+ * This program is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program in the file COPYING; if not, write to the
22
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23
+ * Boston, MA 02110-1301 USA
24
+ */
25
+ namespace lsolesen\pel;
26
+
27
+ /**
28
+ * Abstract class for numbers.
29
+ *
30
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
31
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
32
+ * License (GPL)
33
+ * @package PEL
34
+ */
35
+
36
+ /**
37
+ * Class for holding numbers.
38
+ *
39
+ * This class can hold numbers, with range checks.
40
+ *
41
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
42
+ * @package PEL
43
+ */
44
+ abstract class PelEntryNumber extends PelEntry
45
+ {
46
+
47
+ /**
48
+ * The value held by this entry.
49
+ *
50
+ * @var array
51
+ */
52
+ protected $value = array();
53
+
54
+ /**
55
+ * The minimum allowed value.
56
+ *
57
+ * Any attempt to change the value below this variable will result
58
+ * in a {@link PelOverflowException} being thrown.
59
+ *
60
+ * @var int
61
+ */
62
+ protected $min;
63
+
64
+ /**
65
+ * The maximum allowed value.
66
+ *
67
+ * Any attempt to change the value over this variable will result in
68
+ * a {@link PelOverflowException} being thrown.
69
+ *
70
+ * @var int
71
+ */
72
+ protected $max;
73
+
74
+ /**
75
+ * The dimension of the number held.
76
+ *
77
+ * Normal numbers have a dimension of one, pairs have a dimension of
78
+ * two, etc.
79
+ *
80
+ * @var int
81
+ */
82
+ protected $dimension = 1;
83
+
84
+ /**
85
+ * Change the value.
86
+ *
87
+ * This method can change both the number of components and the
88
+ * value of the components. Range checks will be made on the new
89
+ * value, and a {@link PelOverflowException} will be thrown if the
90
+ * value is found to be outside the legal range.
91
+ *
92
+ * The method accept several number arguments. The {@link getValue}
93
+ * method will always return an array except for when a single
94
+ * number is given here.
95
+ *
96
+ * @param int|array $value...
97
+ * the new value(s). This can be zero or
98
+ * more numbers, that is, either integers or arrays. The input will
99
+ * be checked to ensure that the numbers are within the valid range.
100
+ * If not, then a {@link PelOverflowException} will be thrown.
101
+ *
102
+ * @see getValue
103
+ */
104
+ public function setValue($value)
105
+ {
106
+ $value = func_get_args();
107
+ $this->setValueArray($value);
108
+ }
109
+
110
+ /**
111
+ * Change the value.
112
+ *
113
+ * This method can change both the number of components and the
114
+ * value of the components. Range checks will be made on the new
115
+ * value, and a {@link PelOverflowException} will be thrown if the
116
+ * value is found to be outside the legal range.
117
+ *
118
+ * @param
119
+ * array the new values. The array must contain the new
120
+ * numbers.
121
+ *
122
+ * @see getValue
123
+ */
124
+ public function setValueArray($value)
125
+ {
126
+ foreach ($value as $v) {
127
+ $this->validateNumber($v);
128
+ }
129
+
130
+ $this->components = count($value);
131
+ $this->value = $value;
132
+ }
133
+
134
+ /**
135
+ * Return the numeric value held.
136
+ *
137
+ * @return int|array this will either be a single number if there is
138
+ * only one component, or an array of numbers otherwise.
139
+ */
140
+ public function getValue()
141
+ {
142
+ if ($this->components == 1) {
143
+ return $this->value[0];
144
+ } else {
145
+ return $this->value;
146
+ }
147
+ }
148
+
149
+ /**
150
+ * Validate a number.
151
+ *
152
+ * This method will check that the number given is within the range
153
+ * given my {@link getMin()} and {@link getMax()}, inclusive. If
154
+ * not, then a {@link PelOverflowException} is thrown.
155
+ *
156
+ * @param
157
+ * int|array the number in question.
158
+ *
159
+ * @return void nothing, but will throw a {@link
160
+ * PelOverflowException} if the number is found to be outside the
161
+ * legal range and {@link Pel::$strict} is true.
162
+ */
163
+ public function validateNumber($n)
164
+ {
165
+ if ($this->dimension == 1) {
166
+ if ($n < $this->min || $n > $this->max) {
167
+ Pel::maybeThrow(new PelOverflowException($n, $this->min, $this->max));
168
+ }
169
+ } else {
170
+ for ($i = 0; $i < $this->dimension; $i ++) {
171
+ if ($n[$i] < $this->min || $n[$i] > $this->max) {
172
+ Pel::maybeThrow(new PelOverflowException($n[$i], $this->min, $this->max));
173
+ }
174
+ }
175
+ }
176
+ }
177
+
178
+ /**
179
+ * Add a number.
180
+ *
181
+ * This appends a number to the numbers already held by this entry,
182
+ * thereby increasing the number of components by one.
183
+ *
184
+ * @param
185
+ * int|array the number to be added.
186
+ */
187
+ public function addNumber($n)
188
+ {
189
+ $this->validateNumber($n);
190
+ $this->value[] = $n;
191
+ $this->components ++;
192
+ }
193
+
194
+ /**
195
+ * Convert a number into bytes.
196
+ *
197
+ * The concrete subclasses will have to implement this method so
198
+ * that the numbers represented can be turned into bytes.
199
+ *
200
+ * The method will be called once for each number held by the entry.
201
+ *
202
+ * @param
203
+ * int the number that should be converted.
204
+ *
205
+ * @param
206
+ * PelByteOrder one of {@link PelConvert::LITTLE_ENDIAN} and
207
+ * {@link PelConvert::BIG_ENDIAN}, specifying the target byte order.
208
+ *
209
+ * @return string bytes representing the number given.
210
+ */
211
+ abstract public function numberToBytes($number, $order);
212
+
213
+ /**
214
+ * Turn this entry into bytes.
215
+ *
216
+ * @param
217
+ * PelByteOrder the desired byte order, which must be either
218
+ * {@link PelConvert::LITTLE_ENDIAN} or {@link
219
+ * PelConvert::BIG_ENDIAN}.
220
+ *
221
+ * @return string bytes representing this entry.
222
+ */
223
+ public function getBytes($o)
224
+ {
225
+ $bytes = '';
226
+ for ($i = 0; $i < $this->components; $i ++) {
227
+ if ($this->dimension == 1) {
228
+ $bytes .= $this->numberToBytes($this->value[$i], $o);
229
+ } else {
230
+ for ($j = 0; $j < $this->dimension; $j ++) {
231
+ $bytes .= $this->numberToBytes($this->value[$i][$j], $o);
232
+ }
233
+ }
234
+ }
235
+ return $bytes;
236
+ }
237
+
238
+ /**
239
+ * Format a number.
240
+ *
241
+ * This method is called by {@link getText} to format numbers.
242
+ * Subclasses should override this method if they need more
243
+ * sophisticated behavior than the default, which is to just return
244
+ * the number as is.
245
+ *
246
+ * @param
247
+ * int the number which will be formatted.
248
+ *
249
+ * @param
250
+ * boolean it could be that there is both a verbose and a
251
+ * brief formatting available, and this argument controls that.
252
+ *
253
+ * @return string the number formatted as a string suitable for
254
+ * display.
255
+ */
256
+ public function formatNumber($number, $brief = false)
257
+ {
258
+ return $number;
259
+ }
260
+
261
+ /**
262
+ * Get the numeric value of this entry as text.
263
+ *
264
+ * @param
265
+ * boolean use brief output? The numbers will be separated
266
+ * by a single space if brief output is requested, otherwise a space
267
+ * and a comma will be used.
268
+ *
269
+ * @return string the numbers(s) held by this entry.
270
+ */
271
+ public function getText($brief = false)
272
+ {
273
+ if ($this->components == 0) {
274
+ return '';
275
+ }
276
+
277
+ $str = $this->formatNumber($this->value[0]);
278
+ for ($i = 1; $i < $this->components; $i ++) {
279
+ $str .= ($brief ? ' ' : ', ');
280
+ $str .= $this->formatNumber($this->value[$i]);
281
+ }
282
+
283
+ return $str;
284
+ }
285
+ }
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelEntryRational.php ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * PEL: PHP Exif Library.
5
+ * A library with support for reading and
6
+ * writing all Exif headers in JPEG and TIFF images using PHP.
7
+ *
8
+ * Copyright (C) 2004, 2005, 2006 Martin Geisler.
9
+ *
10
+ * This program is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program in the file COPYING; if not, write to the
22
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23
+ * Boston, MA 02110-1301 USA
24
+ */
25
+ namespace lsolesen\pel;
26
+
27
+ /**
28
+ * Classes used to manipulate rational numbers.
29
+ *
30
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
31
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
32
+ * License (GPL)
33
+ * @package PEL
34
+ */
35
+
36
+ /**
37
+ * Class for holding unsigned rational numbers.
38
+ *
39
+ * This class can hold rational numbers, consisting of a numerator and
40
+ * denominator both of which are of type unsigned long. Each rational
41
+ * is represented by an array with just two entries: the numerator and
42
+ * the denominator, in that order.
43
+ *
44
+ * The class can hold either just a single rational or an array of
45
+ * rationals. The class will be used to manipulate any of the Exif
46
+ * tags which can have format {@link PelFormat::RATIONAL} like in this
47
+ * example:
48
+ *
49
+ * <code>
50
+ * $resolution = $ifd->getEntry(PelTag::X_RESOLUTION);
51
+ * $resolution->setValue(array(1, 300));
52
+ * </code>
53
+ *
54
+ * Here the x-resolution is adjusted to 1/300, which will be 300 DPI,
55
+ * unless the {@link PelTag::RESOLUTION_UNIT resolution unit} is set
56
+ * to something different than 2 which means inches.
57
+ *
58
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
59
+ * @package PEL
60
+ */
61
+ class PelEntryRational extends PelEntryLong
62
+ {
63
+
64
+ /**
65
+ * Make a new entry that can hold an unsigned rational.
66
+ *
67
+ * @param
68
+ * PelTag the tag which this entry represents. This should
69
+ * be one of the constants defined in {@link PelTag}, e.g., {@link
70
+ * PelTag::X_RESOLUTION}, or any other tag which can have format
71
+ * {@link PelFormat::RATIONAL}.
72
+ *
73
+ * @param array $value...
74
+ * the rational(s) that this entry will
75
+ * represent. The arguments passed must obey the same rules as the
76
+ * argument to {@link setValue}, namely that each argument should be
77
+ * an array with two entries, both of which must be within range of
78
+ * an unsigned long (32 bit), that is between 0 and 4294967295
79
+ * (inclusive). If not, then a {@link PelOverflowException} will be
80
+ * thrown.
81
+ */
82
+ public function __construct($tag, $value = null)
83
+ {
84
+ $this->tag = $tag;
85
+ $this->format = PelFormat::RATIONAL;
86
+ $this->dimension = 2;
87
+ $this->min = 0;
88
+ $this->max = 4294967295;
89
+
90
+ $value = func_get_args();
91
+ array_shift($value);
92
+ $this->setValueArray($value);
93
+ }
94
+
95
+ /**
96
+ * Format a rational number.
97
+ *
98
+ * The rational will be returned as a string with a slash '/'
99
+ * between the numerator and denominator.
100
+ *
101
+ * @param
102
+ * array the rational which will be formatted.
103
+ *
104
+ * @param
105
+ * boolean not used.
106
+ *
107
+ * @return string the rational formatted as a string suitable for
108
+ * display.
109
+ */
110
+ public function formatNumber($number, $brief = false)
111
+ {
112
+ return $number[0] . '/' . $number[1];
113
+ }
114
+
115
+ /**
116
+ * Get the value of an entry as text.
117
+ *
118
+ * The value will be returned in a format suitable for presentation,
119
+ * e.g., rationals will be returned as 'x/y', ASCII strings will be
120
+ * returned as themselves etc.
121
+ *
122
+ * @param
123
+ * boolean some values can be returned in a long or more
124
+ * brief form, and this parameter controls that.
125
+ *
126
+ * @return string the value as text.
127
+ */
128
+ public function getText($brief = false)
129
+ {
130
+ if (isset($this->value[0])) {
131
+ $v = $this->value[0];
132
+ }
133
+
134
+ switch ($this->tag) {
135
+ case PelTag::FNUMBER:
136
+ // CC (e->components, 1, v);
137
+ return Pel::fmt('f/%.01f', $v[0] / $v[1]);
138
+
139
+ case PelTag::APERTURE_VALUE:
140
+ // CC (e->components, 1, v);
141
+ // if (!v_rat.denominator) return (NULL);
142
+ return Pel::fmt('f/%.01f', pow(2, $v[0] / $v[1] / 2));
143
+
144
+ case PelTag::FOCAL_LENGTH:
145
+ // CC (e->components, 1, v);
146
+ // if (!v_rat.denominator) return (NULL);
147
+ return Pel::fmt('%.1f mm', $v[0] / $v[1]);
148
+
149
+ case PelTag::SUBJECT_DISTANCE:
150
+ // CC (e->components, 1, v);
151
+ // if (!v_rat.denominator) return (NULL);
152
+ return Pel::fmt('%.1f m', $v[0] / $v[1]);
153
+
154
+ case PelTag::EXPOSURE_TIME:
155
+ // CC (e->components, 1, v);
156
+ // if (!v_rat.denominator) return (NULL);
157
+ if ($v[0] / $v[1] < 1) {
158
+ return Pel::fmt('1/%d sec.', $v[1] / $v[0]);
159
+ } else {
160
+ return Pel::fmt('%d sec.', $v[0] / $v[1]);
161
+ }
162
+ break;
163
+ case PelTag::GPS_LATITUDE:
164
+ case PelTag::GPS_LONGITUDE:
165
+ $degrees = $this->value[0][0] / $this->value[0][1];
166
+ $minutes = $this->value[1][0] / $this->value[1][1];
167
+ $seconds = $this->value[2][0] / $this->value[2][1];
168
+
169
+ return sprintf('%s° %s\' %s" (%.2f°)', $degrees, $minutes, $seconds, $degrees + $minutes / 60 + $seconds / 3600);
170
+
171
+ default:
172
+ return parent::getText($brief);
173
+ }
174
+ }
175
+ }
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelEntrySByte.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * PEL: PHP Exif Library.
5
+ * A library with support for reading and
6
+ * writing all Exif headers in JPEG and TIFF images using PHP.
7
+ *
8
+ * Copyright (C) 2004, 2005, 2006, 2007 Martin Geisler.
9
+ *
10
+ * This program is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program in the file COPYING; if not, write to the
22
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23
+ * Boston, MA 02110-1301 USA
24
+ */
25
+ namespace lsolesen\pel;
26
+
27
+ /**
28
+ * Classes used to hold bytes, both signed and unsigned.
29
+ * The {@link
30
+ * PelEntryWindowsString} class is used to manipulate strings in the
31
+ * format Windows XP needs.
32
+ *
33
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
34
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
35
+ * License (GPL)
36
+ * @package PEL
37
+ */
38
+
39
+ /**
40
+ * Class for holding signed bytes.
41
+ *
42
+ * This class can hold bytes, either just a single byte or an array of
43
+ * bytes. The class will be used to manipulate any of the Exif tags
44
+ * which has format {@link PelFormat::BYTE}.
45
+ *
46
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
47
+ * @package PEL
48
+ */
49
+ class PelEntrySByte extends PelEntryNumber
50
+ {
51
+
52
+ /**
53
+ * Make a new entry that can hold a signed byte.
54
+ *
55
+ * The method accept several integer arguments. The {@link getValue}
56
+ * method will always return an array except for when a single
57
+ * integer argument is given here.
58
+ *
59
+ * @param PelTag $tag
60
+ * the tag which this entry represents. This
61
+ * should be one of the constants defined in {@link PelTag}
62
+ * which has format {@link PelFormat::BYTE}.
63
+ *
64
+ * @param int $value...
65
+ * the byte(s) that this entry will represent.
66
+ * The argument passed must obey the same rules as the argument to
67
+ * {@link setValue}, namely that it should be within range of a
68
+ * signed byte, that is between -128 and 127 (inclusive). If not,
69
+ * then a {@link PelOverflowException} will be thrown.
70
+ */
71
+ public function __construct($tag, $value = null)
72
+ {
73
+ $this->tag = $tag;
74
+ $this->min = - 128;
75
+ $this->max = 127;
76
+ $this->format = PelFormat::SBYTE;
77
+
78
+ $value = func_get_args();
79
+ array_shift($value);
80
+ $this->setValueArray($value);
81
+ }
82
+
83
+ /**
84
+ * Convert a number into bytes.
85
+ *
86
+ * @param int $number
87
+ * the number that should be converted.
88
+ *
89
+ * @param PelByteOrder $order
90
+ * one of {@link PelConvert::LITTLE_ENDIAN} and
91
+ * {@link PelConvert::BIG_ENDIAN}, specifying the target byte order.
92
+ *
93
+ * @return string bytes representing the number given.
94
+ */
95
+ public function numberToBytes($number, $order)
96
+ {
97
+ return chr($number);
98
+ }
99
+ }
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelEntrySLong.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * PEL: PHP Exif Library.
5
+ * A library with support for reading and
6
+ * writing all Exif headers in JPEG and TIFF images using PHP.
7
+ *
8
+ * Copyright (C) 2004, 2005, 2006 Martin Geisler.
9
+ *
10
+ * This program is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program in the file COPYING; if not, write to the
22
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23
+ * Boston, MA 02110-1301 USA
24
+ */
25
+ namespace lsolesen\pel;
26
+
27
+ /**
28
+ * Classes used to hold longs, both signed and unsigned.
29
+ *
30
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
31
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
32
+ * License (GPL)
33
+ * @package PEL
34
+ */
35
+
36
+ /**
37
+ * Class for holding signed longs.
38
+ *
39
+ * This class can hold longs, either just a single long or an array of
40
+ * longs. The class will be used to manipulate any of the Exif tags
41
+ * which can have format {@link PelFormat::SLONG}.
42
+ *
43
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
44
+ * @package PEL
45
+ */
46
+ class PelEntrySLong extends PelEntryNumber
47
+ {
48
+
49
+ /**
50
+ * Make a new entry that can hold a signed long.
51
+ *
52
+ * The method accept its arguments in two forms: several integer
53
+ * arguments or a single array argument. The {@link getValue}
54
+ * method will always return an array except for when a single
55
+ * integer argument is given here, or when an array with just a
56
+ * single integer is given.
57
+ *
58
+ * @param
59
+ * PelTag the tag which this entry represents. This
60
+ * should be one of the constants defined in {@link PelTag}
61
+ * which have format {@link PelFormat::SLONG}.
62
+ *
63
+ * @param int $value...
64
+ * the long(s) that this entry will represent
65
+ * or an array of longs. The argument passed must obey the same
66
+ * rules as the argument to {@link setValue}, namely that it should
67
+ * be within range of a signed long (32 bit), that is between
68
+ * -2147483648 and 2147483647 (inclusive). If not, then a {@link
69
+ * PelOverflowException} will be thrown.
70
+ */
71
+ public function __construct($tag, $value = null)
72
+ {
73
+ $this->tag = $tag;
74
+ $this->min = - 2147483648;
75
+ $this->max = 2147483647;
76
+ $this->format = PelFormat::SLONG;
77
+
78
+ $value = func_get_args();
79
+ array_shift($value);
80
+ $this->setValueArray($value);
81
+ }
82
+
83
+ /**
84
+ * Convert a number into bytes.
85
+ *
86
+ * @param
87
+ * int the number that should be converted.
88
+ *
89
+ * @param
90
+ * PelByteOrder one of {@link PelConvert::LITTLE_ENDIAN} and
91
+ * {@link PelConvert::BIG_ENDIAN}, specifying the target byte order.
92
+ *
93
+ * @return string bytes representing the number given.
94
+ */
95
+ public function numberToBytes($number, $order)
96
+ {
97
+ return PelConvert::sLongToBytes($number, $order);
98
+ }
99
+ }
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelEntrySRational.php ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * PEL: PHP Exif Library.
5
+ * A library with support for reading and
6
+ * writing all Exif headers in JPEG and TIFF images using PHP.
7
+ *
8
+ * Copyright (C) 2004, 2005, 2006 Martin Geisler.
9
+ *
10
+ * This program is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program in the file COPYING; if not, write to the
22
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23
+ * Boston, MA 02110-1301 USA
24
+ */
25
+ namespace lsolesen\pel;
26
+
27
+ /**
28
+ * Classes used to manipulate rational numbers.
29
+ *
30
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
31
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
32
+ * License (GPL)
33
+ * @package PEL
34
+ */
35
+
36
+ /**
37
+ * Class for holding signed rational numbers.
38
+ *
39
+ * This class can hold rational numbers, consisting of a numerator and
40
+ * denominator both of which are of type unsigned long. Each rational
41
+ * is represented by an array with just two entries: the numerator and
42
+ * the denominator, in that order.
43
+ *
44
+ * The class can hold either just a single rational or an array of
45
+ * rationals. The class will be used to manipulate any of the Exif
46
+ * tags which can have format {@link PelFormat::SRATIONAL}.
47
+ *
48
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
49
+ * @package PEL
50
+ */
51
+ class PelEntrySRational extends PelEntrySLong
52
+ {
53
+
54
+ /**
55
+ * Make a new entry that can hold a signed rational.
56
+ *
57
+ * @param
58
+ * PelTag the tag which this entry represents. This should
59
+ * be one of the constants defined in {@link PelTag}, e.g., {@link
60
+ * PelTag::SHUTTER_SPEED_VALUE}, or any other tag which can have
61
+ * format {@link PelFormat::SRATIONAL}.
62
+ *
63
+ * @param array $value...
64
+ * the rational(s) that this entry will
65
+ * represent. The arguments passed must obey the same rules as the
66
+ * argument to {@link setValue}, namely that each argument should be
67
+ * an array with two entries, both of which must be within range of
68
+ * a signed long (32 bit), that is between -2147483648 and
69
+ * 2147483647 (inclusive). If not, then a {@link
70
+ * PelOverflowException} will be thrown.
71
+ */
72
+ public function __construct($tag, $value = null)
73
+ {
74
+ $this->tag = $tag;
75
+ $this->format = PelFormat::SRATIONAL;
76
+ $this->dimension = 2;
77
+ $this->min = - 2147483648;
78
+ $this->max = 2147483647;
79
+
80
+ $value = func_get_args();
81
+ array_shift($value);
82
+ $this->setValueArray($value);
83
+ }
84
+
85
+ /**
86
+ * Format a rational number.
87
+ *
88
+ * The rational will be returned as a string with a slash '/'
89
+ * between the numerator and denominator. Care is taken to display
90
+ * '-1/2' instead of the ugly but mathematically equivalent '1/-2'.
91
+ *
92
+ * @param
93
+ * array the rational which will be formatted.
94
+ *
95
+ * @param
96
+ * boolean not used.
97
+ *
98
+ * @return string the rational formatted as a string suitable for
99
+ * display.
100
+ */
101
+ public function formatNumber($number, $brief = false)
102
+ {
103
+ if ($number[1] < 0) {
104
+ /* Turn output like 1/-2 into -1/2. */
105
+ return (- $number[0]) . '/' . (- $number[1]);
106
+ } else {
107
+ return $number[0] . '/' . $number[1];
108
+ }
109
+ }
110
+
111
+ /**
112
+ * Get the value of an entry as text.
113
+ *
114
+ * The value will be returned in a format suitable for presentation,
115
+ * e.g., rationals will be returned as 'x/y', ASCII strings will be
116
+ * returned as themselves etc.
117
+ *
118
+ * @param
119
+ * boolean some values can be returned in a long or more
120
+ * brief form, and this parameter controls that.
121
+ *
122
+ * @return string the value as text.
123
+ */
124
+ public function getText($brief = false)
125
+ {
126
+ if (isset($this->value[0])) {
127
+ $v = $this->value[0];
128
+ }
129
+
130
+ switch ($this->tag) {
131
+ case PelTag::SHUTTER_SPEED_VALUE:
132
+ // CC (e->components, 1, v);
133
+ // if (!v_srat.denominator) return (NULL);
134
+ return Pel::fmt('%.0f/%.0f sec. (APEX: %d)', $v[0], $v[1], pow(sqrt(2), $v[0] / $v[1]));
135
+
136
+ case PelTag::BRIGHTNESS_VALUE:
137
+ // CC (e->components, 1, v);
138
+ //
139
+ // TODO: figure out the APEX thing, or remove this so that it is
140
+ // handled by the default clause at the bottom.
141
+ return sprintf('%d/%d', $v[0], $v[1]);
142
+ // FIXME: How do I calculate the APEX value?
143
+
144
+ case PelTag::EXPOSURE_BIAS_VALUE:
145
+ // CC (e->components, 1, v);
146
+ // if (!v_srat.denominator) return (NULL);
147
+ return sprintf('%s%.01f', $v[0] * $v[1] > 0 ? '+' : '', $v[0] / $v[1]);
148
+
149
+ default:
150
+ return parent::getText($brief);
151
+ }
152
+ }
153
+ }
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelEntrySShort.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * PEL: PHP Exif Library.
5
+ * A library with support for reading and
6
+ * writing all Exif headers in JPEG and TIFF images using PHP.
7
+ *
8
+ * Copyright (C) 2004, 2005, 2006 Martin Geisler.
9
+ *
10
+ * This program is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program in the file COPYING; if not, write to the
22
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23
+ * Boston, MA 02110-1301 USA
24
+ */
25
+ namespace lsolesen\pel;
26
+
27
+ /**
28
+ * Classes used to hold shorts, both signed and unsigned.
29
+ *
30
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
31
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
32
+ * License (GPL)
33
+ * @package PEL
34
+ */
35
+
36
+ /**
37
+ * Class for holding signed shorts.
38
+ *
39
+ * This class can hold shorts, either just a single short or an array
40
+ * of shorts. The class will be used to manipulate any of the Exif
41
+ * tags which has format {@link PelFormat::SSHORT}.
42
+ *
43
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
44
+ * @package PEL
45
+ */
46
+ class PelEntrySShort extends PelEntryNumber
47
+ {
48
+
49
+ /**
50
+ * Make a new entry that can hold a signed short.
51
+ *
52
+ * The method accept several integer arguments. The {@link
53
+ * getValue} method will always return an array except for when a
54
+ * single integer argument is given here.
55
+ *
56
+ * @param PelTag $tag
57
+ * the tag which this entry represents. This
58
+ * should be one of the constants defined in {@link PelTag}
59
+ * which has format {@link PelFormat::SSHORT}.
60
+ *
61
+ * @param int $value...
62
+ * the signed short(s) that this entry will
63
+ * represent. The argument passed must obey the same rules as the
64
+ * argument to {@link setValue}, namely that it should be within
65
+ * range of a signed short, that is between -32768 to 32767
66
+ * (inclusive). If not, then a {@link PelOverFlowException} will be
67
+ * thrown.
68
+ */
69
+ public function __construct($tag, $value = null)
70
+ {
71
+ $this->tag = $tag;
72
+ $this->min = - 32768;
73
+ $this->max = 32767;
74
+ $this->format = PelFormat::SSHORT;
75
+
76
+ $value = func_get_args();
77
+ array_shift($value);
78
+ $this->setValueArray($value);
79
+ }
80
+
81
+ /**
82
+ * Convert a number into bytes.
83
+ *
84
+ * @param int $number
85
+ * the number that should be converted.
86
+ *
87
+ * @param PelByteOrder $order
88
+ * one of {@link PelConvert::LITTLE_ENDIAN} and
89
+ * {@link PelConvert::BIG_ENDIAN}, specifying the target byte order.
90
+ *
91
+ * @return string bytes representing the number given.
92
+ */
93
+ public function numberToBytes($number, $order)
94
+ {
95
+ return PelConvert::sShortToBytes($number, $order);
96
+ }
97
+ }
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelEntryShort.php ADDED
@@ -0,0 +1,534 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * PEL: PHP Exif Library.
5
+ * A library with support for reading and
6
+ * writing all Exif headers in JPEG and TIFF images using PHP.
7
+ *
8
+ * Copyright (C) 2004, 2005, 2006 Martin Geisler.
9
+ *
10
+ * This program is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program in the file COPYING; if not, write to the
22
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23
+ * Boston, MA 02110-1301 USA
24
+ */
25
+ namespace lsolesen\pel;
26
+
27
+ /**
28
+ * Classes used to hold shorts, both signed and unsigned.
29
+ *
30
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
31
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
32
+ * License (GPL)
33
+ * @package PEL
34
+ */
35
+
36
+ /**
37
+ * Class for holding signed shorts.
38
+ *
39
+ * This class can hold shorts, either just a single short or an array
40
+ * of shorts. The class will be used to manipulate any of the Exif
41
+ * tags which has format {@link PelFormat::SHORT} like in this
42
+ * example:
43
+ *
44
+ * <code>
45
+ * $w = $ifd->getEntry(PelTag::EXIF_IMAGE_WIDTH);
46
+ * $w->setValue($w->getValue() / 2);
47
+ * $h = $ifd->getEntry(PelTag::EXIF_IMAGE_HEIGHT);
48
+ * $h->setValue($h->getValue() / 2);
49
+ * </code>
50
+ *
51
+ * Here the width and height is updated to 50% of their original
52
+ * values.
53
+ *
54
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
55
+ * @package PEL
56
+ */
57
+ class PelEntryShort extends PelEntryNumber
58
+ {
59
+
60
+ /**
61
+ * Make a new entry that can hold an unsigned short.
62
+ *
63
+ * The method accept several integer arguments. The {@link
64
+ * getValue} method will always return an array except for when a
65
+ * single integer argument is given here.
66
+ *
67
+ * This means that one can conveniently use objects like this:
68
+ * <code>
69
+ * $a = new PelEntryShort(PelTag::EXIF_IMAGE_HEIGHT, 42);
70
+ * $b = $a->getValue() + 314;
71
+ * </code>
72
+ * where the call to {@link getValue} will return an integer
73
+ * instead of an array with one integer element, which would then
74
+ * have to be extracted.
75
+ *
76
+ * @param PelTag $tag
77
+ * the tag which this entry represents. This should be
78
+ * one of the constants defined in {@link PelTag}, e.g., {@link
79
+ * PelTag::IMAGE_WIDTH}, {@link PelTag::ISO_SPEED_RATINGS},
80
+ * or any other tag with format {@link PelFormat::SHORT}.
81
+ *
82
+ * @param int $value...
83
+ * the short(s) that this entry will
84
+ * represent. The argument passed must obey the same rules as the
85
+ * argument to {@link setValue}, namely that it should be within
86
+ * range of an unsigned short, that is between 0 and 65535
87
+ * (inclusive). If not, then a {@link PelOverFlowException} will be
88
+ * thrown.
89
+ */
90
+ public function __construct($tag, $value = null)
91
+ {
92
+ $this->tag = $tag;
93
+ $this->min = 0;
94
+ $this->max = 65535;
95
+ $this->format = PelFormat::SHORT;
96
+
97
+ $value = func_get_args();
98
+ array_shift($value);
99
+ $this->setValueArray($value);
100
+ }
101
+
102
+ /**
103
+ * Convert a number into bytes.
104
+ *
105
+ * @param int $number
106
+ * the number that should be converted.
107
+ *
108
+ * @param PelByteOrder $order
109
+ * one of {@link PelConvert::LITTLE_ENDIAN} and
110
+ * {@link PelConvert::BIG_ENDIAN}, specifying the target byte order.
111
+ *
112
+ * @return string bytes representing the number given.
113
+ */
114
+ public function numberToBytes($number, $order)
115
+ {
116
+ return PelConvert::shortToBytes($number, $order);
117
+ }
118
+
119
+ /**
120
+ * Get the value of an entry as text.
121
+ *
122
+ * The value will be returned in a format suitable for presentation,
123
+ * e.g., instead of returning '2' for a {@link
124
+ * PelTag::METERING_MODE} tag, 'Center-Weighted Average' is
125
+ * returned.
126
+ *
127
+ * @param
128
+ * boolean some values can be returned in a long or more
129
+ * brief form, and this parameter controls that.
130
+ *
131
+ * @return string the value as text.
132
+ */
133
+ public function getText($brief = false)
134
+ {
135
+ switch ($this->tag) {
136
+ case PelTag::METERING_MODE:
137
+ // CC (e->components, 1, v);
138
+ switch ($this->value[0]) {
139
+ case 0:
140
+ return Pel::tra('Unknown');
141
+ case 1:
142
+ return Pel::tra('Average');
143
+ case 2:
144
+ return Pel::tra('Center-Weighted Average');
145
+ case 3:
146
+ return Pel::tra('Spot');
147
+ case 4:
148
+ return Pel::tra('Multi Spot');
149
+ case 5:
150
+ return Pel::tra('Pattern');
151
+ case 6:
152
+ return Pel::tra('Partial');
153
+ case 255:
154
+ return Pel::tra('Other');
155
+ default:
156
+ return $this->value[0];
157
+ }
158
+ break;
159
+ case PelTag::COMPRESSION:
160
+ // CC (e->components, 1, v);
161
+ switch ($this->value[0]) {
162
+ case 1:
163
+ return Pel::tra('Uncompressed');
164
+ case 6:
165
+ return Pel::tra('JPEG compression');
166
+ default:
167
+ return $this->value[0];
168
+ }
169
+ break;
170
+ case PelTag::PLANAR_CONFIGURATION:
171
+ // CC (e->components, 1, v);
172
+ switch ($this->value[0]) {
173
+ case 1:
174
+ return Pel::tra('chunky format');
175
+ case 2:
176
+ return Pel::tra('planar format');
177
+ default:
178
+ return $this->value[0];
179
+ }
180
+ break;
181
+ case PelTag::SENSING_METHOD:
182
+ // CC (e->components, 1, v);
183
+ switch ($this->value[0]) {
184
+ case 1:
185
+ return Pel::tra('Not defined');
186
+ case 2:
187
+ return Pel::tra('One-chip color area sensor');
188
+ case 3:
189
+ return Pel::tra('Two-chip color area sensor');
190
+ case 4:
191
+ return Pel::tra('Three-chip color area sensor');
192
+ case 5:
193
+ return Pel::tra('Color sequential area sensor');
194
+ case 7:
195
+ return Pel::tra('Trilinear sensor');
196
+ case 8:
197
+ return Pel::tra('Color sequential linear sensor');
198
+ default:
199
+ return $this->value[0];
200
+ }
201
+ break;
202
+ case PelTag::LIGHT_SOURCE:
203
+ // CC (e->components, 1, v);
204
+ switch ($this->value[0]) {
205
+ case 0:
206
+ return Pel::tra('Unknown');
207
+ case 1:
208
+ return Pel::tra('Daylight');
209
+ case 2:
210
+ return Pel::tra('Fluorescent');
211
+ case 3:
212
+ return Pel::tra('Tungsten (incandescent light)');
213
+ case 4:
214
+ return Pel::tra('Flash');
215
+ case 9:
216
+ return Pel::tra('Fine weather');
217
+ case 10:
218
+ return Pel::tra('Cloudy weather');
219
+ case 11:
220
+ return Pel::tra('Shade');
221
+ case 12:
222
+ return Pel::tra('Daylight fluorescent');
223
+ case 13:
224
+ return Pel::tra('Day white fluorescent');
225
+ case 14:
226
+ return Pel::tra('Cool white fluorescent');
227
+ case 15:
228
+ return Pel::tra('White fluorescent');
229
+ case 17:
230
+ return Pel::tra('Standard light A');
231
+ case 18:
232
+ return Pel::tra('Standard light B');
233
+ case 19:
234
+ return Pel::tra('Standard light C');
235
+ case 20:
236
+ return Pel::tra('D55');
237
+ case 21:
238
+ return Pel::tra('D65');
239
+ case 22:
240
+ return Pel::tra('D75');
241
+ case 24:
242
+ return Pel::tra('ISO studio tungsten');
243
+ case 255:
244
+ return Pel::tra('Other');
245
+ default:
246
+ return $this->value[0];
247
+ }
248
+ break;
249
+ case PelTag::FOCAL_PLANE_RESOLUTION_UNIT:
250
+ case PelTag::RESOLUTION_UNIT:
251
+ // CC (e->components, 1, v);
252
+ switch ($this->value[0]) {
253
+ case 2:
254
+ return Pel::tra('Inch');
255
+ case 3:
256
+ return Pel::tra('Centimeter');
257
+ default:
258
+ return $this->value[0];
259
+ }
260
+ break;
261
+ case PelTag::EXPOSURE_PROGRAM:
262
+ // CC (e->components, 1, v);
263
+ switch ($this->value[0]) {
264
+ case 0:
265
+ return Pel::tra('Not defined');
266
+ case 1:
267
+ return Pel::tra('Manual');
268
+ case 2:
269
+ return Pel::tra('Normal program');
270
+ case 3:
271
+ return Pel::tra('Aperture priority');
272
+ case 4:
273
+ return Pel::tra('Shutter priority');
274
+ case 5:
275
+ return Pel::tra('Creative program (biased toward depth of field)');
276
+ case 6:
277
+ return Pel::tra('Action program (biased toward fast shutter speed)');
278
+ case 7:
279
+ return Pel::tra('Portrait mode (for closeup photos with the background out of focus');
280
+ case 8:
281
+ return Pel::tra('Landscape mode (for landscape photos with the background in focus');
282
+ default:
283
+ return $this->value[0];
284
+ }
285
+ break;
286
+ case PelTag::ORIENTATION:
287
+ // CC (e->components, 1, v);
288
+ switch ($this->value[0]) {
289
+ case 1:
290
+ return Pel::tra('top - left');
291
+ case 2:
292
+ return Pel::tra('top - right');
293
+ case 3:
294
+ return Pel::tra('bottom - right');
295
+ case 4:
296
+ return Pel::tra('bottom - left');
297
+ case 5:
298
+ return Pel::tra('left - top');
299
+ case 6:
300
+ return Pel::tra('right - top');
301
+ case 7:
302
+ return Pel::tra('right - bottom');
303
+ case 8:
304
+ return Pel::tra('left - bottom');
305
+ default:
306
+ return $this->value[0];
307
+ }
308
+ break;
309
+ case PelTag::YCBCR_POSITIONING:
310
+ // CC (e->components, 1, v);
311
+ switch ($this->value[0]) {
312
+ case 1:
313
+ return Pel::tra('centered');
314
+ case 2:
315
+ return Pel::tra('co-sited');
316
+ default:
317
+ return $this->value[0];
318
+ }
319
+ break;
320
+ case PelTag::YCBCR_SUB_SAMPLING:
321
+ // CC (e->components, 2, v);
322
+ if ($this->value[0] == 2 && $this->value[1] == 1) {
323
+ return 'YCbCr4:2:2';
324
+ }
325
+ if ($this->value[0] == 2 && $this->value[1] == 2) {
326
+ return 'YCbCr4:2:0';
327
+ }
328
+
329
+ return $this->value[0] . ', ' . $this->value[1];
330
+ break;
331
+ case PelTag::PHOTOMETRIC_INTERPRETATION:
332
+ // CC (e->components, 1, v);
333
+ switch ($this->value[0]) {
334
+ case 2:
335
+ return 'RGB';
336
+ case 6:
337
+ return 'YCbCr';
338
+ default:
339
+ return $this->value[0];
340
+ }
341
+ break;
342
+ case PelTag::COLOR_SPACE:
343
+ // CC (e->components, 1, v);
344
+ switch ($this->value[0]) {
345
+ case 1:
346
+ return 'sRGB';
347
+ case 2:
348
+ return 'Adobe RGB';
349
+ case 0xffff:
350
+ return Pel::tra('Uncalibrated');
351
+ default:
352
+ return $this->value[0];
353
+ }
354
+ break;
355
+ case PelTag::FLASH:
356
+ // CC (e->components, 1, v);
357
+ switch ($this->value[0]) {
358
+ case 0x0000:
359
+ return Pel::tra('Flash did not fire.');
360
+ case 0x0001:
361
+ return Pel::tra('Flash fired.');
362
+ case 0x0005:
363
+ return Pel::tra('Strobe return light not detected.');
364
+ case 0x0007:
365
+ return Pel::tra('Strobe return light detected.');
366
+ case 0x0009:
367
+ return Pel::tra('Flash fired, compulsory flash mode.');
368
+ case 0x000d:
369
+ return Pel::tra('Flash fired, compulsory flash mode, return light not detected.');
370
+ case 0x000f:
371
+ return Pel::tra('Flash fired, compulsory flash mode, return light detected.');
372
+ case 0x0010:
373
+ return Pel::tra('Flash did not fire, compulsory flash mode.');
374
+ case 0x0018:
375
+ return Pel::tra('Flash did not fire, auto mode.');
376
+ case 0x0019:
377
+ return Pel::tra('Flash fired, auto mode.');
378
+ case 0x001d:
379
+ return Pel::tra('Flash fired, auto mode, return light not detected.');
380
+ case 0x001f:
381
+ return Pel::tra('Flash fired, auto mode, return light detected.');
382
+ case 0x0020:
383
+ return Pel::tra('No flash function.');
384
+ case 0x0041:
385
+ return Pel::tra('Flash fired, red-eye reduction mode.');
386
+ case 0x0045:
387
+ return Pel::tra('Flash fired, red-eye reduction mode, return light not detected.');
388
+ case 0x0047:
389
+ return Pel::tra('Flash fired, red-eye reduction mode, return light detected.');
390
+ case 0x0049:
391
+ return Pel::tra('Flash fired, compulsory flash mode, red-eye reduction mode.');
392
+ case 0x004d:
393
+ return Pel::tra('Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected.');
394
+ case 0x004f:
395
+ return Pel::tra('Flash fired, compulsory flash mode, red-eye reduction mode, return light detected.');
396
+ case 0x0058:
397
+ return Pel::tra('Flash did not fire, auto mode, red-eye reduction mode.');
398
+ case 0x0059:
399
+ return Pel::tra('Flash fired, auto mode, red-eye reduction mode.');
400
+ case 0x005d:
401
+ return Pel::tra('Flash fired, auto mode, return light not detected, red-eye reduction mode.');
402
+ case 0x005f:
403
+ return Pel::tra('Flash fired, auto mode, return light detected, red-eye reduction mode.');
404
+ default:
405
+ return $this->value[0];
406
+ }
407
+ break;
408
+ case PelTag::CUSTOM_RENDERED:
409
+ // CC (e->components, 1, v);
410
+ switch ($this->value[0]) {
411
+ case 0:
412
+ return Pel::tra('Normal process');
413
+ case 1:
414
+ return Pel::tra('Custom process');
415
+ default:
416
+ return $this->value[0];
417
+ }
418
+ break;
419
+ case PelTag::EXPOSURE_MODE:
420
+ // CC (e->components, 1, v);
421
+ switch ($this->value[0]) {
422
+ case 0:
423
+ return Pel::tra('Auto exposure');
424
+ case 1:
425
+ return Pel::tra('Manual exposure');
426
+ case 2:
427
+ return Pel::tra('Auto bracket');
428
+ default:
429
+ return $this->value[0];
430
+ }
431
+ break;
432
+ case PelTag::WHITE_BALANCE:
433
+ // CC (e->components, 1, v);
434
+ switch ($this->value[0]) {
435
+ case 0:
436
+ return Pel::tra('Auto white balance');
437
+ case 1:
438
+ return Pel::tra('Manual white balance');
439
+ default:
440
+ return $this->value[0];
441
+ }
442
+ break;
443
+ case PelTag::SCENE_CAPTURE_TYPE:
444
+ // CC (e->components, 1, v);
445
+ switch ($this->value[0]) {
446
+ case 0:
447
+ return Pel::tra('Standard');
448
+ case 1:
449
+ return Pel::tra('Landscape');
450
+ case 2:
451
+ return Pel::tra('Portrait');
452
+ case 3:
453
+ return Pel::tra('Night scene');
454
+ default:
455
+ return $this->value[0];
456
+ }
457
+ break;
458
+ case PelTag::GAIN_CONTROL:
459
+ // CC (e->components, 1, v);
460
+ switch ($this->value[0]) {
461
+ case 0:
462
+ return Pel::tra('Normal');
463
+ case 1:
464
+ return Pel::tra('Low gain up');
465
+ case 2:
466
+ return Pel::tra('High gain up');
467
+ case 3:
468
+ return Pel::tra('Low gain down');
469
+ case 4:
470
+ return Pel::tra('High gain down');
471
+ default:
472
+ return $this->value[0];
473
+ }
474
+ break;
475
+ case PelTag::SATURATION:
476
+ // CC (e->components, 1, v);
477
+ switch ($this->value[0]) {
478
+ case 0:
479
+ return Pel::tra('Normal');
480
+ case 1:
481
+ return Pel::tra('Low saturation');
482
+ case 2:
483
+ return Pel::tra('High saturation');
484
+ default:
485
+ return $this->value[0];
486
+ }
487
+ break;
488
+ case PelTag::CONTRAST:
489
+ case PelTag::SHARPNESS:
490
+ // CC (e->components, 1, v);
491
+ switch ($this->value[0]) {
492
+ case 0:
493
+ return Pel::tra('Normal');
494
+ case 1:
495
+ return Pel::tra('Soft');
496
+ case 2:
497
+ return Pel::tra('Hard');
498
+ default:
499
+ return $this->value[0];
500
+ }
501
+ break;
502
+ case PelTag::SUBJECT_DISTANCE_RANGE:
503
+ // CC (e->components, 1, v);
504
+ switch ($this->value[0]) {
505
+ case 0:
506
+ return Pel::tra('Unknown');
507
+ case 1:
508
+ return Pel::tra('Macro');
509
+ case 2:
510
+ return Pel::tra('Close view');
511
+ case 3:
512
+ return Pel::tra('Distant view');
513
+ default:
514
+ return $this->value[0];
515
+ }
516
+ break;
517
+ case PelTag::SUBJECT_AREA:
518
+ switch ($this->components) {
519
+ case 2:
520
+ return Pel::fmt('(x,y) = (%d,%d)', $this->value[0], $this->value[1]);
521
+ case 3:
522
+ return Pel::fmt('Within distance %d of (x,y) = (%d,%d)', $this->value[0], $this->value[1], $this->value[2]);
523
+ case 4:
524
+ return Pel::fmt('Within rectangle (width %d, height %d) around (x,y) = (%d,%d)', $this->value[0], $this->value[1], $this->value[2], $this->value[3]);
525
+
526
+ default:
527
+ return Pel::fmt('Unexpected number of components (%d, expected 2, 3, or 4).', $this->components);
528
+ }
529
+ break;
530
+ default:
531
+ return parent::getText($brief);
532
+ }
533
+ }
534
+ }
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelEntryTime.php ADDED
@@ -0,0 +1,352 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * PEL: PHP Exif Library.
5
+ * A library with support for reading and
6
+ * writing all Exif headers in JPEG and TIFF images using PHP.
7
+ *
8
+ * Copyright (C) 2004, 2005, 2006, 2007 Martin Geisler.
9
+ *
10
+ * This program is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program in the file COPYING; if not, write to the
22
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23
+ * Boston, MA 02110-1301 USA
24
+ */
25
+ namespace lsolesen\pel;
26
+
27
+ /**
28
+ * Classes used to hold ASCII strings.
29
+ *
30
+ * The classes defined here are to be used for Exif entries holding
31
+ * ASCII strings, such as {@link PelTag::MAKE}, {@link
32
+ * PelTag::SOFTWARE}, and {@link PelTag::DATE_TIME}. For
33
+ * entries holding normal textual ASCII strings the class {@link
34
+ * PelEntryAscii} should be used, but for entries holding
35
+ * timestamps the class {@link PelEntryTime} would be more
36
+ * convenient instead. Copyright information is handled by the {@link
37
+ * PelEntryCopyright} class.
38
+ *
39
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
40
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
41
+ * License (GPL)
42
+ * @package PEL
43
+ */
44
+
45
+ /**
46
+ * Class for holding a date and time.
47
+ *
48
+ * This class can hold a timestamp, and it will be used as
49
+ * in this example where the time is advanced by one week:
50
+ * <code>
51
+ * $entry = $ifd->getEntry(PelTag::DATE_TIME_ORIGINAL);
52
+ * $time = $entry->getValue();
53
+ * print('The image was taken on the ' . date('jS', $time));
54
+ * $entry->setValue($time + 7 * 24 * 3600);
55
+ * </code>
56
+ *
57
+ * The example used a standard UNIX timestamp, which is the default
58
+ * for this class.
59
+ *
60
+ * But the Exif format defines dates outside the range of a UNIX
61
+ * timestamp (about 1970 to 2038) and so you can also get access to
62
+ * the timestamp in two other formats: a simple string or a Julian Day
63
+ * Count. Please see the Calendar extension in the PHP Manual for more
64
+ * information about the Julian Day Count.
65
+ *
66
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
67
+ * @package PEL
68
+ */
69
+ class PelEntryTime extends PelEntryAscii
70
+ {
71
+
72
+ /**
73
+ * Constant denoting a UNIX timestamp.
74
+ */
75
+ const UNIX_TIMESTAMP = 1;
76
+
77
+ /**
78
+ * Constant denoting a Exif string.
79
+ */
80
+ const EXIF_STRING = 2;
81
+
82
+ /**
83
+ * Constant denoting a Julian Day Count.
84
+ */
85
+ const JULIAN_DAY_COUNT = 3;
86
+
87
+ /**
88
+ * The Julian Day Count of the timestamp held by this entry.
89
+ *
90
+ * This is an integer counting the number of whole days since
91
+ * January 1st, 4713 B.C. The fractional part of the timestamp held
92
+ * by this entry is stored in {@link $seconds}.
93
+ *
94
+ * @var int
95
+ */
96
+ private $day_count;
97
+
98
+ /**
99
+ * The number of seconds into the day of the timestamp held by this
100
+ * entry.
101
+ *
102
+ * The number of whole days is stored in {@link $day_count} and the
103
+ * number of seconds left-over is stored here.
104
+ *
105
+ * @var int
106
+ */
107
+ private $seconds;
108
+
109
+ /**
110
+ * Make a new entry for holding a timestamp.
111
+ *
112
+ * @param integer $tag
113
+ * the Exif tag which this entry represents. There are
114
+ * only three standard tags which hold timestamp, so this should be
115
+ * one of the constants {@link PelTag::DATE_TIME}, {@link
116
+ * PelTag::DATE_TIME_ORIGINAL}, or {@link
117
+ * PelTag::DATE_TIME_DIGITIZED}.
118
+ *
119
+ * @param integer $timestamp
120
+ * the timestamp held by this entry in the correct form
121
+ * as indicated by the third argument. For {@link UNIX_TIMESTAMP}
122
+ * this is an integer counting the number of seconds since January
123
+ * 1st 1970, for {@link EXIF_STRING} this is a string of the form
124
+ * 'YYYY:MM:DD hh:mm:ss', and for {@link JULIAN_DAY_COUNT} this is a
125
+ * floating point number where the integer part denotes the day
126
+ * count and the fractional part denotes the time of day (0.25 means
127
+ * 6:00, 0.75 means 18:00).
128
+ *
129
+ * @param integer $type
130
+ * the type of the timestamp. This must be one of
131
+ * {@link UNIX_TIMESTAMP}, {@link EXIF_STRING}, or
132
+ * {@link JULIAN_DAY_COUNT}.
133
+ */
134
+ public function __construct($tag, $timestamp, $type = self::UNIX_TIMESTAMP)
135
+ {
136
+ parent::__construct($tag);
137
+ $this->setValue($timestamp, $type);
138
+ }
139
+
140
+ /**
141
+ * Return the timestamp of the entry.
142
+ *
143
+ * The timestamp held by this entry is returned in one of three
144
+ * formats: as a standard UNIX timestamp (default), as a fractional
145
+ * Julian Day Count, or as a string.
146
+ *
147
+ * @param integer $type
148
+ * the type of the timestamp. This must be one of
149
+ * {@link UNIX_TIMESTAMP}, {@link EXIF_STRING}, or
150
+ * {@link JULIAN_DAY_COUNT}.
151
+ *
152
+ * @return integer the timestamp held by this entry in the correct form
153
+ * as indicated by the type argument. For {@link UNIX_TIMESTAMP}
154
+ * this is an integer counting the number of seconds since January
155
+ * 1st 1970, for {@link EXIF_STRING} this is a string of the form
156
+ * 'YYYY:MM:DD hh:mm:ss', and for {@link JULIAN_DAY_COUNT} this is a
157
+ * floating point number where the integer part denotes the day
158
+ * count and the fractional part denotes the time of day (0.25 means
159
+ * 6:00, 0.75 means 18:00).
160
+ */
161
+ public function getValue($type = self::UNIX_TIMESTAMP)
162
+ {
163
+ switch ($type) {
164
+ case self::UNIX_TIMESTAMP:
165
+ $seconds = $this->convertJdToUnix($this->day_count);
166
+ if ($seconds === false) {
167
+ /*
168
+ * We get false if the Julian Day Count is outside the range
169
+ * of a UNIX timestamp.
170
+ */
171
+ return false;
172
+ } else {
173
+ return $seconds + $this->seconds;
174
+ }
175
+ break;
176
+ case self::EXIF_STRING:
177
+ list ($year, $month, $day) = $this->convertJdToGregorian($this->day_count);
178
+ $hours = (int) ($this->seconds / 3600);
179
+ $minutes = (int) ($this->seconds % 3600 / 60);
180
+ $seconds = $this->seconds % 60;
181
+ return sprintf('%04d:%02d:%02d %02d:%02d:%02d', $year, $month, $day, $hours, $minutes, $seconds);
182
+ case self::JULIAN_DAY_COUNT:
183
+ return $this->day_count + $this->seconds / 86400;
184
+ default:
185
+ throw new PelInvalidArgumentException(
186
+ 'Expected UNIX_TIMESTAMP (%d), ' . 'EXIF_STRING (%d), or ' . 'JULIAN_DAY_COUNT (%d) for $type, ' .
187
+ 'got %d.',
188
+ self::UNIX_TIMESTAMP,
189
+ self::EXIF_STRING,
190
+ self::JULIAN_DAY_COUNT,
191
+ $type);
192
+ }
193
+ }
194
+
195
+ /**
196
+ * Update the timestamp held by this entry.
197
+ *
198
+ * @param integer $timestamp
199
+ * the timestamp held by this entry in the correct form
200
+ * as indicated by the third argument. For {@link UNIX_TIMESTAMP}
201
+ * this is an integer counting the number of seconds since January
202
+ * 1st 1970, for {@link EXIF_STRING} this is a string of the form
203
+ * 'YYYY:MM:DD hh:mm:ss', and for {@link JULIAN_DAY_COUNT} this is a
204
+ * floating point number where the integer part denotes the day
205
+ * count and the fractional part denotes the time of day (0.25 means
206
+ * 6:00, 0.75 means 18:00).
207
+ *
208
+ * @param integer $type
209
+ * the type of the timestamp. This must be one of
210
+ * {@link UNIX_TIMESTAMP}, {@link EXIF_STRING}, or
211
+ * {@link JULIAN_DAY_COUNT}.
212
+ */
213
+ public function setValue($timestamp, $type = self::UNIX_TIMESTAMP)
214
+ {
215
+ switch ($type) {
216
+ case self::UNIX_TIMESTAMP:
217
+ $this->day_count = $this->convertUnixToJd($timestamp);
218
+ $this->seconds = $timestamp % 86400;
219
+ break;
220
+
221
+ case self::EXIF_STRING:
222
+ /* Clean the timestamp: some timestamps are broken other
223
+ * separators than ':' and ' '. */
224
+ $d = preg_split('/[^0-9]+/', $timestamp);
225
+ for ($i = 0; $i < 6; $i ++) {
226
+ if (empty($d[$i])) {
227
+ $d[$i] = 0;
228
+ }
229
+ }
230
+ $this->day_count = $this->convertGregorianToJd($d[0], $d[1], $d[2]);
231
+ $this->seconds = $d[3] * 3600 + $d[4] * 60 + $d[5];
232
+ break;
233
+
234
+ case self::JULIAN_DAY_COUNT:
235
+ $this->day_count = (int) floor($timestamp);
236
+ $this->seconds = (int) (86400 * ($timestamp - floor($timestamp)));
237
+ break;
238
+
239
+ default:
240
+ throw new PelInvalidArgumentException(
241
+ 'Expected UNIX_TIMESTAMP (%d), ' . 'EXIF_STRING (%d), or ' . 'JULIAN_DAY_COUNT (%d) for $type, ' .
242
+ 'got %d.',
243
+ self::UNIX_TIMESTAMP,
244
+ self::EXIF_STRING,
245
+ self::JULIAN_DAY_COUNT,
246
+ $type);
247
+ }
248
+
249
+ /*
250
+ * Now finally update the string which will be used when this is
251
+ * turned into bytes.
252
+ */
253
+ parent::setValue($this->getValue(self::EXIF_STRING));
254
+ }
255
+
256
+ // The following four functions are used for converting back and
257
+ // forth between the date formats. They are used in preference to
258
+ // the ones from the PHP calendar extension to avoid having to
259
+ // fiddle with timezones and to avoid depending on the extension.
260
+ //
261
+ // See http://www.hermetic.ch/cal_stud/jdn.htm#comp for a reference.
262
+
263
+ /**
264
+ * Converts a date in year/month/day format to a Julian Day count.
265
+ *
266
+ * @param integer $year
267
+ * the year.
268
+ * @param integer $month
269
+ * the month, 1 to 12.
270
+ * @param integer $day
271
+ * the day in the month.
272
+ * @return integer the Julian Day count.
273
+ */
274
+ public function convertGregorianToJd($year, $month, $day)
275
+ {
276
+ // Special case mapping 0/0/0 -> 0
277
+ if ($year == 0 || $month == 0 || $day == 0) {
278
+ return 0;
279
+ }
280
+
281
+ $m1412 = ($month <= 2) ? - 1 : 0;
282
+ return floor((1461 * ($year + 4800 + $m1412)) / 4) + floor((367 * ($month - 2 - 12 * $m1412)) / 12) -
283
+ floor((3 * floor(($year + 4900 + $m1412) / 100)) / 4) + $day - 32075;
284
+ }
285
+
286
+ /**
287
+ * Converts a Julian Day count to a year/month/day triple.
288
+ *
289
+ * @param
290
+ * int the Julian Day count.
291
+ * @return array an array with three entries: year, month, day.
292
+ */
293
+ public function convertJdToGregorian($jd)
294
+ {
295
+ // Special case mapping 0 -> 0/0/0
296
+ if ($jd == 0) {
297
+ return array(
298
+ 0,
299
+ 0,
300
+ 0
301
+ );
302
+ }
303
+
304
+ $l = $jd + 68569;
305
+ $n = floor((4 * $l) / 146097);
306
+ $l = $l - floor((146097 * $n + 3) / 4);
307
+ $i = floor((4000 * ($l + 1)) / 1461001);
308
+ $l = $l - floor((1461 * $i) / 4) + 31;
309
+ $j = floor((80 * $l) / 2447);
310
+ $d = $l - floor((2447 * $j) / 80);
311
+ $l = floor($j / 11);
312
+ $m = $j + 2 - (12 * $l);
313
+ $y = 100 * ($n - 49) + $i + $l;
314
+ return array(
315
+ $y,
316
+ $m,
317
+ $d
318
+ );
319
+ }
320
+
321
+ /**
322
+ * Converts a UNIX timestamp to a Julian Day count.
323
+ *
324
+ * @param integer $timestamp
325
+ * the timestamp.
326
+ * @return integer the Julian Day count.
327
+ */
328
+ public function convertUnixToJd($timestamp)
329
+ {
330
+ return (int) (floor($timestamp / 86400) + 2440588);
331
+ }
332
+
333
+ /**
334
+ * Converts a Julian Day count to a UNIX timestamp.
335
+ *
336
+ * @param integer $jd
337
+ * the Julian Day count.
338
+ *
339
+ * @return mixed $timestamp the integer timestamp or false if the
340
+ * day count cannot be represented as a UNIX timestamp.
341
+ */
342
+ public function convertJdToUnix($jd)
343
+ {
344
+ if ($jd > 0) {
345
+ $timestamp = ($jd - 2440588) * 86400;
346
+ if ($timestamp >= 0) {
347
+ return $timestamp;
348
+ }
349
+ }
350
+ return false;
351
+ }
352
+ }
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelEntryUndefined.php ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * PEL: PHP Exif Library.
5
+ * A library with support for reading and
6
+ * writing all Exif headers in JPEG and TIFF images using PHP.
7
+ *
8
+ * Copyright (C) 2004, 2005 Martin Geisler.
9
+ *
10
+ * This program is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program in the file COPYING; if not, write to the
22
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23
+ * Boston, MA 02110-1301 USA
24
+ */
25
+ namespace lsolesen\pel;
26
+
27
+ /**
28
+ * Classes used to hold data for Exif tags of format undefined.
29
+ *
30
+ * This file contains the base class {@link PelEntryUndefined} and
31
+ * the subclasses {@link PelEntryUserComment} which should be used
32
+ * to manage the {@link PelTag::USER_COMMENT} tag, and {@link
33
+ * PelEntryVersion} which is used to manage entries with version
34
+ * information.
35
+ *
36
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
37
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
38
+ * License (GPL)
39
+ * @package PEL
40
+ */
41
+
42
+ /**
43
+ * Class for holding data of any kind.
44
+ *
45
+ * This class can hold bytes of undefined format.
46
+ *
47
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
48
+ * @package PEL
49
+ */
50
+ class PelEntryUndefined extends PelEntry
51
+ {
52
+
53
+ /**
54
+ * Make a new PelEntry that can hold undefined data.
55
+ *
56
+ * @param integer $tag
57
+ * which this entry represents. This
58
+ * should be one of the constants defined in {@link PelTag},
59
+ * e.g., {@link PelTag::SCENE_TYPE}, {@link
60
+ * PelTag::MAKER_NOTE} or any other tag with format {@link
61
+ * PelFormat::UNDEFINED}.
62
+ *
63
+ * @param string $data
64
+ * the data that this entry will be holding. Since
65
+ * the format is undefined, no checking will be done on the data. If no data are given, a empty string will be stored
66
+ */
67
+ public function __construct($tag, $data = '')
68
+ {
69
+ $this->tag = $tag;
70
+ $this->format = PelFormat::UNDEFINED;
71
+ $this->setValue($data);
72
+ }
73
+
74
+ /**
75
+ * Set the data of this undefined entry.
76
+ *
77
+ * @param string $data
78
+ * the data that this entry will be holding. Since
79
+ * the format is undefined, no checking will be done on the data.
80
+ */
81
+ public function setValue($data)
82
+ {
83
+ $this->components = strlen($data);
84
+ $this->bytes = $data;
85
+ }
86
+
87
+ /**
88
+ * Get the data of this undefined entry.
89
+ *
90
+ * @return string the data that this entry is holding.
91
+ */
92
+ public function getValue()
93
+ {
94
+ return $this->bytes;
95
+ }
96
+
97
+ /**
98
+ * Get the value of this entry as text.
99
+ *
100
+ * The value will be returned in a format suitable for presentation.
101
+ *
102
+ * @param
103
+ * boolean some values can be returned in a long or more
104
+ * brief form, and this parameter controls that.
105
+ *
106
+ * @return string the value as text.
107
+ */
108
+ public function getText($brief = false)
109
+ {
110
+ switch ($this->tag) {
111
+ case PelTag::FILE_SOURCE:
112
+ // CC (e->components, 1, v);
113
+ switch (ord($this->bytes{0})) {
114
+ case 0x03:
115
+ return 'DSC';
116
+ default:
117
+ return sprintf('0x%02X', ord($this->bytes{0}));
118
+ }
119
+ break;
120
+ case PelTag::SCENE_TYPE:
121
+ // CC (e->components, 1, v);
122
+ switch (ord($this->bytes{0})) {
123
+ case 0x01:
124
+ return 'Directly photographed';
125
+ default:
126
+ return sprintf('0x%02X', ord($this->bytes{0}));
127
+ }
128
+ break;
129
+ case PelTag::COMPONENTS_CONFIGURATION:
130
+ // CC (e->components, 4, v);
131
+ $v = '';
132
+ for ($i = 0; $i < 4; $i ++) {
133
+ switch (ord($this->bytes{$i})) {
134
+ case 0:
135
+ $v .= '-';
136
+ break;
137
+ case 1:
138
+ $v .= 'Y';
139
+ break;
140
+ case 2:
141
+ $v .= 'Cb';
142
+ break;
143
+ case 3:
144
+ $v .= 'Cr';
145
+ break;
146
+ case 4:
147
+ $v .= 'R';
148
+ break;
149
+ case 5:
150
+ $v .= 'G';
151
+ break;
152
+ case 6:
153
+ $v .= 'B';
154
+ break;
155
+ default:
156
+ $v .= 'reserved';
157
+ break;
158
+ }
159
+ if ($i < 3) {
160
+ $v .= ' ';
161
+ }
162
+ }
163
+ return $v;
164
+ break;
165
+ case PelTag::MAKER_NOTE:
166
+ // TODO: handle maker notes.
167
+ return $this->components . ' bytes unknown MakerNote data';
168
+ break;
169
+ default:
170
+ return '(undefined)';
171
+ }
172
+ }
173
+ }
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelEntryUserComment.php ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * PEL: PHP Exif Library.
5
+ * A library with support for reading and
6
+ * writing all Exif headers in JPEG and TIFF images using PHP.
7
+ *
8
+ * Copyright (C) 2004, 2005 Martin Geisler.
9
+ *
10
+ * This program is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program in the file COPYING; if not, write to the
22
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23
+ * Boston, MA 02110-1301 USA
24
+ */
25
+ namespace lsolesen\pel;
26
+
27
+ /**
28
+ * Classes used to hold data for Exif tags of format undefined.
29
+ *
30
+ * This file contains the base class {@link PelEntryUndefined} and
31
+ * the subclasses {@link PelEntryUserComment} which should be used
32
+ * to manage the {@link PelTag::USER_COMMENT} tag, and {@link
33
+ * PelEntryVersion} which is used to manage entries with version
34
+ * information.
35
+ *
36
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
37
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
38
+ * License (GPL)
39
+ * @package PEL
40
+ */
41
+
42
+ /**
43
+ * Class for a user comment.
44
+ *
45
+ * This class is used to hold user comments, which can come in several
46
+ * different character encodings. The Exif standard specifies a
47
+ * certain format of the {@link PelTag::USER_COMMENT user comment
48
+ * tag}, and this class will make sure that the format is kept.
49
+ *
50
+ * The most basic use of this class simply stores an ASCII encoded
51
+ * string for later retrieval using {@link getValue}:
52
+ *
53
+ * <code>
54
+ * $entry = new PelEntryUserComment('An ASCII string');
55
+ * echo $entry->getValue();
56
+ * </code>
57
+ *
58
+ * The string can be encoded with a different encoding, and if so, the
59
+ * encoding must be given using the second argument. The Exif
60
+ * standard specifies three known encodings: 'ASCII', 'JIS', and
61
+ * 'Unicode'. If the user comment is encoded using a character
62
+ * encoding different from the tree known encodings, then the empty
63
+ * string should be passed as encoding, thereby specifying that the
64
+ * encoding is undefined.
65
+ *
66
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
67
+ * @package PEL
68
+ */
69
+ class PelEntryUserComment extends PelEntryUndefined
70
+ {
71
+
72
+ /**
73
+ * The user comment.
74
+ *
75
+ * @var string
76
+ */
77
+ private $comment;
78
+
79
+ /**
80
+ * The encoding.
81
+ *
82
+ * This should be one of 'ASCII', 'JIS', 'Unicode', or ''.
83
+ *
84
+ * @var string
85
+ */
86
+ private $encoding;
87
+
88
+ /**
89
+ * Make a new entry for holding a user comment.
90
+ *
91
+ * @param
92
+ * string the new user comment.
93
+ *
94
+ * @param
95
+ * string the encoding of the comment. This should be either
96
+ * 'ASCII', 'JIS', 'Unicode', or the empty string specifying an
97
+ * undefined encoding.
98
+ */
99
+ public function __construct($comment = '', $encoding = 'ASCII')
100
+ {
101
+ parent::__construct(PelTag::USER_COMMENT);
102
+ $this->setValue($comment, $encoding);
103
+ }
104
+
105
+ /**
106
+ * Set the user comment.
107
+ *
108
+ * @param
109
+ * string the new user comment.
110
+ *
111
+ * @param
112
+ * string the encoding of the comment. This should be either
113
+ * 'ASCII', 'JIS', 'Unicode', or the empty string specifying an
114
+ * unknown encoding.
115
+ */
116
+ public function setValue($comment = '', $encoding = 'ASCII')
117
+ {
118
+ $this->comment = $comment;
119
+ $this->encoding = $encoding;
120
+ parent::setValue(str_pad($encoding, 8, chr(0)) . $comment);
121
+ }
122
+
123
+ /**
124
+ * Returns the user comment.
125
+ *
126
+ * The comment is returned with the same character encoding as when
127
+ * it was set using {@link setValue} or {@link __construct the
128
+ * constructor}.
129
+ *
130
+ * @return string the user comment.
131
+ */
132
+ public function getValue()
133
+ {
134
+ return $this->comment;
135
+ }
136
+
137
+ /**
138
+ * Returns the encoding.
139
+ *
140
+ * @return string the encoding of the user comment.
141
+ */
142
+ public function getEncoding()
143
+ {
144
+ return $this->encoding;
145
+ }
146
+
147
+ /**
148
+ * Returns the user comment.
149
+ *
150
+ * @return string the user comment.
151
+ */
152
+ public function getText($brief = false)
153
+ {
154
+ return $this->comment;
155
+ }
156
+ }
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelEntryVersion.php ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * PEL: PHP Exif Library.
5
+ * A library with support for reading and
6
+ * writing all Exif headers in JPEG and TIFF images using PHP.
7
+ *
8
+ * Copyright (C) 2004, 2005 Martin Geisler.
9
+ *
10
+ * This program is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program in the file COPYING; if not, write to the
22
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23
+ * Boston, MA 02110-1301 USA
24
+ */
25
+ namespace lsolesen\pel;
26
+
27
+ /**
28
+ * Classes used to hold data for Exif tags of format undefined.
29
+ *
30
+ * This file contains the base class {@link PelEntryUndefined} and
31
+ * the subclasses {@link PelEntryUserComment} which should be used
32
+ * to manage the {@link PelTag::USER_COMMENT} tag, and {@link
33
+ * PelEntryVersion} which is used to manage entries with version
34
+ * information.
35
+ *
36
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
37
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
38
+ * License (GPL)
39
+ * @package PEL
40
+ */
41
+
42
+ /**
43
+ * Class to hold version information.
44
+ *
45
+ * There are three Exif entries that hold version information: the
46
+ * {@link PelTag::EXIF_VERSION}, {@link
47
+ * PelTag::FLASH_PIX_VERSION}, and {@link
48
+ * PelTag::INTEROPERABILITY_VERSION} tags. This class manages
49
+ * those tags.
50
+ *
51
+ * The class is used in a very straight-forward way:
52
+ * <code>
53
+ * $entry = new PelEntryVersion(PelTag::EXIF_VERSION, 2.2);
54
+ * </code>
55
+ * This creates an entry for an file complying to the Exif 2.2
56
+ * standard. It is easy to test for standards level of an unknown
57
+ * entry:
58
+ * <code>
59
+ * if ($entry->getTag() == PelTag::EXIF_VERSION &&
60
+ * $entry->getValue() > 2.0) {
61
+ * echo 'Recent Exif version.';
62
+ * }
63
+ * </code>
64
+ *
65
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
66
+ * @package PEL
67
+ */
68
+ class PelEntryVersion extends PelEntry
69
+ {
70
+
71
+ /**
72
+ * The version held by this entry.
73
+ *
74
+ * @var float
75
+ */
76
+ private $version;
77
+
78
+ /**
79
+ * Make a new entry for holding a version.
80
+ *
81
+ * @param integer $tag
82
+ * This should be one of {@link
83
+ * PelTag::EXIF_VERSION}, {@link PelTag::FLASH_PIX_VERSION},
84
+ * or {@link PelTag::INTEROPERABILITY_VERSION}.
85
+ *
86
+ * @param float $version
87
+ * The size of the entries leave room for
88
+ * exactly four digits: two digits on either side of the decimal
89
+ * point.
90
+ */
91
+ public function __construct($tag, $version = 0.0)
92
+ {
93
+ $this->tag = $tag;
94
+ $this->format = PelFormat::UNDEFINED;
95
+ $this->setValue($version);
96
+ }
97
+
98
+ /**
99
+ * Set the version held by this entry.
100
+ *
101
+ * @param float $version
102
+ * The size of the entries leave room for
103
+ * exactly four digits: two digits on either side of the decimal
104
+ * point.
105
+ */
106
+ public function setValue($version = 0.0)
107
+ {
108
+ $this->version = $version;
109
+ $major = floor($version);
110
+ $minor = ($version - $major) * 100;
111
+ $strValue = sprintf('%02.0f%02.0f', $major, $minor);
112
+ $this->components = strlen($strValue);
113
+ $this->bytes = $strValue;
114
+ }
115
+
116
+ /**
117
+ * Return the version held by this entry.
118
+ *
119
+ * @return float This will be the same as the value
120
+ * given to {@link setValue} or {@link __construct the
121
+ * constructor}.
122
+ */
123
+ public function getValue()
124
+ {
125
+ return $this->version;
126
+ }
127
+
128
+ /**
129
+ * Return a text string with the version.
130
+ *
131
+ * @param boolean $brief
132
+ * controls if the output should be brief. Brief
133
+ * output omits the word 'Version' so the result is just 'Exif x.y'
134
+ * instead of 'Exif Version x.y' if the entry holds information
135
+ * about the Exif version --- the output for FlashPix is similar.
136
+ *
137
+ * @return string the version number with the type of the tag,
138
+ * either 'Exif' or 'FlashPix'.
139
+ */
140
+ public function getText($brief = false)
141
+ {
142
+ $v = $this->version;
143
+
144
+ /*
145
+ * Versions numbers like 2.0 would be output as just 2 if we don't
146
+ * add the '.0' ourselves.
147
+ */
148
+ if (floor($this->version) == $this->version) {
149
+ $v .= '.0';
150
+ }
151
+
152
+ switch ($this->tag) {
153
+ case PelTag::EXIF_VERSION:
154
+ if ($brief) {
155
+ return Pel::fmt('Exif %s', $v);
156
+ } else {
157
+ return Pel::fmt('Exif Version %s', $v);
158
+ }
159
+ break;
160
+ case PelTag::FLASH_PIX_VERSION:
161
+ if ($brief) {
162
+ return Pel::fmt('FlashPix %s', $v);
163
+ } else {
164
+ return Pel::fmt('FlashPix Version %s', $v);
165
+ }
166
+ break;
167
+ case PelTag::INTEROPERABILITY_VERSION:
168
+ if ($brief) {
169
+ return Pel::fmt('Interoperability %s', $v);
170
+ } else {
171
+ return Pel::fmt('Interoperability Version %s', $v);
172
+ }
173
+ break;
174
+ }
175
+
176
+ if ($brief) {
177
+ return $v;
178
+ } else {
179
+ return Pel::fmt('Version %s', $v);
180
+ }
181
+ }
182
+ }
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelEntryWindowsString.php ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * PEL: PHP Exif Library.
5
+ * A library with support for reading and
6
+ * writing all Exif headers in JPEG and TIFF images using PHP.
7
+ *
8
+ * Copyright (C) 2004, 2005, 2006, 2007 Martin Geisler.
9
+ *
10
+ * This program is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program in the file COPYING; if not, write to the
22
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23
+ * Boston, MA 02110-1301 USA
24
+ */
25
+ namespace lsolesen\pel;
26
+
27
+ /**
28
+ * Classes used to hold bytes, both signed and unsigned.
29
+ * The {@link
30
+ * PelEntryWindowsString} class is used to manipulate strings in the
31
+ * format Windows XP needs.
32
+ *
33
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
34
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
35
+ * License (GPL)
36
+ * @package PEL
37
+ */
38
+
39
+ /**
40
+ * Class used to manipulate strings in the format Windows XP uses.
41
+ *
42
+ * When examining the file properties of an image in Windows XP one
43
+ * can fill in title, comment, author, keyword, and subject fields.
44
+ * Filling those fields and pressing OK will result in the data being
45
+ * written into the Exif data in the image.
46
+ *
47
+ * The data is written in a non-standard format and can thus not be
48
+ * loaded directly --- this class is needed to translate it into
49
+ * normal strings.
50
+ *
51
+ * It is important that entries from this class are only created with
52
+ * the {@link PelTag::XP_TITLE}, {@link PelTag::XP_COMMENT}, {@link
53
+ * PelTag::XP_AUTHOR}, {@link PelTag::XP_KEYWORD}, and {@link
54
+ * PelTag::XP_SUBJECT} tags. If another tag is used the data will no
55
+ * longer be correctly decoded when reloaded with PEL. (The data will
56
+ * be loaded as an {@link PelEntryByte} entry, which isn't as useful.)
57
+ *
58
+ * This class is to be used as in
59
+ * <code>
60
+ * $title = $ifd->getEntry(PelTag::XP_TITLE);
61
+ * print($title->getValue());
62
+ * $title->setValue('My favorite cat');
63
+ * </code>
64
+ * or if no entry is present one can add a new one with
65
+ * <code>
66
+ * $title = new PelEntryWindowsString(PelTag::XP_TITLE, 'A cute dog.');
67
+ * $ifd->addEntry($title);
68
+ * </code>
69
+ *
70
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
71
+ * @package PEL
72
+ */
73
+ class PelEntryWindowsString extends PelEntry
74
+ {
75
+
76
+ /**
77
+ * The string hold by this entry.
78
+ *
79
+ * This is the string that was given to the {@link __construct
80
+ * constructor} or later to {@link setValue}, without any extra NULL
81
+ * characters or any such nonsense.
82
+ *
83
+ * @var string
84
+ */
85
+ private $str;
86
+
87
+ /**
88
+ * Make a new PelEntry that can hold a Windows XP specific string.
89
+ *
90
+ * @param int $tag
91
+ * the tag which this entry represents. This should be
92
+ * one of {@link PelTag::XP_TITLE}, {@link PelTag::XP_COMMENT},
93
+ * {@link PelTag::XP_AUTHOR}, {@link PelTag::XP_KEYWORD}, and {@link
94
+ * PelTag::XP_SUBJECT} tags. If another tag is used, then this
95
+ * entry will be incorrectly reloaded as a {@link PelEntryByte}.
96
+ *
97
+ * @param string $str
98
+ * the string that this entry will represent. It will
99
+ * be passed to {@link setValue} and thus has to obey its
100
+ * requirements.
101
+ */
102
+ public function __construct($tag, $str = '')
103
+ {
104
+ $this->tag = $tag;
105
+ $this->format = PelFormat::BYTE;
106
+ $this->setValue($str);
107
+ }
108
+
109
+ /**
110
+ * Give the entry a new value.
111
+ *
112
+ * This will overwrite the previous value. The value can be
113
+ * retrieved later with the {@link getValue} method.
114
+ *
115
+ * @param string $str
116
+ * the new value of the entry. This should be use the
117
+ * Latin-1 encoding and be given without any extra NULL characters.
118
+ */
119
+ public function setValue($str)
120
+ {
121
+ $l = strlen($str);
122
+
123
+ $this->components = 2 * ($l + 1);
124
+ $this->str = $str;
125
+ $this->bytes = '';
126
+ for ($i = 0; $i < $l; $i ++) {
127
+ $this->bytes .= $str{$i} . chr(0x00);
128
+ }
129
+
130
+ $this->bytes .= chr(0x00) . chr(0x00);
131
+ }
132
+
133
+ /**
134
+ * Return the string of the entry.
135
+ *
136
+ * @return string the string held, without any extra NULL
137
+ * characters. The string will be the same as the one given to
138
+ * {@link setValue} or to the {@link __construct constructor}.
139
+ */
140
+ public function getValue()
141
+ {
142
+ return $this->str;
143
+ }
144
+
145
+ /**
146
+ * Return the string of the entry.
147
+ *
148
+ * This methods returns the same as {@link getValue}.
149
+ *
150
+ * @param boolean $brief
151
+ * not used.
152
+ *
153
+ * @return string the string held, without any extra NULL
154
+ * characters. The string will be the same as the one given to
155
+ * {@link setValue} or to the {@link __construct constructor}.
156
+ */
157
+ public function getText($brief = false)
158
+ {
159
+ return $this->str;
160
+ }
161
+ }
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelException.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * PEL: PHP Exif Library.
5
+ * A library with support for reading and
6
+ * writing all Exif headers in JPEG and TIFF images using PHP.
7
+ *
8
+ * Copyright (C) 2004, 2005 Martin Geisler.
9
+ *
10
+ * This program is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program in the file COPYING; if not, write to the
22
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23
+ * Boston, MA 02110-1301 USA
24
+ */
25
+ namespace lsolesen\pel;
26
+
27
+ /**
28
+ * Standard PEL printf() capable exception.
29
+ * This class is a simple extension of the standard Exception class in
30
+ * PHP, and all the methods defined there retain their original
31
+ * meaning.
32
+ *
33
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
34
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
35
+ * License (GPL)
36
+ * @package PEL
37
+ *
38
+ * @subpackage PelException
39
+ */
40
+ class PelException extends \Exception
41
+ {
42
+
43
+ /**
44
+ * Construct a new PEL exception.
45
+ *
46
+ * @param string $fmt
47
+ * an optional format string can be given. It
48
+ * will be used as a format string for vprintf(). The remaining
49
+ * arguments will be available for the format string as usual with
50
+ * vprintf().
51
+ *
52
+ * @param mixed ...$args
53
+ * any number of arguments to be used with
54
+ * the format string.
55
+ */
56
+ public function __construct($fmt, $args = null)
57
+ {
58
+ $args = func_get_args();
59
+ $fmt = array_shift($args);
60
+ parent::__construct(vsprintf($fmt, $args));
61
+ }
62
+ }
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelExif.php ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * PEL: PHP Exif Library.
5
+ * A library with support for reading and
6
+ * writing all Exif headers in JPEG and TIFF images using PHP.
7
+ *
8
+ * Copyright (C) 2004, 2005 Martin Geisler.
9
+ *
10
+ * This program is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program in the file COPYING; if not, write to the
22
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23
+ * Boston, MA 02110-1301 USA
24
+ */
25
+ namespace lsolesen\pel;
26
+
27
+ /**
28
+ * Classes for dealing with Exif data.
29
+ *
30
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
31
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
32
+ * License (GPL)
33
+ * @package PEL
34
+ */
35
+
36
+ /**
37
+ * Class representing Exif data.
38
+ *
39
+ * Exif data resides as {@link PelJpegContent data} and consists of a
40
+ * header followed by a number of {@link PelJpegIfd IFDs}.
41
+ *
42
+ * The interesting method in this class is {@link getTiff()} which
43
+ * will return the {@link PelTiff} object which really holds the data
44
+ * which one normally think of when talking about Exif data. This is
45
+ * because Exif data is stored as an extension of the TIFF file
46
+ * format.
47
+ *
48
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
49
+ * @package PEL
50
+ */
51
+ class PelExif extends PelJpegContent
52
+ {
53
+
54
+ /**
55
+ * Exif header.
56
+ *
57
+ * The Exif data must start with these six bytes to be considered
58
+ * valid.
59
+ */
60
+ const EXIF_HEADER = "Exif\0\0";
61
+
62
+ /**
63
+ * The PelTiff object contained within.
64
+ *
65
+ * @var PelTiff
66
+ */
67
+ private $tiff = null;
68
+
69
+ /**
70
+ * Construct a new Exif object.
71
+ *
72
+ * The new object will be empty --- use the {@link load()} method to
73
+ * load Exif data from a {@link PelDataWindow} object, or use the
74
+ * {@link setTiff()} to change the {@link PelTiff} object, which is
75
+ * the true holder of the Exif {@link PelEntry entries}.
76
+ */
77
+ public function __construct()
78
+ {
79
+ // nothing to be done
80
+ }
81
+
82
+ /**
83
+ * Load and parse Exif data.
84
+ *
85
+ * This will populate the object with Exif data, contained as a
86
+ * {@link PelTiff} object. This TIFF object can be accessed with
87
+ * the {@link getTiff()} method.
88
+ *
89
+ * @param PelDataWindow $d
90
+ */
91
+ public function load(PelDataWindow $d)
92
+ {
93
+ Pel::debug('Parsing %d bytes of Exif data...', $d->getSize());
94
+
95
+ /* There must be at least 6 bytes for the Exif header. */
96
+ if ($d->getSize() < 6) {
97
+ throw new PelInvalidDataException('Expected at least 6 bytes of Exif ' . 'data, found just %d bytes.', $d->getSize());
98
+ }
99
+ /* Verify the Exif header */
100
+ if ($d->strcmp(0, self::EXIF_HEADER)) {
101
+ $d->setWindowStart(strlen(self::EXIF_HEADER));
102
+ } else {
103
+ throw new PelInvalidDataException('Exif header not found.');
104
+ }
105
+
106
+ /* The rest of the data is TIFF data. */
107
+ $this->tiff = new PelTiff();
108
+ $this->tiff->load($d);
109
+ }
110
+
111
+ /**
112
+ * Change the TIFF information.
113
+ *
114
+ * Exif data is really stored as TIFF data, and this method can be
115
+ * used to change this data from one {@link PelTiff} object to
116
+ * another.
117
+ *
118
+ * @param PelTiff $tiff
119
+ * the new TIFF object.
120
+ */
121
+ public function setTiff(PelTiff $tiff)
122
+ {
123
+ $this->tiff = $tiff;
124
+ }
125
+
126
+ /**
127
+ * Get the underlying TIFF object.
128
+ *
129
+ * The actual Exif data is stored in a {@link PelTiff} object, and
130
+ * this method provides access to it.
131
+ *
132
+ * @return PelTiff the TIFF object with the Exif data.
133
+ */
134
+ public function getTiff()
135
+ {
136
+ return $this->tiff;
137
+ }
138
+
139
+ /**
140
+ * Produce bytes for the Exif data.
141
+ *
142
+ * @return string bytes representing this object.
143
+ */
144
+ public function getBytes()
145
+ {
146
+ return self::EXIF_HEADER . $this->tiff->getBytes();
147
+ }
148
+
149
+ /**
150
+ * Return a string representation of this object.
151
+ *
152
+ * @return string a string describing this object. This is mostly
153
+ * useful for debugging.
154
+ */
155
+ public function __toString()
156
+ {
157
+ return Pel::tra("Dumping Exif data...\n") . $this->tiff->__toString();
158
+ }
159
+ }
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelFormat.php ADDED
@@ -0,0 +1,227 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * PEL: PHP Exif Library.
4
+ * A library with support for reading and
5
+ * writing all Exif headers in JPEG and TIFF images using PHP.
6
+ *
7
+ * Copyright (C) 2004, 2005 Martin Geisler.
8
+ * Copyright (C) 2017 Johannes Weberhofer.
9
+ *
10
+ * This program is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program in the file COPYING; if not, write to the
22
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23
+ * Boston, MA 02110-1301 USA
24
+ */
25
+ namespace lsolesen\pel;
26
+
27
+ /**
28
+ * Namespace for functions operating on Exif formats.
29
+ *
30
+ * This class defines the constants that are to be used whenever one
31
+ * has to refer to the format of an Exif tag. They will be
32
+ * collectively denoted by the pseudo-type PelFormat throughout the
33
+ * documentation.
34
+ *
35
+ * All the methods defined here are static, and they all operate on a
36
+ * single argument which should be one of the class constants.
37
+ *
38
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
39
+ * @author Johannes Weberhofer <jweberhofer@weberhofer.at>
40
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
41
+ * License (GPL)
42
+ * @package
43
+ *
44
+ */
45
+ class PelFormat
46
+ {
47
+
48
+ /**
49
+ * Unsigned byte.
50
+ *
51
+ * Each component will be an unsigned 8-bit integer with a value
52
+ * between 0 and 255.
53
+ *
54
+ * Modelled with the {@link PelEntryByte} class.
55
+ */
56
+ const BYTE = 1;
57
+
58
+ /**
59
+ * ASCII string.
60
+ *
61
+ * Each component will be an ASCII character.
62
+ *
63
+ * Modelled with the {@link PelEntryAscii} class.
64
+ */
65
+ const ASCII = 2;
66
+
67
+ /**
68
+ * Unsigned short.
69
+ *
70
+ * Each component will be an unsigned 16-bit integer with a value
71
+ * between 0 and 65535.
72
+ *
73
+ * Modelled with the {@link PelEntryShort} class.
74
+ */
75
+ const SHORT = 3;
76
+
77
+ /**
78
+ * Unsigned long.
79
+ *
80
+ * Each component will be an unsigned 32-bit integer with a value
81
+ * between 0 and 4294967295.
82
+ *
83
+ * Modelled with the {@link PelEntryLong} class.
84
+ */
85
+ const LONG = 4;
86
+
87
+ /**
88
+ * Unsigned rational number.
89
+ *
90
+ * Each component will consist of two unsigned 32-bit integers
91
+ * denoting the enumerator and denominator. Each integer will have
92
+ * a value between 0 and 4294967295.
93
+ *
94
+ * Modelled with the {@link PelEntryRational} class.
95
+ */
96
+ const RATIONAL = 5;
97
+
98
+ /**
99
+ * Signed byte.
100
+ *
101
+ * Each component will be a signed 8-bit integer with a value
102
+ * between -128 and 127.
103
+ *
104
+ * Modelled with the {@link PelEntrySByte} class.
105
+ */
106
+ const SBYTE = 6;
107
+
108
+ /**
109
+ * Undefined byte.
110
+ *
111
+ * Each component will be a byte with no associated interpretation.
112
+ *
113
+ * Modelled with the {@link PelEntryUndefined} class.
114
+ */
115
+ const UNDEFINED = 7;
116
+
117
+ /**
118
+ * Signed short.
119
+ *
120
+ * Each component will be a signed 16-bit integer with a value
121
+ * between -32768 and 32767.
122
+ *
123
+ * Modelled with the {@link PelEntrySShort} class.
124
+ */
125
+ const SSHORT = 8;
126
+
127
+ /**
128
+ * Signed long.
129
+ *
130
+ * Each component will be a signed 32-bit integer with a value
131
+ * between -2147483648 and 2147483647.
132
+ *
133
+ * Modelled with the {@link PelEntrySLong} class.
134
+ */
135
+ const SLONG = 9;
136
+
137
+ /**
138
+ * Signed rational number.
139
+ *
140
+ * Each component will consist of two signed 32-bit integers
141
+ * denoting the enumerator and denominator. Each integer will have
142
+ * a value between -2147483648 and 2147483647.
143
+ *
144
+ * Modelled with the {@link PelEntrySRational} class.
145
+ */
146
+ const SRATIONAL = 10;
147
+
148
+ /**
149
+ * Floating point number.
150
+ *
151
+ * Entries with this format are not currently implemented.
152
+ */
153
+ const FLOAT = 11;
154
+
155
+ /**
156
+ * Double precision floating point number.
157
+ *
158
+ * Entries with this format are not currently implemented.
159
+ */
160
+ const DOUBLE = 12;
161
+
162
+ /**
163
+ * Values for format's short names
164
+ */
165
+ protected static $formatName = array(
166
+ self::ASCII => 'Ascii',
167
+ self::BYTE => 'Byte',
168
+ self::SHORT => 'Short',
169
+ self::LONG => 'Long',
170
+ self::RATIONAL => 'Rational',
171
+ self::SBYTE => 'SByte',
172
+ self::SSHORT => 'SShort',
173
+ self::SLONG => 'SLong',
174
+ self::SRATIONAL => 'SRational',
175
+ self::FLOAT => 'Float',
176
+ self::DOUBLE => 'Double',
177
+ self::UNDEFINED => 'Undefined'
178
+ );
179
+
180
+ protected static $formatLength = array(
181
+ self::ASCII => 1,
182
+ self::BYTE => 1,
183
+ self::SHORT => 2,
184
+ self::LONG => 4,
185
+ self::RATIONAL => 8,
186
+ self::SBYTE => 1,
187
+ self::SSHORT => 2,
188
+ self::SLONG => 4,
189
+ self::SRATIONAL => 8,
190
+ self::FLOAT => 4,
191
+ self::DOUBLE => 8,
192
+ self::UNDEFINED => 1
193
+ );
194
+
195
+ /**
196
+ * Returns the name of a format like 'Ascii' for the {@link ASCII} format
197
+ *
198
+ * @param integer $type
199
+ * as defined in {@link PelFormat}
200
+ * @return string
201
+ */
202
+ public static function getName($type)
203
+ {
204
+ if (array_key_exists($type, self::$formatName)) {
205
+ return self::$formatName[$type];
206
+ } else {
207
+ return Pel::fmt('Unknown format: 0x%X', $type);
208
+ }
209
+ }
210
+
211
+ /**
212
+ * Return the size of components in a given format in bytes needed to store one component with the
213
+ * given format.
214
+ *
215
+ * @param integer $type
216
+ * as defined in {@link PelFormat}
217
+ * @return integer|string
218
+ */
219
+ public static function getSize($type)
220
+ {
221
+ if (array_key_exists($type, self::$formatLength)) {
222
+ return self::$formatLength[$type];
223
+ } else {
224
+ return Pel::fmt('Unknown format: 0x%X', $type);
225
+ }
226
+ }
227
+ }
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelIfd.php ADDED
@@ -0,0 +1,1221 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * PEL: PHP Exif Library.
5
+ * A library with support for reading and
6
+ * writing all Exif headers in JPEG and TIFF images using PHP.
7
+ *
8
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008 Martin Geisler.
9
+ *
10
+ * This program is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program in the file COPYING; if not, write to the
22
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23
+ * Boston, MA 02110-1301 USA
24
+ */
25
+ namespace lsolesen\pel;
26
+
27
+ /**
28
+ * Classes for dealing with Exif IFDs.
29
+ *
30
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
31
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
32
+ * License (GPL)
33
+ * @package PEL
34
+ */
35
+
36
+ /**
37
+ * Class representing an Image File Directory (IFD).
38
+ *
39
+ * {@link PelTiff TIFF data} is structured as a number of Image File
40
+ * Directories, IFDs for short. Each IFD contains a number of {@link
41
+ * PelEntry entries}, some data and finally a link to the next IFD.
42
+ *
43
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
44
+ * @package PEL
45
+ */
46
+ class PelIfd implements \IteratorAggregate, \ArrayAccess
47
+ {
48
+
49
+ /**
50
+ * Main image IFD.
51
+ *
52
+ * Pass this to the constructor when creating an IFD which will be
53
+ * the IFD of the main image.
54
+ */
55
+ const IFD0 = 0;
56
+
57
+ /**
58
+ * Thumbnail image IFD.
59
+ *
60
+ * Pass this to the constructor when creating an IFD which will be
61
+ * the IFD of the thumbnail image.
62
+ */
63
+ const IFD1 = 1;
64
+
65
+ /**
66
+ * Exif IFD.
67
+ *
68
+ * Pass this to the constructor when creating an IFD which will be
69
+ * the Exif sub-IFD.
70
+ */
71
+ const EXIF = 2;
72
+
73
+ /**
74
+ * GPS IFD.
75
+ *
76
+ * Pass this to the constructor when creating an IFD which will be
77
+ * the GPS sub-IFD.
78
+ */
79
+ const GPS = 3;
80
+
81
+ /**
82
+ * Interoperability IFD.
83
+ *
84
+ * Pass this to the constructor when creating an IFD which will be
85
+ * the interoperability sub-IFD.
86
+ */
87
+ const INTEROPERABILITY = 4;
88
+
89
+ /**
90
+ * The entries held by this directory.
91
+ *
92
+ * Each tag in the directory is represented by a {@link PelEntry}
93
+ * object in this array.
94
+ *
95
+ * @var array
96
+ */
97
+ private $entries = array();
98
+
99
+ /**
100
+ * The type of this directory.
101
+ *
102
+ * Initialized in the constructor. Must be one of {@link IFD0},
103
+ * {@link IFD1}, {@link EXIF}, {@link GPS}, or {@link
104
+ * INTEROPERABILITY}.
105
+ *
106
+ * @var int
107
+ */
108
+ private $type;
109
+
110
+ /**
111
+ * The next directory.
112
+ *
113
+ * This will be initialized in the constructor, or be left as null
114
+ * if this is the last directory.
115
+ *
116
+ * @var PelIfd
117
+ */
118
+ private $next = null;
119
+
120
+ /**
121
+ * Sub-directories pointed to by this directory.
122
+ *
123
+ * This will be an array of ({@link PelTag}, {@link PelIfd}) pairs.
124
+ *
125
+ * @var array
126
+ */
127
+ private $sub = array();
128
+
129
+ /**
130
+ * The thumbnail data.
131
+ *
132
+ * This will be initialized in the constructor, or be left as null
133
+ * if there are no thumbnail as part of this directory.
134
+ *
135
+ * @var PelDataWindow
136
+ */
137
+ private $thumb_data = null;
138
+ // TODO: use this format to choose between the
139
+ // JPEG_INTERCHANGE_FORMAT and STRIP_OFFSETS tags.
140
+ // private $thumb_format;
141
+
142
+ /**
143
+ * Construct a new Image File Directory (IFD).
144
+ *
145
+ * The IFD will be empty, use the {@link addEntry()} method to add
146
+ * an {@link PelEntry}. Use the {@link setNext()} method to link
147
+ * this IFD to another.
148
+ *
149
+ * @param
150
+ * int type the type of this IFD. Must be one of {@link
151
+ * IFD0}, {@link IFD1}, {@link EXIF}, {@link GPS}, or {@link
152
+ * INTEROPERABILITY}. An {@link PelIfdException} will be thrown
153
+ * otherwise.
154
+ */
155
+ public function __construct($type)
156
+ {
157
+ if ($type != PelIfd::IFD0 && $type != PelIfd::IFD1 && $type != PelIfd::EXIF && $type != PelIfd::GPS &&
158
+ $type != PelIfd::INTEROPERABILITY) {
159
+ throw new PelIfdException('Unknown IFD type: %d', $type);
160
+ }
161
+
162
+ $this->type = $type;
163
+ }
164
+
165
+ /**
166
+ * Load data into a Image File Directory (IFD).
167
+ *
168
+ * @param PelDataWindow $d
169
+ * the data window that will provide the data.
170
+ *
171
+ * @param int $offset
172
+ * the offset within the window where the directory will
173
+ * be found.
174
+ */
175
+ public function load(PelDataWindow $d, $offset)
176
+ {
177
+ $thumb_offset = 0;
178
+ $thumb_length = 0;
179
+
180
+ Pel::debug('Constructing IFD at offset %d from %d bytes...', $offset, $d->getSize());
181
+
182
+ /* Read the number of entries */
183
+ $n = $d->getShort($offset);
184
+ Pel::debug('Loading %d entries...', $n);
185
+
186
+ $offset += 2;
187
+
188
+ /* Check if we have enough data. */
189
+ if ($offset + 12 * $n > $d->getSize()) {
190
+ $n = floor(($offset - $d->getSize()) / 12);
191
+ Pel::maybeThrow(new PelIfdException('Adjusted to: %d.', $n));
192
+ }
193
+
194
+ for ($i = 0; $i < $n; $i ++) {
195
+ // TODO: increment window start instead of using offsets.
196
+ $tag = $d->getShort($offset + 12 * $i);
197
+ Pel::debug(
198
+ 'Loading entry with tag 0x%04X: %s (%d of %d)...',
199
+ $tag,
200
+ PelTag::getName($this->type, $tag),
201
+ $i + 1,
202
+ $n);
203
+
204
+ switch ($tag) {
205
+ case PelTag::EXIF_IFD_POINTER:
206
+ case PelTag::GPS_INFO_IFD_POINTER:
207
+ case PelTag::INTEROPERABILITY_IFD_POINTER:
208
+ $o = $d->getLong($offset + 12 * $i + 8);
209
+ Pel::debug('Found sub IFD at offset %d', $o);
210
+
211
+ /* Map tag to IFD type. */
212
+ if ($tag == PelTag::EXIF_IFD_POINTER) {
213
+ $type = PelIfd::EXIF;
214
+ } elseif ($tag == PelTag::GPS_INFO_IFD_POINTER) {
215
+ $type = PelIfd::GPS;
216
+ } elseif ($tag == PelTag::INTEROPERABILITY_IFD_POINTER) {
217
+ $type = PelIfd::INTEROPERABILITY;
218
+ }
219
+
220
+ $this->sub[$type] = new PelIfd($type);
221
+ $this->sub[$type]->load($d, $o);
222
+ break;
223
+ case PelTag::JPEG_INTERCHANGE_FORMAT:
224
+ $thumb_offset = $d->getLong($offset + 12 * $i + 8);
225
+ $this->safeSetThumbnail($d, $thumb_offset, $thumb_length);
226
+ break;
227
+ case PelTag::JPEG_INTERCHANGE_FORMAT_LENGTH:
228
+ $thumb_length = $d->getLong($offset + 12 * $i + 8);
229
+ $this->safeSetThumbnail($d, $thumb_offset, $thumb_length);
230
+ break;
231
+ default:
232
+ $format = $d->getShort($offset + 12 * $i + 2);
233
+ $components = $d->getLong($offset + 12 * $i + 4);
234
+
235
+ /*
236
+ * The data size. If bigger than 4 bytes, the actual data is
237
+ * not in the entry but somewhere else, with the offset stored
238
+ * in the entry.
239
+ */
240
+ $s = PelFormat::getSize($format) * $components;
241
+ if ($s > 0) {
242
+ $doff = $offset + 12 * $i + 8;
243
+ if ($s > 4) {
244
+ $doff = $d->getLong($doff);
245
+ }
246
+ $data = $d->getClone($doff, $s);
247
+ } else {
248
+ $data = new PelDataWindow();
249
+ }
250
+
251
+ try {
252
+ $entry = $this->newEntryFromData($tag, $format, $components, $data);
253
+ $this->addEntry($entry);
254
+ } catch (PelException $e) {
255
+ /*
256
+ * Throw the exception when running in strict mode, store
257
+ * otherwise.
258
+ */
259
+ Pel::maybeThrow($e);
260
+ }
261
+
262
+ /* The format of the thumbnail is stored in this tag. */
263
+ // TODO: handle TIFF thumbnail.
264
+ // if ($tag == PelTag::COMPRESSION) {
265
+ // $this->thumb_format = $data->getShort();
266
+ // }
267
+ break;
268
+ }
269
+ }
270
+
271
+ /* Offset to next IFD */
272
+ $o = $d->getLong($offset + 12 * $n);
273
+ Pel::debug('Current offset is %d, link at %d points to %d.', $offset, $offset + 12 * $n, $o);
274
+
275
+ if ($o > 0) {
276
+ /* Sanity check: we need 6 bytes */
277
+ if ($o > $d->getSize() - 6) {
278
+ Pel::maybeThrow(new PelIfdException('Bogus offset to next IFD: ' . '%d > %d!', $o, $d->getSize() - 6));
279
+ } else {
280
+ if ($this->type == PelIfd::IFD1) {
281
+ // IFD1 shouldn't link further...
282
+ Pel::maybeThrow(new PelIfdException('IFD1 links to another IFD!'));
283
+ }
284
+ $this->next = new PelIfd(PelIfd::IFD1);
285
+ $this->next->load($d, $o);
286
+ }
287
+ } else {
288
+ Pel::debug('Last IFD.');
289
+ }
290
+ }
291
+
292
+ /**
293
+ * Make a new entry from a bunch of bytes.
294
+ *
295
+ * This method will create the proper subclass of {@link PelEntry}
296
+ * corresponding to the {@link PelTag} and {@link PelFormat} given.
297
+ * The entry will be initialized with the data given.
298
+ *
299
+ * Please note that the data you pass to this method should come
300
+ * from an image, that is, it should be raw bytes. If instead you
301
+ * want to create an entry for holding, say, an short integer, then
302
+ * create a {@link PelEntryShort} object directly and load the data
303
+ * into it.
304
+ *
305
+ * A {@link PelUnexpectedFormatException} is thrown if a mismatch is
306
+ * discovered between the tag and format, and likewise a {@link
307
+ * PelWrongComponentCountException} is thrown if the number of
308
+ * components does not match the requirements of the tag. The
309
+ * requirements for a given tag (if any) can be found in the
310
+ * documentation for {@link PelTag}.
311
+ *
312
+ * @param integer $tag
313
+ * the tag of the entry as defined in {@link PelTag}.
314
+ *
315
+ * @param integer $format
316
+ * the format of the entry as defined in {@link PelFormat}.
317
+ *
318
+ * @param int $components
319
+ * the components in the entry.
320
+ *
321
+ * @param PelDataWindow $data
322
+ * the data which will be used to construct the
323
+ * entry.
324
+ *
325
+ * @return PelEntry a newly created entry, holding the data given.
326
+ */
327
+ public function newEntryFromData($tag, $format, $components, PelDataWindow $data)
328
+ {
329
+
330
+ /*
331
+ * First handle tags for which we have a specific PelEntryXXX
332
+ * class.
333
+ */
334
+ switch ($this->type) {
335
+ case self::IFD0:
336
+ case self::IFD1:
337
+ case self::EXIF:
338
+ case self::INTEROPERABILITY:
339
+ switch ($tag) {
340
+ case PelTag::DATE_TIME:
341
+ case PelTag::DATE_TIME_ORIGINAL:
342
+ case PelTag::DATE_TIME_DIGITIZED:
343
+ if ($format != PelFormat::ASCII) {
344
+ throw new PelUnexpectedFormatException($this->type, $tag, $format, PelFormat::ASCII);
345
+ }
346
+ if ($components != 20) {
347
+ throw new PelWrongComponentCountException($this->type, $tag, $components, 20);
348
+ }
349
+ // TODO: handle timezones.
350
+ return new PelEntryTime($tag, $data->getBytes(0, - 1), PelEntryTime::EXIF_STRING);
351
+
352
+ case PelTag::COPYRIGHT:
353
+ if ($format != PelFormat::ASCII) {
354
+ throw new PelUnexpectedFormatException($this->type, $tag, $format, PelFormat::ASCII);
355
+ }
356
+ $v = explode("\0", trim($data->getBytes(), ' '));
357
+ if (! isset($v[1])) {
358
+ Pel::maybeThrow(new PelException('Invalid copyright: %s', $data->getBytes()));
359
+ // when not in strict mode, set empty copyright and continue
360
+ $v[1] = '';
361
+ }
362
+ return new PelEntryCopyright($v[0], $v[1]);
363
+
364
+ case PelTag::EXIF_VERSION:
365
+ case PelTag::FLASH_PIX_VERSION:
366
+ case PelTag::INTEROPERABILITY_VERSION:
367
+ if ($format != PelFormat::UNDEFINED) {
368
+ throw new PelUnexpectedFormatException($this->type, $tag, $format, PelFormat::UNDEFINED);
369
+ }
370
+ return new PelEntryVersion($tag, $data->getBytes() / 100);
371
+
372
+ case PelTag::USER_COMMENT:
373
+ if ($format != PelFormat::UNDEFINED) {
374
+ throw new PelUnexpectedFormatException($this->type, $tag, $format, PelFormat::UNDEFINED);
375
+ }
376
+ if ($data->getSize() < 8) {
377
+ return new PelEntryUserComment();
378
+ } else {
379
+ return new PelEntryUserComment($data->getBytes(8), rtrim($data->getBytes(0, 8)));
380
+ }
381
+ // this point can not be reached
382
+ case PelTag::XP_TITLE:
383
+ case PelTag::XP_COMMENT:
384
+ case PelTag::XP_AUTHOR:
385
+ case PelTag::XP_KEYWORDS:
386
+ case PelTag::XP_SUBJECT:
387
+ if ($format != PelFormat::BYTE) {
388
+ throw new PelUnexpectedFormatException($this->type, $tag, $format, PelFormat::BYTE);
389
+ }
390
+ $v = '';
391
+ for ($i = 0; $i < $components; $i ++) {
392
+ $b = $data->getByte($i);
393
+ /*
394
+ * Convert the byte to a character if it is non-null ---
395
+ * information about the character encoding of these entries
396
+ * would be very nice to have! So far my tests have shown
397
+ * that characters in the Latin-1 character set are stored in
398
+ * a single byte followed by a NULL byte.
399
+ */
400
+ if ($b != 0) {
401
+ $v .= chr($b);
402
+ }
403
+ }
404
+
405
+ return new PelEntryWindowsString($tag, $v);
406
+ }
407
+ // This point can be reached! Continue with default.
408
+ case self::GPS:
409
+ default:
410
+ /* Then handle the basic formats. */
411
+ switch ($format) {
412
+ case PelFormat::BYTE:
413
+ $v = new PelEntryByte($tag);
414
+ for ($i = 0; $i < $components; $i ++) {
415
+ $v->addNumber($data->getByte($i));
416
+ }
417
+ return $v;
418
+
419
+ case PelFormat::SBYTE:
420
+ $v = new PelEntrySByte($tag);
421
+ for ($i = 0; $i < $components; $i ++) {
422
+ $v->addNumber($data->getSByte($i));
423
+ }
424
+ return $v;
425
+
426
+ case PelFormat::ASCII:
427
+ return new PelEntryAscii($tag, rtrim($data->getBytes(0), "\0"));
428
+
429
+ case PelFormat::SHORT:
430
+ $v = new PelEntryShort($tag);
431
+ for ($i = 0; $i < $components; $i ++) {
432
+ $v->addNumber($data->getShort($i * 2));
433
+ }
434
+ return $v;
435
+
436
+ case PelFormat::SSHORT:
437
+ $v = new PelEntrySShort($tag);
438
+ for ($i = 0; $i < $components; $i ++) {
439
+ $v->addNumber($data->getSShort($i * 2));
440
+ }
441
+ return $v;
442
+
443
+ case PelFormat::LONG:
444
+ $v = new PelEntryLong($tag);
445
+ for ($i = 0; $i < $components; $i ++) {
446
+ $v->addNumber($data->getLong($i * 4));
447
+ }
448
+ return $v;
449
+
450
+ case PelFormat::SLONG:
451
+ $v = new PelEntrySLong($tag);
452
+ for ($i = 0; $i < $components; $i ++) {
453
+ $v->addNumber($data->getSLong($i * 4));
454
+ }
455
+ return $v;
456
+
457
+ case PelFormat::RATIONAL:
458
+ $v = new PelEntryRational($tag);
459
+ for ($i = 0; $i < $components; $i ++) {
460
+ $v->addNumber($data->getRational($i * 8));
461
+ }
462
+ return $v;
463
+
464
+ case PelFormat::SRATIONAL:
465
+ $v = new PelEntrySRational($tag);
466
+ for ($i = 0; $i < $components; $i ++) {
467
+ $v->addNumber($data->getSRational($i * 8));
468
+ }
469
+ return $v;
470
+
471
+ case PelFormat::UNDEFINED:
472
+ return new PelEntryUndefined($tag, $data->getBytes());
473
+
474
+ default:
475
+ throw new PelException('Unsupported format: %s', PelFormat::getName($format));
476
+ }
477
+ }
478
+ }
479
+
480
+ /**
481
+ * Extract thumbnail data safely.
482
+ *
483
+ * It is safe to call this method repeatedly with either the offset
484
+ * or the length set to zero, since it requires both of these
485
+ * arguments to be positive before the thumbnail is extracted.
486
+ *
487
+ * When both parameters are set it will check the length against the
488
+ * available data and adjust as necessary. Only then is the
489
+ * thumbnail data loaded.
490
+ *
491
+ * @param PelDataWindow $d
492
+ * the data from which the thumbnail will be
493
+ * extracted.
494
+ *
495
+ * @param int $offset
496
+ * the offset into the data.
497
+ *
498
+ * @param int $length
499
+ * the length of the thumbnail.
500
+ */
501
+ private function safeSetThumbnail(PelDataWindow $d, $offset, $length)
502
+ {
503
+ /*
504
+ * Load the thumbnail if both the offset and the length is
505
+ * available.
506
+ */
507
+ if ($offset > 0 && $length > 0) {
508
+ /*
509
+ * Some images have a broken length, so we try to carefully
510
+ * check the length before we store the thumbnail.
511
+ */
512
+ if ($offset + $length > $d->getSize()) {
513
+ Pel::maybeThrow(
514
+ new PelIfdException(
515
+ 'Thumbnail length %d bytes ' . 'adjusted to %d bytes.',
516
+ $length,
517
+ $d->getSize() - $offset));
518
+ $length = $d->getSize() - $offset;
519
+ }
520
+
521
+ /* Now set the thumbnail normally. */
522
+ $this->setThumbnail($d->getClone($offset, $length));
523
+ }
524
+ }
525
+
526
+ /**
527
+ * Set thumbnail data.
528
+ *
529
+ * Use this to embed an arbitrary JPEG image within this IFD. The
530
+ * data will be checked to ensure that it has a proper {@link
531
+ * PelJpegMarker::EOI} at the end. If not, then the length is
532
+ * adjusted until one if found. An {@link PelIfdException} might be
533
+ * thrown (depending on {@link Pel::$strict}) this case.
534
+ *
535
+ * @param PelDataWindow $d
536
+ * the thumbnail data.
537
+ */
538
+ public function setThumbnail(PelDataWindow $d)
539
+ {
540
+ $size = $d->getSize();
541
+ /* Now move backwards until we find the EOI JPEG marker. */
542
+ while ($d->getByte($size - 2) != 0xFF || $d->getByte($size - 1) != PelJpegMarker::EOI) {
543
+ $size --;
544
+ }
545
+
546
+ if ($size != $d->getSize()) {
547
+ Pel::maybeThrow(new PelIfdException('Decrementing thumbnail size ' . 'to %d bytes', $size));
548
+ }
549
+ $this->thumb_data = $d->getClone(0, $size);
550
+ }
551
+
552
+ /**
553
+ * Get the type of this directory.
554
+ *
555
+ * @return int of {@link PelIfd::IFD0}, {@link PelIfd::IFD1}, {@link
556
+ * PelIfd::EXIF}, {@link PelIfd::GPS}, or {@link
557
+ * PelIfd::INTEROPERABILITY}.
558
+ */
559
+ public function getType()
560
+ {
561
+ return $this->type;
562
+ }
563
+
564
+ /**
565
+ * Is a given tag valid for this IFD?
566
+ *
567
+ * Different types of IFDs can contain different kinds of tags ---
568
+ * the {@link IFD0} type, for example, cannot contain a {@link
569
+ * PelTag::GPS_LONGITUDE} tag.
570
+ *
571
+ * A special exception is tags with values above 0xF000. They are
572
+ * treated as private tags and will be allowed everywhere (use this
573
+ * for testing or for implementing your own types of tags).
574
+ *
575
+ * @param PelTag $tag
576
+ * the tag.
577
+ *
578
+ * @return boolean true if the tag is considered valid in this IFD,
579
+ * false otherwise.
580
+ *
581
+ * @see getValidTags()
582
+ */
583
+ public function isValidTag($tag)
584
+ {
585
+ return $tag > 0xF000 || in_array($tag, $this->getValidTags());
586
+ }
587
+
588
+ /**
589
+ * Returns a list of valid tags for this IFD.
590
+ *
591
+ * @return array an array of {@link PelTag}s which are valid for
592
+ * this IFD.
593
+ */
594
+ public function getValidTags()
595
+ {
596
+ switch ($this->type) {
597
+ case PelIfd::IFD0:
598
+ case PelIfd::IFD1:
599
+ return array(
600
+ PelTag::IMAGE_WIDTH,
601
+ PelTag::IMAGE_LENGTH,
602
+ PelTag::BITS_PER_SAMPLE,
603
+ PelTag::COMPRESSION,
604
+ PelTag::PHOTOMETRIC_INTERPRETATION,
605
+ PelTag::DOCUMENT_NAME,
606
+ PelTag::IMAGE_DESCRIPTION,
607
+ PelTag::MAKE,
608
+ PelTag::MODEL,
609
+ PelTag::STRIP_OFFSETS,
610
+ PelTag::ORIENTATION,
611
+ PelTag::SAMPLES_PER_PIXEL,
612
+ PelTag::ROWS_PER_STRIP,
613
+ PelTag::STRIP_BYTE_COUNTS,
614
+ PelTag::X_RESOLUTION,
615
+ PelTag::Y_RESOLUTION,
616
+ PelTag::PLANAR_CONFIGURATION,
617
+ PelTag::RESOLUTION_UNIT,
618
+ PelTag::TRANSFER_FUNCTION,
619
+ PelTag::SOFTWARE,
620
+ PelTag::DATE_TIME,
621
+ PelTag::ARTIST,
622
+ PelTag::WHITE_POINT,
623
+ PelTag::PRIMARY_CHROMATICITIES,
624
+ PelTag::JPEG_INTERCHANGE_FORMAT,
625
+ PelTag::JPEG_INTERCHANGE_FORMAT_LENGTH,
626
+ PelTag::YCBCR_COEFFICIENTS,
627
+ PelTag::YCBCR_SUB_SAMPLING,
628
+ PelTag::YCBCR_POSITIONING,
629
+ PelTag::REFERENCE_BLACK_WHITE,
630
+ PelTag::COPYRIGHT,
631
+ PelTag::EXIF_IFD_POINTER,
632
+ PelTag::GPS_INFO_IFD_POINTER,
633
+ PelTag::PRINT_IM,
634
+ PelTag::XP_TITLE,
635
+ PelTag::XP_COMMENT,
636
+ PelTag::XP_AUTHOR,
637
+ PelTag::XP_KEYWORDS,
638
+ PelTag::XP_SUBJECT,
639
+ PelTag::RATING
640
+ );
641
+
642
+ case PelIfd::EXIF:
643
+ return array(
644
+ PelTag::EXPOSURE_TIME,
645
+ PelTag::FNUMBER,
646
+ PelTag::EXPOSURE_PROGRAM,
647
+ PelTag::SPECTRAL_SENSITIVITY,
648
+ PelTag::ISO_SPEED_RATINGS,
649
+ PelTag::OECF,
650
+ PelTag::EXIF_VERSION,
651
+ PelTag::DATE_TIME_ORIGINAL,
652
+ PelTag::DATE_TIME_DIGITIZED,
653
+ PelTag::COMPONENTS_CONFIGURATION,
654
+ PelTag::COMPRESSED_BITS_PER_PIXEL,
655
+ PelTag::SHUTTER_SPEED_VALUE,
656
+ PelTag::APERTURE_VALUE,
657
+ PelTag::BRIGHTNESS_VALUE,
658
+ PelTag::EXPOSURE_BIAS_VALUE,
659
+ PelTag::MAX_APERTURE_VALUE,
660
+ PelTag::SUBJECT_DISTANCE,
661
+ PelTag::METERING_MODE,
662
+ PelTag::LIGHT_SOURCE,
663
+ PelTag::FLASH,
664
+ PelTag::FOCAL_LENGTH,
665
+ PelTag::MAKER_NOTE,
666
+ PelTag::USER_COMMENT,
667
+ PelTag::SUB_SEC_TIME,
668
+ PelTag::SUB_SEC_TIME_ORIGINAL,
669
+ PelTag::SUB_SEC_TIME_DIGITIZED,
670
+ PelTag::FLASH_PIX_VERSION,
671
+ PelTag::COLOR_SPACE,
672
+ PelTag::PIXEL_X_DIMENSION,
673
+ PelTag::PIXEL_Y_DIMENSION,
674
+ PelTag::RELATED_SOUND_FILE,
675
+ PelTag::FLASH_ENERGY,
676
+ PelTag::SPATIAL_FREQUENCY_RESPONSE,
677
+ PelTag::FOCAL_PLANE_X_RESOLUTION,
678
+ PelTag::FOCAL_PLANE_Y_RESOLUTION,
679
+ PelTag::FOCAL_PLANE_RESOLUTION_UNIT,
680
+ PelTag::SUBJECT_LOCATION,
681
+ PelTag::EXPOSURE_INDEX,
682
+ PelTag::SENSING_METHOD,
683
+ PelTag::FILE_SOURCE,
684
+ PelTag::SCENE_TYPE,
685
+ PelTag::CFA_PATTERN,
686
+ PelTag::CUSTOM_RENDERED,
687
+ PelTag::EXPOSURE_MODE,
688
+ PelTag::WHITE_BALANCE,
689
+ PelTag::DIGITAL_ZOOM_RATIO,
690
+ PelTag::FOCAL_LENGTH_IN_35MM_FILM,
691
+ PelTag::SCENE_CAPTURE_TYPE,
692
+ PelTag::GAIN_CONTROL,
693
+ PelTag::CONTRAST,
694
+ PelTag::SATURATION,
695
+ PelTag::SHARPNESS,
696
+ PelTag::DEVICE_SETTING_DESCRIPTION,
697
+ PelTag::SUBJECT_DISTANCE_RANGE,
698
+ PelTag::IMAGE_UNIQUE_ID,
699
+ PelTag::INTEROPERABILITY_IFD_POINTER,
700
+ PelTag::GAMMA
701
+ );
702
+
703
+ case PelIfd::GPS:
704
+ return array(
705
+ PelTag::GPS_VERSION_ID,
706
+ PelTag::GPS_LATITUDE_REF,
707
+ PelTag::GPS_LATITUDE,
708
+ PelTag::GPS_LONGITUDE_REF,
709
+ PelTag::GPS_LONGITUDE,
710
+ PelTag::GPS_ALTITUDE_REF,
711
+ PelTag::GPS_ALTITUDE,
712
+ PelTag::GPS_TIME_STAMP,
713
+ PelTag::GPS_SATELLITES,
714
+ PelTag::GPS_STATUS,
715
+ PelTag::GPS_MEASURE_MODE,
716
+ PelTag::GPS_DOP,
717
+ PelTag::GPS_SPEED_REF,
718
+ PelTag::GPS_SPEED,
719
+ PelTag::GPS_TRACK_REF,
720
+ PelTag::GPS_TRACK,
721
+ PelTag::GPS_IMG_DIRECTION_REF,
722
+ PelTag::GPS_IMG_DIRECTION,
723
+ PelTag::GPS_MAP_DATUM,
724
+ PelTag::GPS_DEST_LATITUDE_REF,
725
+ PelTag::GPS_DEST_LATITUDE,
726
+ PelTag::GPS_DEST_LONGITUDE_REF,
727
+ PelTag::GPS_DEST_LONGITUDE,
728
+ PelTag::GPS_DEST_BEARING_REF,
729
+ PelTag::GPS_DEST_BEARING,
730
+ PelTag::GPS_DEST_DISTANCE_REF,
731
+ PelTag::GPS_DEST_DISTANCE,
732
+ PelTag::GPS_PROCESSING_METHOD,
733
+ PelTag::GPS_AREA_INFORMATION,
734
+ PelTag::GPS_DATE_STAMP,
735
+ PelTag::GPS_DIFFERENTIAL
736
+ );
737
+
738
+ case PelIfd::INTEROPERABILITY:
739
+ return array(
740
+ PelTag::INTEROPERABILITY_INDEX,
741
+ PelTag::INTEROPERABILITY_VERSION,
742
+ PelTag::RELATED_IMAGE_FILE_FORMAT,
743
+ PelTag::RELATED_IMAGE_WIDTH,
744
+ PelTag::RELATED_IMAGE_LENGTH
745
+ );
746
+
747
+ /*
748
+ * TODO: Where do these tags belong?
749
+ * PelTag::FILL_ORDER,
750
+ * PelTag::TRANSFER_RANGE,
751
+ * PelTag::JPEG_PROC,
752
+ * PelTag::BATTERY_LEVEL,
753
+ * PelTag::IPTC_NAA,
754
+ * PelTag::INTER_COLOR_PROFILE,
755
+ * PelTag::CFA_REPEAT_PATTERN_DIM,
756
+ */
757
+ }
758
+ }
759
+
760
+ /**
761
+ * Get the name of an IFD type.
762
+ *
763
+ * @param int $type
764
+ * one of {@link PelIfd::IFD0}, {@link PelIfd::IFD1},
765
+ * {@link PelIfd::EXIF}, {@link PelIfd::GPS}, or {@link
766
+ * PelIfd::INTEROPERABILITY}.
767
+ *
768
+ * @return string the name of type.
769
+ */
770
+ public static function getTypeName($type)
771
+ {
772
+ switch ($type) {
773
+ case self::IFD0:
774
+ return '0';
775
+ case self::IFD1:
776
+ return '1';
777
+ case self::EXIF:
778
+ return 'Exif';
779
+ case self::GPS:
780
+ return 'GPS';
781
+ case self::INTEROPERABILITY:
782
+ return 'Interoperability';
783
+ default:
784
+ throw new PelIfdException('Unknown IFD type: %d', $type);
785
+ }
786
+ }
787
+
788
+ /**
789
+ * Get the name of this directory.
790
+ *
791
+ * @return string the name of this directory.
792
+ */
793
+ public function getName()
794
+ {
795
+ return $this->getTypeName($this->type);
796
+ }
797
+
798
+ /**
799
+ * Adds an entry to the directory.
800
+ *
801
+ * @param PelEntry $e
802
+ * the entry that will be added. If the entry is not
803
+ * valid in this IFD (as per {@link isValidTag()}) an
804
+ * {@link PelInvalidDataException} is thrown.
805
+ *
806
+ * @todo The entry will be identified with its tag, so each
807
+ * directory can only contain one entry with each tag. Is this a
808
+ * bug?
809
+ */
810
+ public function addEntry(PelEntry $e)
811
+ {
812
+ if ($this->isValidTag($e->getTag())) {
813
+ $e->setIfdType($this->type);
814
+ $this->entries[$e->getTag()] = $e;
815
+ } else {
816
+ throw new PelInvalidDataException("IFD %s cannot hold\n%s", $this->getName(), $e->__toString());
817
+ }
818
+ }
819
+
820
+ /**
821
+ * Does a given tag exist in this IFD?
822
+ *
823
+ * This methods is part of the ArrayAccess SPL interface for
824
+ * overriding array access of objects, it allows you to check for
825
+ * existance of an entry in the IFD:
826
+ *
827
+ * <code>
828
+ * if (isset($ifd[PelTag::FNUMBER]))
829
+ * // ... do something with the F-number.
830
+ * </code>
831
+ *
832
+ * @param PelTag $tag
833
+ * the offset to check.
834
+ *
835
+ * @return boolean whether the tag exists.
836
+ */
837
+ public function offsetExists($tag)
838
+ {
839
+ return isset($this->entries[$tag]);
840
+ }
841
+
842
+ /**
843
+ * Retrieve a given tag from this IFD.
844
+ *
845
+ * This methods is part of the ArrayAccess SPL interface for
846
+ * overriding array access of objects, it allows you to read entries
847
+ * from the IFD the same was as for an array:
848
+ *
849
+ * <code>
850
+ * $entry = $ifd[PelTag::FNUMBER];
851
+ * </code>
852
+ *
853
+ * @param PelTag $tag
854
+ * the tag to return. It is an error to ask for a tag
855
+ * which is not in the IFD, just like asking for a non-existant
856
+ * array entry.
857
+ *
858
+ * @return PelEntry the entry.
859
+ */
860
+ public function offsetGet($tag)
861
+ {
862
+ return $this->entries[$tag];
863
+ }
864
+
865
+ /**
866
+ * Set or update a given tag in this IFD.
867
+ *
868
+ * This methods is part of the ArrayAccess SPL interface for
869
+ * overriding array access of objects, it allows you to add new
870
+ * entries or replace esisting entries by doing:
871
+ *
872
+ * <code>
873
+ * $ifd[PelTag::EXPOSURE_BIAS_VALUE] = $entry;
874
+ * </code>
875
+ *
876
+ * Note that the actual array index passed is ignored! Instead the
877
+ * {@link PelTag} from the entry is used.
878
+ *
879
+ * @param PelTag $tag
880
+ * the offset to update.
881
+ *
882
+ * @param PelEntry $e
883
+ * the new value.
884
+ */
885
+ public function offsetSet($tag, $e)
886
+ {
887
+ if ($e instanceof PelEntry) {
888
+ $tag = $e->getTag();
889
+ $this->entries[$tag] = $e;
890
+ } else {
891
+ throw new PelInvalidArgumentException('Argument "%s" must be a PelEntry.', $e);
892
+ }
893
+ }
894
+
895
+ /**
896
+ * Unset a given tag in this IFD.
897
+ *
898
+ * This methods is part of the ArrayAccess SPL interface for
899
+ * overriding array access of objects, it allows you to delete
900
+ * entries in the IFD by doing:
901
+ *
902
+ * <code>
903
+ * unset($ifd[PelTag::EXPOSURE_BIAS_VALUE])
904
+ * </code>
905
+ *
906
+ * @param PelTag $tag
907
+ * the offset to delete.
908
+ */
909
+ public function offsetUnset($tag)
910
+ {
911
+ unset($this->entries[$tag]);
912
+ }
913
+
914
+ /**
915
+ * Retrieve an entry.
916
+ *
917
+ * @param PelTag $tag
918
+ * the tag identifying the entry.
919
+ *
920
+ * @return PelEntry the entry associated with the tag, or null if no
921
+ * such entry exists.
922
+ */
923
+ public function getEntry($tag)
924
+ {
925
+ if (isset($this->entries[$tag])) {
926
+ return $this->entries[$tag];
927
+ } else {
928
+ return null;
929
+ }
930
+ }
931
+
932
+ /**
933
+ * Returns all entries contained in this IFD.
934
+ *
935
+ * @return array an array of {@link PelEntry} objects, or rather
936
+ * descendant classes. The array has {@link PelTag}s as keys
937
+ * and the entries as values.
938
+ *
939
+ * @see getEntry
940
+ * @see getIterator
941
+ */
942
+ public function getEntries()
943
+ {
944
+ return $this->entries;
945
+ }
946
+
947
+ /**
948
+ * Return an iterator for all entries contained in this IFD.
949
+ *
950
+ * Used with foreach as in
951
+ *
952
+ * <code>
953
+ * foreach ($ifd as $tag => $entry) {
954
+ * // $tag is now a PelTag and $entry is a PelEntry object.
955
+ * }
956
+ * </code>
957
+ *
958
+ * @return Iterator an iterator using the {@link PelTag tags} as
959
+ * keys and the entries as values.
960
+ */
961
+ public function getIterator()
962
+ {
963
+ return new \ArrayIterator($this->entries);
964
+ }
965
+
966
+ /**
967
+ * Returns available thumbnail data.
968
+ *
969
+ * @return string the bytes in the thumbnail, if any. If the IFD
970
+ * does not contain any thumbnail data, the empty string is
971
+ * returned.
972
+ *
973
+ * @todo Throw an exception instead when no data is available?
974
+ *
975
+ * @todo Return the $this->thumb_data object instead of the bytes?
976
+ */
977
+ public function getThumbnailData()
978
+ {
979
+ if ($this->thumb_data !== null) {
980
+ return $this->thumb_data->getBytes();
981
+ } else {
982
+ return '';
983
+ }
984
+ }
985
+
986
+ /**
987
+ * Make this directory point to a new directory.
988
+ *
989
+ * @param PelIfd $i
990
+ * the IFD that this directory will point to.
991
+ */
992
+ public function setNextIfd(PelIfd $i)
993
+ {
994
+ $this->next = $i;
995
+ }
996
+
997
+ /**
998
+ * Return the IFD pointed to by this directory.
999
+ *
1000
+ * @return PelIfd the next IFD, following this IFD. If this is the
1001
+ * last IFD, null is returned.
1002
+ */
1003
+ public function getNextIfd()
1004
+ {
1005
+ return $this->next;
1006
+ }
1007
+
1008
+ /**
1009
+ * Check if this is the last IFD.
1010
+ *
1011
+ * @return boolean true if there are no following IFD, false
1012
+ * otherwise.
1013
+ */
1014
+ public function isLastIfd()
1015
+ {
1016
+ return $this->next === null;
1017
+ }
1018
+
1019
+ /**
1020
+ * Add a sub-IFD.
1021
+ *
1022
+ * Any previous sub-IFD of the same type will be overwritten.
1023
+ *
1024
+ * @param PelIfd $sub
1025
+ * the sub IFD. The type of must be one of {@link
1026
+ * PelIfd::EXIF}, {@link PelIfd::GPS}, or {@link
1027
+ * PelIfd::INTEROPERABILITY}.
1028
+ */
1029
+ public function addSubIfd(PelIfd $sub)
1030
+ {
1031
+ $this->sub[$sub->type] = $sub;
1032
+ }
1033
+
1034
+ /**
1035
+ * Return a sub IFD.
1036
+ *
1037
+ * @param int $type
1038
+ * the type of the sub IFD. This must be one of {@link
1039
+ * PelIfd::EXIF}, {@link PelIfd::GPS}, or {@link
1040
+ * PelIfd::INTEROPERABILITY}.
1041
+ *
1042
+ * @return PelIfd the IFD associated with the type, or null if that
1043
+ * sub IFD does not exist.
1044
+ */
1045
+ public function getSubIfd($type)
1046
+ {
1047
+ if (isset($this->sub[$type])) {
1048
+ return $this->sub[$type];
1049
+ } else {
1050
+ return null;
1051
+ }
1052
+ }
1053
+
1054
+ /**
1055
+ * Get all sub IFDs.
1056
+ *
1057
+ * @return array an associative array with (IFD-type, {@link
1058
+ * PelIfd}) pairs.
1059
+ */
1060
+ public function getSubIfds()
1061
+ {
1062
+ return $this->sub;
1063
+ }
1064
+
1065
+ /**
1066
+ * Turn this directory into bytes.
1067
+ *
1068
+ * This directory will be turned into a byte string, with the
1069
+ * specified byte order. The offsets will be calculated from the
1070
+ * offset given.
1071
+ *
1072
+ * @param int $offset
1073
+ * the offset of the first byte of this directory.
1074
+ *
1075
+ * @param PelByteOrder $order
1076
+ * the byte order that should be used when
1077
+ * turning integers into bytes. This should be one of {@link
1078
+ * PelConvert::LITTLE_ENDIAN} and {@link PelConvert::BIG_ENDIAN}.
1079
+ */
1080
+ public function getBytes($offset, $order)
1081
+ {
1082
+ $bytes = '';
1083
+ $extra_bytes = '';
1084
+
1085
+ Pel::debug('Bytes from IDF will start at offset %d within Exif data', $offset);
1086
+
1087
+ $n = count($this->entries) + count($this->sub);
1088
+ if ($this->thumb_data !== null) {
1089
+ /*
1090
+ * We need two extra entries for the thumbnail offset and
1091
+ * length.
1092
+ */
1093
+ $n += 2;
1094
+ }
1095
+
1096
+ $bytes .= PelConvert::shortToBytes($n, $order);
1097
+
1098
+ /*
1099
+ * Initialize offset of extra data. This included the bytes
1100
+ * preceding this IFD, the bytes needed for the count of entries,
1101
+ * the entries themselves (and sub entries), the extra data in the
1102
+ * entries, and the IFD link.
1103
+ */
1104
+ $end = $offset + 2 + 12 * $n + 4;
1105
+
1106
+ foreach ($this->entries as $tag => $entry) {
1107
+ /* Each entry is 12 bytes long. */
1108
+ $bytes .= PelConvert::shortToBytes($entry->getTag(), $order);
1109
+ $bytes .= PelConvert::shortToBytes($entry->getFormat(), $order);
1110
+ $bytes .= PelConvert::longToBytes($entry->getComponents(), $order);
1111
+
1112
+ /*
1113
+ * Size? If bigger than 4 bytes, the actual data is not in
1114
+ * the entry but somewhere else.
1115
+ */
1116
+ $data = $entry->getBytes($order);
1117
+ $s = strlen($data);
1118
+ if ($s > 4) {
1119
+ Pel::debug('Data size %d too big, storing at offset %d instead.', $s, $end);
1120
+ $bytes .= PelConvert::longToBytes($end, $order);
1121
+ $extra_bytes .= $data;
1122
+ $end += $s;
1123
+ } else {
1124
+ Pel::debug('Data size %d fits.', $s);
1125
+ /*
1126
+ * Copy data directly, pad with NULL bytes as necessary to
1127
+ * fill out the four bytes available.
1128
+ */
1129
+ $bytes .= $data . str_repeat(chr(0), 4 - $s);
1130
+ }
1131
+ }
1132
+
1133
+ if ($this->thumb_data !== null) {
1134
+ Pel::debug('Appending %d bytes of thumbnail data at %d', $this->thumb_data->getSize(), $end);
1135
+ // TODO: make PelEntry a class that can be constructed with
1136
+ // arguments corresponding to the newt four lines.
1137
+ $bytes .= PelConvert::shortToBytes(PelTag::JPEG_INTERCHANGE_FORMAT_LENGTH, $order);
1138
+ $bytes .= PelConvert::shortToBytes(PelFormat::LONG, $order);
1139
+ $bytes .= PelConvert::longToBytes(1, $order);
1140
+ $bytes .= PelConvert::longToBytes($this->thumb_data->getSize(), $order);
1141
+
1142
+ $bytes .= PelConvert::shortToBytes(PelTag::JPEG_INTERCHANGE_FORMAT, $order);
1143
+ $bytes .= PelConvert::shortToBytes(PelFormat::LONG, $order);
1144
+ $bytes .= PelConvert::longToBytes(1, $order);
1145
+ $bytes .= PelConvert::longToBytes($end, $order);
1146
+
1147
+ $extra_bytes .= $this->thumb_data->getBytes();
1148
+ $end += $this->thumb_data->getSize();
1149
+ }
1150
+
1151
+ /* Find bytes from sub IFDs. */
1152
+ $sub_bytes = '';
1153
+ foreach ($this->sub as $type => $sub) {
1154
+ if ($type == PelIfd::EXIF) {
1155
+ $tag = PelTag::EXIF_IFD_POINTER;
1156
+ } elseif ($type == PelIfd::GPS) {
1157
+ $tag = PelTag::GPS_INFO_IFD_POINTER;
1158
+ } elseif ($type == PelIfd::INTEROPERABILITY) {
1159
+ $tag = PelTag::INTEROPERABILITY_IFD_POINTER;
1160
+ } else {
1161
+ // PelConvert::BIG_ENDIAN is the default used by PelConvert
1162
+ $tag = PelConvert::BIG_ENDIAN;
1163
+ }
1164
+ /* Make an aditional entry with the pointer. */
1165
+ $bytes .= PelConvert::shortToBytes($tag, $order);
1166
+ /* Next the format, which is always unsigned long. */
1167
+ $bytes .= PelConvert::shortToBytes(PelFormat::LONG, $order);
1168
+ /* There is only one component. */
1169
+ $bytes .= PelConvert::longToBytes(1, $order);
1170
+
1171
+ $data = $sub->getBytes($end, $order);
1172
+ $s = strlen($data);
1173
+ $sub_bytes .= $data;
1174
+
1175
+ $bytes .= PelConvert::longToBytes($end, $order);
1176
+ $end += $s;
1177
+ }
1178
+
1179
+ /* Make link to next IFD, if any */
1180
+ if ($this->isLastIFD()) {
1181
+ $link = 0;
1182
+ } else {
1183
+ $link = $end;
1184
+ }
1185
+
1186
+ Pel::debug('Link to next IFD: %d', $link);
1187
+
1188
+ $bytes .= PelConvert::longtoBytes($link, $order);
1189
+
1190
+ $bytes .= $extra_bytes . $sub_bytes;
1191
+
1192
+ if (! $this->isLastIfd()) {
1193
+ $bytes .= $this->next->getBytes($end, $order);
1194
+ }
1195
+ return $bytes;
1196
+ }
1197
+
1198
+ /**
1199
+ * Turn this directory into text.
1200
+ *
1201
+ * @return string information about the directory, mainly for
1202
+ * debugging.
1203
+ */
1204
+ public function __toString()
1205
+ {
1206
+ $str = Pel::fmt("Dumping IFD %s with %d entries...\n", $this->getName(), count($this->entries));
1207
+
1208
+ foreach ($this->entries as $entry) {
1209
+ $str .= $entry->__toString();
1210
+ }
1211
+ $str .= Pel::fmt("Dumping %d sub IFDs...\n", count($this->sub));
1212
+
1213
+ foreach ($this->sub as $type => $ifd) {
1214
+ $str .= $ifd->__toString();
1215
+ }
1216
+ if ($this->next !== null) {
1217
+ $str .= $this->next->__toString();
1218
+ }
1219
+ return $str;
1220
+ }
1221
+ }
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelIfdException.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * PEL: PHP Exif Library.
5
+ * A library with support for reading and
6
+ * writing all Exif headers in JPEG and TIFF images using PHP.
7
+ *
8
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008 Martin Geisler.
9
+ *
10
+ * This program is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program in the file COPYING; if not, write to the
22
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23
+ * Boston, MA 02110-1301 USA
24
+ */
25
+ namespace lsolesen\pel;
26
+
27
+ /**
28
+ * Classes for dealing with Exif IFDs.
29
+ *
30
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
31
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
32
+ * License (GPL)
33
+ * @package PEL
34
+ */
35
+
36
+ /**
37
+ * Exception indicating a general problem with the IFD.
38
+ *
39
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
40
+ * @package PEL
41
+ * @subpackage Exception
42
+ */
43
+ class PelIfdException extends PelException
44
+ {
45
+ // do nothing
46
+ }
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelInvalidArgumentException.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * PEL: PHP Exif Library.
5
+ * A library with support for reading and
6
+ * writing all Exif headers in JPEG and TIFF images using PHP.
7
+ *
8
+ * Copyright (C) 2004, 2005 Martin Geisler.
9
+ *
10
+ * This program is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program in the file COPYING; if not, write to the
22
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23
+ * Boston, MA 02110-1301 USA
24
+ */
25
+ namespace lsolesen\pel;
26
+
27
+ use lsolesen\pel\PelException;
28
+
29
+ /**
30
+ * Standard PEL exception.
31
+ *
32
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
33
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
34
+ * License (GPL)
35
+ * @package PEL
36
+ */
37
+
38
+ /**
39
+ * Exception throw if an invalid argument is passed.
40
+ *
41
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
42
+ * @package PEL
43
+ * @subpackage Exception
44
+ */
45
+ class PelInvalidArgumentException extends PelException
46
+ {
47
+ }
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelInvalidDataException.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * PEL: PHP Exif Library.
5
+ * A library with support for reading and
6
+ * writing all Exif headers in JPEG and TIFF images using PHP.
7
+ *
8
+ * Copyright (C) 2004, 2005 Martin Geisler.
9
+ *
10
+ * This program is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program in the file COPYING; if not, write to the
22
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23
+ * Boston, MA 02110-1301 USA
24
+ */
25
+ namespace lsolesen\pel;
26
+
27
+ use lsolesen\pel\PelException;
28
+
29
+ /**
30
+ * Standard PEL exception.
31
+ *
32
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
33
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
34
+ * License (GPL)
35
+ * @package PEL
36
+ */
37
+
38
+ /**
39
+ * Exception throw if invalid data is found.
40
+ *
41
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
42
+ * @package PEL
43
+ * @subpackage Exception
44
+ */
45
+ class PelInvalidDataException extends PelException
46
+ {
47
+ }
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelJpeg.php ADDED
@@ -0,0 +1,663 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * PEL: PHP Exif Library.
5
+ * A library with support for reading and
6
+ * writing all Exif headers in JPEG and TIFF images using PHP.
7
+ *
8
+ * Copyright (C) 2004, 2005, 2006, 2007 Martin Geisler.
9
+ *
10
+ * This program is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program in the file COPYING; if not, write to the
22
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23
+ * Boston, MA 02110-1301 USA
24
+ */
25
+
26
+ namespace lsolesen\pel;
27
+
28
+ /**
29
+ * Class for handling JPEG data.
30
+ *
31
+ * The {@link PelJpeg} class defined here provides an abstraction for
32
+ * dealing with a JPEG file. The file will be contain a number of
33
+ * sections containing some {@link PelJpegContent content} identified
34
+ * by a {@link PelJpegMarker marker}.
35
+ *
36
+ * The {@link getExif()} method is used get hold of the {@link
37
+ * PelJpegMarker::APP1 APP1} section which stores Exif data. So if
38
+ * the name of the JPEG file is stored in $filename, then one would
39
+ * get hold of the Exif data by saying:
40
+ *
41
+ * <code>
42
+ * $jpeg = new PelJpeg($filename);
43
+ * $exif = $jpeg->getExif();
44
+ * $tiff = $exif->getTiff();
45
+ * $ifd0 = $tiff->getIfd();
46
+ * $exif = $ifd0->getSubIfd(PelIfd::EXIF);
47
+ * $ifd1 = $ifd0->getNextIfd();
48
+ * </code>
49
+ *
50
+ * The $idf0 and $ifd1 variables will then be two {@link PelTiff TIFF}
51
+ * {@link PelIfd Image File Directories}, in which the data is stored
52
+ * under the keys found in {@link PelTag}.
53
+ *
54
+ * Should one have some image data (in the form of a {@link
55
+ * PelDataWindow}) of an unknown type, then the {@link
56
+ * PelJpeg::isValid()} function is handy: it will quickly test if the
57
+ * data could be valid JPEG data. The {@link PelTiff::isValid()}
58
+ * function does the same for TIFF images.
59
+ *
60
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
61
+ * @package PEL
62
+ */
63
+ class PelJpeg
64
+ {
65
+
66
+ /**
67
+ * The sections in the JPEG data.
68
+ *
69
+ * A JPEG file is built up as a sequence of sections, each section
70
+ * is identified with a {@link PelJpegMarker}. Some sections can
71
+ * occur more than once in the JPEG stream (the {@link
72
+ * PelJpegMarker::DQT DQT} and {@link PelJpegMarker::DHT DTH}
73
+ * markers for example) and so this is an array of ({@link
74
+ * PelJpegMarker}, {@link PelJpegContent}) pairs.
75
+ *
76
+ * The content can be either generic {@link PelJpegContent JPEG
77
+ * content} or {@link PelExif Exif data}.
78
+ *
79
+ * @var array
80
+ */
81
+ private $sections = array();
82
+
83
+ /**
84
+ * The JPEG image data.
85
+ *
86
+ * @var PelDataWindow
87
+ */
88
+ private $jpeg_data = null;
89
+
90
+ /**
91
+ * Construct a new JPEG object.
92
+ *
93
+ * The new object will be empty unless an argument is given from
94
+ * which it can initialize itself. This can either be the filename
95
+ * of a JPEG image, a {@link PelDataWindow} object or a PHP image
96
+ * resource handle.
97
+ *
98
+ * New Exif data (in the form of a {@link PelExif} object) can be
99
+ * inserted with the {@link setExif()} method:
100
+ *
101
+ * <code>
102
+ * $jpeg = new PelJpeg($data);
103
+ * // Create container for the Exif information:
104
+ * $exif = new PelExif();
105
+ * // Now Add a PelTiff object with a PelIfd object with one or more
106
+ * // PelEntry objects to $exif... Finally add $exif to $jpeg:
107
+ * $jpeg->setExif($exif);
108
+ * </code>
109
+ *
110
+ * @param
111
+ * mixed the data that this JPEG. This can either be a
112
+ * filename, a {@link PelDataWindow} object, or a PHP image resource
113
+ * handle.
114
+ */
115
+ public function __construct($data = false)
116
+ {
117
+ if ($data === false) {
118
+ return;
119
+ }
120
+
121
+ if (is_string($data)) {
122
+ Pel::debug('Initializing PelJpeg object from %s', $data);
123
+ $this->loadFile($data);
124
+ } elseif ($data instanceof PelDataWindow) {
125
+ Pel::debug('Initializing PelJpeg object from PelDataWindow.');
126
+ $this->load($data);
127
+ } elseif (is_resource($data) && get_resource_type($data) == 'gd') {
128
+ Pel::debug('Initializing PelJpeg object from image resource.');
129
+ $this->load(new PelDataWindow($data));
130
+ } else {
131
+ throw new PelInvalidArgumentException('Bad type for $data: %s', gettype($data));
132
+ }
133
+ }
134
+
135
+ /**
136
+ * JPEG sections start with 0xFF. The first byte that is not
137
+ * 0xFF is a marker (hopefully).
138
+ *
139
+ * @param PelDataWindow $d
140
+ *
141
+ * @return integer
142
+ */
143
+ protected static function getJpgSectionStart($d)
144
+ {
145
+ for ($i = 0; $i < 7; $i ++) {
146
+ if ($d->getByte($i) != 0xFF) {
147
+ break;
148
+ }
149
+ }
150
+ return $i;
151
+ }
152
+
153
+ /**
154
+ * Load data into a JPEG object.
155
+ *
156
+ * The data supplied will be parsed and turned into an object
157
+ * structure representing the image. This structure can then be
158
+ * manipulated and later turned back into an string of bytes.
159
+ *
160
+ * This methods can be called at any time after a JPEG object has
161
+ * been constructed, also after the {@link appendSection()} has been
162
+ * called to append custom sections. Loading several JPEG images
163
+ * into one object will accumulate the sections, but there will only
164
+ * be one {@link PelJpegMarker::SOS} section at any given time.
165
+ *
166
+ * @param
167
+ * PelDataWindow the data that will be turned into JPEG
168
+ * sections.
169
+ */
170
+ public function load(PelDataWindow $d)
171
+ {
172
+ Pel::debug('Parsing %d bytes...', $d->getSize());
173
+
174
+ /* JPEG data is stored in big-endian format. */
175
+ $d->setByteOrder(PelConvert::BIG_ENDIAN);
176
+
177
+ /*
178
+ * Run through the data to read the sections in the image. After
179
+ * each section is read, the start of the data window will be
180
+ * moved forward, and after the last section we'll terminate with
181
+ * no data left in the window.
182
+ */
183
+ while ($d->getSize() > 0) {
184
+ $i = $this->getJpgSectionStart($d);
185
+
186
+ $marker = $d->getByte($i);
187
+
188
+ if (!PelJpegMarker::isValid($marker)) {
189
+ throw new PelJpegInvalidMarkerException($marker, $i);
190
+ }
191
+
192
+ /*
193
+ * Move window so first byte becomes first byte in this
194
+ * section.
195
+ */
196
+ $d->setWindowStart($i + 1);
197
+
198
+ if ($marker == PelJpegMarker::SOI || $marker == PelJpegMarker::EOI) {
199
+ $content = new PelJpegContent(new PelDataWindow());
200
+ $this->appendSection($marker, $content);
201
+ } else {
202
+ /*
203
+ * Read the length of the section. The length includes the
204
+ * two bytes used to store the length.
205
+ */
206
+ $len = $d->getShort(0) - 2;
207
+
208
+ Pel::debug('Found %s section of length %d', PelJpegMarker::getName($marker), $len);
209
+
210
+ /* Skip past the length. */
211
+ $d->setWindowStart(2);
212
+
213
+ if ($marker == PelJpegMarker::APP1) {
214
+ try {
215
+ $content = new PelExif();
216
+ $content->load($d->getClone(0, $len));
217
+ } catch (PelInvalidDataException $e) {
218
+ /*
219
+ * We store the data as normal JPEG content if it could
220
+ * not be parsed as Exif data.
221
+ */
222
+ $content = new PelJpegContent($d->getClone(0, $len));
223
+ }
224
+
225
+ $this->appendSection($marker, $content);
226
+ /* Skip past the data. */
227
+ $d->setWindowStart($len);
228
+ } elseif ($marker == PelJpegMarker::COM) {
229
+ $content = new PelJpegComment();
230
+ $content->load($d->getClone(0, $len));
231
+ $this->appendSection($marker, $content);
232
+ $d->setWindowStart($len);
233
+ } else {
234
+ $content = new PelJpegContent($d->getClone(0, $len));
235
+ $this->appendSection($marker, $content);
236
+ /* Skip past the data. */
237
+ $d->setWindowStart($len);
238
+
239
+ /* In case of SOS, image data will follow. */
240
+ if ($marker == PelJpegMarker::SOS) {
241
+ /*
242
+ * Some images have some trailing (garbage?) following the
243
+ * EOI marker. To handle this we seek backwards until we
244
+ * find the EOI marker. Any trailing content is stored as
245
+ * a PelJpegContent object.
246
+ */
247
+
248
+ $length = $d->getSize();
249
+ while ($d->getByte($length - 2) != 0xFF || $d->getByte($length - 1) != PelJpegMarker::EOI) {
250
+ $length --;
251
+ }
252
+
253
+ $this->jpeg_data = $d->getClone(0, $length - 2);
254
+ Pel::debug('JPEG data: ' . $this->jpeg_data->__toString());
255
+
256
+ /* Append the EOI. */
257
+ $this->appendSection(PelJpegMarker::EOI, new PelJpegContent(new PelDataWindow()));
258
+
259
+ /* Now check to see if there are any trailing data. */
260
+ if ($length != $d->getSize()) {
261
+ Pel::maybeThrow(new PelException('Found trailing content ' . 'after EOI: %d bytes', $d->getSize() - $length));
262
+ $content = new PelJpegContent($d->getClone($length));
263
+ /*
264
+ * We don't have a proper JPEG marker for trailing
265
+ * garbage, so we just use 0x00...
266
+ */
267
+ $this->appendSection(0x00, $content);
268
+ }
269
+
270
+ /* Done with the loop. */
271
+ break;
272
+ }
273
+ }
274
+ }
275
+ } /* while ($d->getSize() > 0) */
276
+ }
277
+
278
+ /**
279
+ * Load data from a file into a JPEG object.
280
+ *
281
+ * @param
282
+ * string the filename. This must be a readable file.
283
+ */
284
+ public function loadFile($filename)
285
+ {
286
+ $this->load(new PelDataWindow(file_get_contents($filename)));
287
+ }
288
+
289
+ /**
290
+ * Set Exif data.
291
+ *
292
+ * Use this to set the Exif data in the image. This will overwrite
293
+ * any old Exif information in the image.
294
+ *
295
+ * @param
296
+ * PelExif the Exif data.
297
+ */
298
+ public function setExif(PelExif $exif)
299
+ {
300
+ $app0_offset = 1;
301
+ $app1_offset = - 1;
302
+
303
+ /* Search through all sections looking for APP0 or APP1. */
304
+ $sections_count = count($this->sections);
305
+ for ($i = 0; $i < $sections_count; $i ++) {
306
+ if (! empty($this->sections[$i][0])) {
307
+ if ($this->sections[$i][0] == PelJpegMarker::APP0) {
308
+ $app0_offset = $i;
309
+ } elseif ($this->sections[$i][0] == PelJpegMarker::APP1) {
310
+ $app1_offset = $i;
311
+ break;
312
+ }
313
+ }
314
+ }
315
+
316
+ /*
317
+ * Store the Exif data at the appropriate place, either where the
318
+ * old Exif data was stored ($app1_offset) or right after APP0
319
+ * ($app0_offset+1).
320
+ */
321
+ if ($app1_offset > 0) {
322
+ $this->sections[$app1_offset][1] = $exif;
323
+ } else {
324
+ $this->insertSection(PelJpegMarker::APP1, $exif, $app0_offset + 1);
325
+ }
326
+ }
327
+
328
+ /**
329
+ * Set ICC data.
330
+ *
331
+ * Use this to set the ICC data in the image. This will overwrite
332
+ * any old ICC information in the image.
333
+ *
334
+ * @param
335
+ * PelJpegContent the ICC data.
336
+ */
337
+ public function setICC(PelJpegContent $icc)
338
+ {
339
+ $app1_offset = 1;
340
+ $app2_offset = - 1;
341
+
342
+ /* Search through all sections looking for APP0 or APP1. */
343
+ $count_sections = count($this->sections);
344
+ for ($i = 0; $i < $count_sections; $i ++) {
345
+ if (! empty($this->sections[$i][0])) {
346
+ if ($this->sections[$i][0] == PelJpegMarker::APP1) {
347
+ $app1_offset = $i;
348
+ } elseif ($this->sections[$i][0] == PelJpegMarker::APP2) {
349
+ $app2_offset = $i;
350
+ break;
351
+ }
352
+ }
353
+ }
354
+
355
+ /*
356
+ * Store the Exif data at the appropriate place, either where the
357
+ * old Exif data was stored ($app1_offset) or right after APP0
358
+ * ($app0_offset+1).
359
+ */
360
+ if ($app2_offset > 0) {
361
+ $this->sections[$app1_offset][1] = $icc;
362
+ } else {
363
+ $this->insertSection(PelJpegMarker::APP2, $icc, $app1_offset + 1);
364
+ }
365
+ }
366
+
367
+ /**
368
+ * Get Exif data.
369
+ *
370
+ * Use this to get the @{link PelExif Exif data} stored.
371
+ *
372
+ * @return PelExif the Exif data found or null if the image has no
373
+ * Exif data.
374
+ */
375
+ public function getExif()
376
+ {
377
+ $exif = $this->getSection(PelJpegMarker::APP1);
378
+ if ($exif instanceof PelExif) {
379
+ return $exif;
380
+ }
381
+ return null;
382
+ }
383
+
384
+ /**
385
+ * Get ICC data.
386
+ *
387
+ * Use this to get the @{link PelJpegContent ICC data} stored.
388
+ *
389
+ * @return PelJpegContent the ICC data found or null if the image has no
390
+ * ICC data.
391
+ */
392
+ public function getICC()
393
+ {
394
+ $icc = $this->getSection(PelJpegMarker::APP2);
395
+ if ($icc instanceof PelJpegContent) {
396
+ return $icc;
397
+ }
398
+ return null;
399
+ }
400
+
401
+ /**
402
+ * Clear any Exif data.
403
+ *
404
+ * This method will only clear the first @{link PelJpegMarker::APP1}
405
+ * section found (there should normally be just one).
406
+ */
407
+ public function clearExif()
408
+ {
409
+ $sections_count = count($this->sections);
410
+ for ($i = 0; $i < $sections_count; $i ++) {
411
+ if ($this->sections[$i][0] == PelJpegMarker::APP1) {
412
+ unset($this->sections[$i]);
413
+ return;
414
+ }
415
+ }
416
+ }
417
+
418
+ /**
419
+ * Append a new section.
420
+ *
421
+ * Used only when loading an image. If it used again later, then the
422
+ * section will end up after the @{link PelJpegMarker::EOI EOI
423
+ * marker} and will probably not be useful.
424
+ *
425
+ * Please use @{link setExif()} instead if you intend to add Exif
426
+ * information to an image as that function will know the right
427
+ * place to insert the data.
428
+ *
429
+ * @param
430
+ * PelJpegMarker the marker identifying the new section.
431
+ *
432
+ * @param
433
+ * PelJpegContent the content of the new section.
434
+ */
435
+ public function appendSection($marker, PelJpegContent $content)
436
+ {
437
+ $this->sections[] = array(
438
+ $marker,
439
+ $content
440
+ );
441
+ }
442
+
443
+ /**
444
+ * Insert a new section.
445
+ *
446
+ * Please use @{link setExif()} instead if you intend to add Exif
447
+ * information to an image as that function will know the right
448
+ * place to insert the data.
449
+ *
450
+ * @param
451
+ * PelJpegMarker the marker for the new section.
452
+ *
453
+ * @param
454
+ * PelJpegContent the content of the new section.
455
+ *
456
+ * @param
457
+ * int the offset where the new section will be inserted ---
458
+ * use 0 to insert it at the very beginning, use 1 to insert it
459
+ * between sections 1 and 2, etc.
460
+ */
461
+ public function insertSection($marker, PelJpegContent $content, $offset)
462
+ {
463
+ array_splice($this->sections, $offset, 0, array(
464
+ array(
465
+ $marker,
466
+ $content
467
+ )
468
+ ));
469
+ }
470
+
471
+ /**
472
+ * Get a section corresponding to a particular marker.
473
+ *
474
+ * Please use the {@link getExif()} if you just need the Exif data.
475
+ *
476
+ * This will search through the sections of this JPEG object,
477
+ * looking for a section identified with the specified {@link
478
+ * PelJpegMarker marker}. The {@link PelJpegContent content} will
479
+ * then be returned. The optional argument can be used to skip over
480
+ * some of the sections. So if one is looking for the, say, third
481
+ * {@link PelJpegMarker::DHT DHT} section one would do:
482
+ *
483
+ * <code>
484
+ * $dht3 = $jpeg->getSection(PelJpegMarker::DHT, 2);
485
+ * </code>
486
+ *
487
+ * @param
488
+ * PelJpegMarker the marker identifying the section.
489
+ *
490
+ * @param
491
+ * int the number of sections to be skipped. This must be a
492
+ * non-negative integer.
493
+ *
494
+ * @return PelJpegContent the content found, or null if there is no
495
+ * content available.
496
+ */
497
+ public function getSection($marker, $skip = 0)
498
+ {
499
+ foreach ($this->sections as $s) {
500
+ if ($s[0] == $marker) {
501
+ if ($skip > 0) {
502
+ $skip --;
503
+ } else {
504
+ return $s[1];
505
+ }
506
+ }
507
+ }
508
+
509
+ return null;
510
+ }
511
+
512
+ /**
513
+ * Get all sections.
514
+ *
515
+ * @return array an array of ({@link PelJpegMarker}, {@link
516
+ * PelJpegContent}) pairs. Each pair is an array with the {@link
517
+ * PelJpegMarker} as the first element and the {@link
518
+ * PelJpegContent} as the second element, so the return type is an
519
+ * array of arrays.
520
+ *
521
+ * So to loop through all the sections in a given JPEG image do
522
+ * this:
523
+ *
524
+ * <code>
525
+ * foreach ($jpeg->getSections() as $section) {
526
+ * $marker = $section[0];
527
+ * $content = $section[1];
528
+ * // Use $marker and $content here.
529
+ * }
530
+ * </code>
531
+ *
532
+ * instead of this:
533
+ *
534
+ * <code>
535
+ * foreach ($jpeg->getSections() as $marker => $content) {
536
+ * // Does not work the way you would think...
537
+ * }
538
+ * </code>
539
+ *
540
+ * The problem is that there could be several sections with the same
541
+ * marker, and thus a simple associative array does not suffice.
542
+ */
543
+ public function getSections()
544
+ {
545
+ return $this->sections;
546
+ }
547
+
548
+ /**
549
+ * Turn this JPEG object into bytes.
550
+ *
551
+ * The bytes returned by this method is ready to be stored in a file
552
+ * as a valid JPEG image. Use the {@link saveFile()} convenience
553
+ * method to do this.
554
+ *
555
+ * @return string bytes representing this JPEG object, including all
556
+ * its sections and their associated data.
557
+ */
558
+ public function getBytes()
559
+ {
560
+ $bytes = '';
561
+
562
+ foreach ($this->sections as $section) {
563
+ $m = $section[0];
564
+ $c = $section[1];
565
+
566
+ /* Write the marker */
567
+ $bytes .= "\xFF" . PelJpegMarker::getBytes($m);
568
+ /* Skip over empty markers. */
569
+ if ($m == PelJpegMarker::SOI || $m == PelJpegMarker::EOI) {
570
+ continue;
571
+ }
572
+
573
+ $data = $c->getBytes();
574
+ $size = strlen($data) + 2;
575
+
576
+ $bytes .= PelConvert::shortToBytes($size, PelConvert::BIG_ENDIAN);
577
+ $bytes .= $data;
578
+
579
+ /* In case of SOS, we need to write the JPEG data. */
580
+ if ($m == PelJpegMarker::SOS) {
581
+ $bytes .= $this->jpeg_data->getBytes();
582
+ }
583
+ }
584
+
585
+ return $bytes;
586
+ }
587
+
588
+ /**
589
+ * Save the JPEG object as a JPEG image in a file.
590
+ *
591
+ * @param
592
+ * string the filename to save in. An existing file with the
593
+ * same name will be overwritten!
594
+ *
595
+ * @return integer|FALSE The number of bytes that were written to the
596
+ * file, or FALSE on failure.
597
+ */
598
+ public function saveFile($filename)
599
+ {
600
+ return file_put_contents($filename, $this->getBytes());
601
+ }
602
+
603
+ /**
604
+ * Make a string representation of this JPEG object.
605
+ *
606
+ * This is mainly usefull for debugging. It will show the structure
607
+ * of the image, and its sections.
608
+ *
609
+ * @return string debugging information about this JPEG object.
610
+ */
611
+ public function __toString()
612
+ {
613
+ $str = Pel::tra("Dumping JPEG data...\n");
614
+ $count_sections = count($this->sections);
615
+ for ($i = 0; $i < $count_sections; $i ++) {
616
+ $m = $this->sections[$i][0];
617
+ $c = $this->sections[$i][1];
618
+ $str .= Pel::fmt("Section %d (marker 0x%02X - %s):\n", $i, $m, PelJpegMarker::getName($m));
619
+ $str .= Pel::fmt(" Description: %s\n", PelJpegMarker::getDescription($m));
620
+
621
+ if ($m == PelJpegMarker::SOI || $m == PelJpegMarker::EOI) {
622
+ continue;
623
+ }
624
+
625
+ if ($c instanceof PelExif) {
626
+ $str .= Pel::tra(" Content : Exif data\n");
627
+ $str .= $c->__toString() . "\n";
628
+ } elseif ($c instanceof PelJpegComment) {
629
+ $str .= Pel::fmt(" Content : %s\n", $c->getValue());
630
+ } else {
631
+ $str .= Pel::tra(" Content : Unknown\n");
632
+ }
633
+ }
634
+
635
+ return $str;
636
+ }
637
+
638
+ /**
639
+ * Test data to see if it could be a valid JPEG image.
640
+ *
641
+ * The function will only look at the first few bytes of the data,
642
+ * and try to determine if it could be a valid JPEG image based on
643
+ * those bytes. This means that the check is more like a heuristic
644
+ * than a rigorous check.
645
+ *
646
+ * @param
647
+ * PelDataWindow the bytes that will be checked.
648
+ *
649
+ * @return boolean true if the bytes look like the beginning of a
650
+ * JPEG image, false otherwise.
651
+ *
652
+ * @see PelTiff::isValid()
653
+ */
654
+ public static function isValid(PelDataWindow $d)
655
+ {
656
+ /* JPEG data is stored in big-endian format. */
657
+ $d->setByteOrder(PelConvert::BIG_ENDIAN);
658
+
659
+ $i = self::getJpgSectionStart($d);
660
+
661
+ return $d->getByte($i) == PelJpegMarker::SOI;
662
+ }
663
+ }
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelJpegComment.php ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * PEL: PHP Exif Library.
5
+ * A library with support for reading and
6
+ * writing all Exif headers in JPEG and TIFF images using PHP.
7
+ *
8
+ * Copyright (C) 2005, 2007 Martin Geisler.
9
+ *
10
+ * This program is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program in the file COPYING; if not, write to the
22
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23
+ * Boston, MA 02110-1301 USA
24
+ */
25
+ namespace lsolesen\pel;
26
+
27
+ /**
28
+ * Class for dealing with JPEG comments.
29
+ *
30
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
31
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
32
+ * License (GPL)
33
+ * @package PEL
34
+ */
35
+
36
+ /**
37
+ * Class representing JPEG comments.
38
+ *
39
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
40
+ * @package PEL
41
+ */
42
+ class PelJpegComment extends PelJpegContent
43
+ {
44
+
45
+ /**
46
+ * The comment.
47
+ *
48
+ * @var string
49
+ */
50
+ private $comment = '';
51
+
52
+ /**
53
+ * Construct a new JPEG comment.
54
+ *
55
+ * The new comment will contain the string given.
56
+ *
57
+ * @param string $comment
58
+ */
59
+ public function __construct($comment = '')
60
+ {
61
+ $this->comment = $comment;
62
+ }
63
+
64
+ /**
65
+ * Load and parse data.
66
+ *
67
+ * This will load the comment from the data window passed.
68
+ *
69
+ * @param PelDataWindow $d
70
+ */
71
+ public function load(PelDataWindow $d)
72
+ {
73
+ $this->comment = $d->getBytes();
74
+ }
75
+
76
+ /**
77
+ * Update the value with a new comment.
78
+ *
79
+ * Any old comment will be overwritten.
80
+ *
81
+ * @param string $comment
82
+ * the new comment.
83
+ */
84
+ public function setValue($comment)
85
+ {
86
+ $this->comment = $comment;
87
+ }
88
+
89
+ /**
90
+ * Get the comment.
91
+ *
92
+ * @return string the comment.
93
+ */
94
+ public function getValue()
95
+ {
96
+ return $this->comment;
97
+ }
98
+
99
+ /**
100
+ * Turn this comment into bytes.
101
+ *
102
+ * @return string bytes representing this comment.
103
+ */
104
+ public function getBytes()
105
+ {
106
+ return $this->comment;
107
+ }
108
+
109
+ /**
110
+ * Return a string representation of this object.
111
+ *
112
+ * @return string the same as {@link getValue()}.
113
+ */
114
+ public function __toString()
115
+ {
116
+ return $this->getValue();
117
+ }
118
+ }
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelJpegContent.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * PEL: PHP Exif Library.
5
+ * A library with support for reading and
6
+ * writing all Exif headers in JPEG and TIFF images using PHP.
7
+ *
8
+ * Copyright (C) 2004, 2005 Martin Geisler.
9
+ *
10
+ * This program is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program in the file COPYING; if not, write to the
22
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23
+ * Boston, MA 02110-1301 USA
24
+ */
25
+ namespace lsolesen\pel;
26
+
27
+ use \lsolesen\pel\PelDataWindow;
28
+
29
+ /**
30
+ * Class representing content in a JPEG file.
31
+ *
32
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
33
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
34
+ * License (GPL)
35
+ * @package PEL
36
+ */
37
+
38
+ /**
39
+ * Class representing content in a JPEG file.
40
+ *
41
+ * A JPEG file consists of a sequence of each of which has an
42
+ * associated {@link PelJpegMarker marker} and some content. This
43
+ * class represents the content, and this basic type is just a simple
44
+ * holder of such content, represented by a {@link PelDataWindow}
45
+ * object. The {@link PelExif} class is an example of more
46
+ * specialized JPEG content.
47
+ *
48
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
49
+ * @package PEL
50
+ */
51
+ class PelJpegContent
52
+ {
53
+
54
+ private $data = null;
55
+
56
+ /**
57
+ * Make a new piece of JPEG content.
58
+ *
59
+ * @param PelDataWindow $data
60
+ * the content.
61
+ */
62
+ public function __construct(PelDataWindow $data)
63
+ {
64
+ $this->data = $data;
65
+ }
66
+
67
+ /**
68
+ * Return the bytes of the content.
69
+ *
70
+ * @return string bytes representing this JPEG content. These bytes
71
+ * will match the bytes given to {@link __construct the
72
+ * constructor}.
73
+ */
74
+ public function getBytes()
75
+ {
76
+ return $this->data->getBytes();
77
+ }
78
+ }
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelJpegInvalidMarkerException.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * PEL: PHP Exif Library.
4
+ * A library with support for reading and
5
+ * writing all Exif headers in JPEG and TIFF images using PHP.
6
+ *
7
+ * Copyright (C) 2004, 2005, 2006, 2007 Martin Geisler.
8
+ *
9
+ * This program is free software; you can redistribute it and/or modify
10
+ * it under the terms of the GNU General Public License as published by
11
+ * the Free Software Foundation; either version 2 of the License, or
12
+ * (at your option) any later version.
13
+ *
14
+ * This program is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ * GNU General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU General Public License
20
+ * along with this program in the file COPYING; if not, write to the
21
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
22
+ * Boston, MA 02110-1301 USA
23
+ */
24
+ namespace lsolesen\pel;
25
+
26
+ /**
27
+ * Exception thrown when an invalid marker is found.
28
+ *
29
+ * This exception is thrown when PEL expects to find a {@link
30
+ * PelJpegMarker} and instead finds a byte that isn't a known marker.
31
+ *
32
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
33
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public License (GPL)
34
+ * @package PEL
35
+ * @subpackage Exception
36
+ */
37
+ class PelJpegInvalidMarkerException extends PelException
38
+ {
39
+
40
+ /**
41
+ * Construct a new invalid marker exception.
42
+ * The exception will contain a message describing the error,
43
+ * including the byte found and the offset of the offending byte.
44
+ *
45
+ * @param int $marker
46
+ * the byte found.
47
+ *
48
+ * @param int $offset
49
+ * the offset in the data.
50
+ */
51
+ public function __construct($marker, $offset)
52
+ {
53
+ parent::__construct('Invalid marker found at offset %d: 0x%2X', $offset, $marker);
54
+ }
55
+ }
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelJpegMarker.php ADDED
@@ -0,0 +1,542 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * PEL: PHP Exif Library.
5
+ * A library with support for reading and
6
+ * writing all Exif headers in JPEG and TIFF images using PHP.
7
+ *
8
+ * Copyright (C) 2004, 2006 Martin Geisler.
9
+ * Copyright (C) 2017 Johannes Weberhofer.
10
+ *
11
+ * This program is free software; you can redistribute it and/or modify
12
+ * it under the terms of the GNU General Public License as published by
13
+ * the Free Software Foundation; either version 2 of the License, or
14
+ * (at your option) any later version.
15
+ *
16
+ * This program is distributed in the hope that it will be useful,
17
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
+ * GNU General Public License for more details.
20
+ *
21
+ * You should have received a copy of the GNU General Public License
22
+ * along with this program in the file COPYING; if not, write to the
23
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
24
+ * Boston, MA 02110-1301 USA
25
+ */
26
+ namespace lsolesen\pel;
27
+
28
+ /**
29
+ * Classes for dealing with JPEG markers.
30
+ *
31
+ * This class defines the constants to be used whenever one refers to
32
+ * a JPEG marker. All the methods defined are static, and they all
33
+ * operate on one argument which should be one of the class constants.
34
+ * They will all be denoted by PelJpegMarker in the documentation.
35
+ *
36
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
37
+ * @author Johannes Weberhofer <jweberhofer@weberhofer.at>
38
+ *
39
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
40
+ * License (GPL)
41
+ * @package PEL
42
+ */
43
+ class PelJpegMarker
44
+ {
45
+
46
+ /**
47
+ * Encoding (baseline)
48
+ */
49
+ const SOF0 = 0xC0;
50
+
51
+ /**
52
+ * Encoding (extended sequential)
53
+ */
54
+ const SOF1 = 0xC1;
55
+
56
+ /**
57
+ * Encoding (progressive)
58
+ */
59
+ const SOF2 = 0xC2;
60
+
61
+ /**
62
+ * Encoding (lossless)
63
+ */
64
+ const SOF3 = 0xC3;
65
+
66
+ /**
67
+ * Define Huffman table
68
+ */
69
+ const DHT = 0xC4;
70
+
71
+ /**
72
+ * Encoding (differential sequential)
73
+ */
74
+ const SOF5 = 0xC5;
75
+
76
+ /**
77
+ * Encoding (differential progressive)
78
+ */
79
+ const SOF6 = 0xC6;
80
+
81
+ /**
82
+ * Encoding (differential lossless)
83
+ */
84
+ const SOF7 = 0xC7;
85
+
86
+ /**
87
+ * Extension
88
+ */
89
+ const JPG = 0xC8;
90
+
91
+ /**
92
+ * Encoding (extended sequential, arithmetic)
93
+ */
94
+ const SOF9 = 0xC9;
95
+
96
+ /**
97
+ * Encoding (progressive, arithmetic)
98
+ */
99
+ const SOF10 = 0xCA;
100
+
101
+ /**
102
+ * Encoding (lossless, arithmetic)
103
+ */
104
+ const SOF11 = 0xCB;
105
+
106
+ /**
107
+ * Define arithmetic coding conditioning
108
+ */
109
+ const DAC = 0xCC;
110
+
111
+ /**
112
+ * Encoding (differential sequential, arithmetic)
113
+ */
114
+ const SOF13 = 0xCD;
115
+
116
+ /**
117
+ * Encoding (differential progressive, arithmetic)
118
+ */
119
+ const SOF14 = 0xCE;
120
+
121
+ /**
122
+ * Encoding (differential lossless, arithmetic)
123
+ */
124
+ const SOF15 = 0xCF;
125
+
126
+ /**
127
+ * Restart 0
128
+ */
129
+ const RST0 = 0xD0;
130
+
131
+ /**
132
+ * Restart 1
133
+ */
134
+ const RST1 = 0xD1;
135
+
136
+ /**
137
+ * Restart 2
138
+ */
139
+ const RST2 = 0xD2;
140
+
141
+ /**
142
+ * Restart 3
143
+ */
144
+ const RST3 = 0xD3;
145
+
146
+ /**
147
+ * Restart 4
148
+ */
149
+ const RST4 = 0xD4;
150
+
151
+ /**
152
+ * Restart 5
153
+ */
154
+ const RST5 = 0xD5;
155
+
156
+ /**
157
+ * Restart 6
158
+ */
159
+ const RST6 = 0xD6;
160
+
161
+ /**
162
+ * Restart 7
163
+ */
164
+ const RST7 = 0xD7;
165
+
166
+ /**
167
+ * Start of image
168
+ */
169
+ const SOI = 0xD8;
170
+
171
+ /**
172
+ * End of image
173
+ */
174
+ const EOI = 0xD9;
175
+
176
+ /**
177
+ * Start of scan
178
+ */
179
+ const SOS = 0xDA;
180
+
181
+ /**
182
+ * Define quantization table
183
+ */
184
+ const DQT = 0xDB;
185
+
186
+ /**
187
+ * Define number of lines
188
+ */
189
+ const DNL = 0xDC;
190
+
191
+ /**
192
+ * Define restart interval
193
+ */
194
+ const DRI = 0xDD;
195
+
196
+ /**
197
+ * Define hierarchical progression
198
+ */
199
+ const DHP = 0xDE;
200
+
201
+ /**
202
+ * Expand reference component
203
+ */
204
+ const EXP = 0xDF;
205
+
206
+ /**
207
+ * Application segment 0
208
+ */
209
+ const APP0 = 0xE0;
210
+
211
+ /**
212
+ * Application segment 1
213
+ *
214
+ * When a JPEG image contains Exif data, the data will normally be
215
+ * stored in this section and a call to {@link PelJpeg::getExif()}
216
+ * will return a {@link PelExif} object representing it.
217
+ */
218
+ const APP1 = 0xE1;
219
+
220
+ /**
221
+ * Application segment 2
222
+ */
223
+ const APP2 = 0xE2;
224
+
225
+ /**
226
+ * Application segment 3
227
+ */
228
+ const APP3 = 0xE3;
229
+
230
+ /**
231
+ * Application segment 4
232
+ */
233
+ const APP4 = 0xE4;
234
+
235
+ /**
236
+ * Application segment 5
237
+ */
238
+ const APP5 = 0xE5;
239
+
240
+ /**
241
+ * Application segment 6
242
+ */
243
+ const APP6 = 0xE6;
244
+
245
+ /**
246
+ * Application segment 7
247
+ */
248
+ const APP7 = 0xE7;
249
+
250
+ /**
251
+ * Application segment 8
252
+ */
253
+ const APP8 = 0xE8;
254
+
255
+ /**
256
+ * Application segment 9
257
+ */
258
+ const APP9 = 0xE9;
259
+
260
+ /**
261
+ * Application segment 10
262
+ */
263
+ const APP10 = 0xEA;
264
+
265
+ /**
266
+ * Application segment 11
267
+ */
268
+ const APP11 = 0xEB;
269
+
270
+ /**
271
+ * Application segment 12
272
+ */
273
+ const APP12 = 0xEC;
274
+
275
+ /**
276
+ * Application segment 13
277
+ */
278
+ const APP13 = 0xED;
279
+
280
+ /**
281
+ * Application segment 14
282
+ */
283
+ const APP14 = 0xEE;
284
+
285
+ /**
286
+ * Application segment 15
287
+ */
288
+ const APP15 = 0xEF;
289
+
290
+ /**
291
+ * Extension 0
292
+ */
293
+ const JPG0 = 0xF0;
294
+
295
+ /**
296
+ * Extension 1
297
+ */
298
+ const JPG1 = 0xF1;
299
+
300
+ /**
301
+ * Extension 2
302
+ */
303
+ const JPG2 = 0xF2;
304
+
305
+ /**
306
+ * Extension 3
307
+ */
308
+ const JPG3 = 0xF3;
309
+
310
+ /**
311
+ * Extension 4
312
+ */
313
+ const JPG4 = 0xF4;
314
+
315
+ /**
316
+ * Extension 5
317
+ */
318
+ const JPG5 = 0xF5;
319
+
320
+ /**
321
+ * Extension 6
322
+ */
323
+ const JPG6 = 0xF6;
324
+
325
+ /**
326
+ * Extension 7
327
+ */
328
+ const JPG7 = 0xF7;
329
+
330
+ /**
331
+ * Extension 8
332
+ */
333
+ const JPG8 = 0xF8;
334
+
335
+ /**
336
+ * Extension 9
337
+ */
338
+ const JPG9 = 0xF9;
339
+
340
+ /**
341
+ * Extension 10
342
+ */
343
+ const JPG10 = 0xFA;
344
+
345
+ /**
346
+ * Extension 11
347
+ */
348
+ const JPG11 = 0xFB;
349
+
350
+ /**
351
+ * Extension 12
352
+ */
353
+ const JPG12 = 0xFC;
354
+
355
+ /**
356
+ * Extension 13
357
+ */
358
+ const JPG13 = 0xFD;
359
+
360
+ /**
361
+ * Comment
362
+ */
363
+ const COM = 0xFE;
364
+
365
+ /**
366
+ * Values for marker's short names
367
+ */
368
+ protected static $jpegMarkerShort = array(
369
+ self::SOF0 => 'SOF0',
370
+ self::SOF1 => 'SOF1',
371
+ self::SOF2 => 'SOF2',
372
+ self::SOF3 => 'SOF3',
373
+ self::SOF5 => 'SOF5',
374
+ self::SOF6 => 'SOF6',
375
+ self::SOF7 => 'SOF7',
376
+ self::SOF9 => 'SOF9',
377
+ self::SOF10 => 'SOF10',
378
+ self::SOF11 => 'SOF11',
379
+ self::SOF13 => 'SOF13',
380
+ self::SOF14 => 'SOF14',
381
+ self::SOF15 => 'SOF15',
382
+ self::SOI => 'SOI',
383
+ self::EOI => 'EOI',
384
+ self::SOS => 'SOS',
385
+ self::COM => 'COM',
386
+ self::DHT => 'DHT',
387
+ self::JPG => 'JPG',
388
+ self::DAC => 'DAC',
389
+ self::RST0 => 'RST0',
390
+ self::RST1 => 'RST1',
391
+ self::RST2 => 'RST2',
392
+ self::RST3 => 'RST3',
393
+ self::RST4 => 'RST4',
394
+ self::RST5 => 'RST5',
395
+ self::RST6 => 'RST6',
396
+ self::RST7 => 'RST7',
397
+ self::DQT => 'DQT',
398
+ self::DNL => 'DNL',
399
+ self::DRI => 'DRI',
400
+ self::DHP => 'DHP',
401
+ self::EXP => 'EXP',
402
+ self::APP0 => 'APP0',
403
+ self::APP1 => 'APP1',
404
+ self::APP2 => 'APP2',
405
+ self::APP3 => 'APP3',
406
+ self::APP4 => 'APP4',
407
+ self::APP5 => 'APP5',
408
+ self::APP6 => 'APP6',
409
+ self::APP7 => 'APP7',
410
+ self::APP8 => 'APP8',
411
+ self::APP9 => 'APP9',
412
+ self::APP10 => 'APP10',
413
+ self::APP11 => 'APP11',
414
+ self::APP12 => 'APP12',
415
+ self::APP13 => 'APP13',
416
+ self::APP14 => 'APP14',
417
+ self::APP15 => 'APP15',
418
+ self::JPG0 => 'JPG0',
419
+ self::JPG1 => 'JPG1',
420
+ self::JPG2 => 'JPG2',
421
+ self::JPG3 => 'JPG3',
422
+ self::JPG4 => 'JPG4',
423
+ self::JPG5 => 'JPG5',
424
+ self::JPG6 => 'JPG6',
425
+ self::JPG7 => 'JPG7',
426
+ self::JPG8 => 'JPG8',
427
+ self::JPG9 => 'JPG9',
428
+ self::JPG10 => 'JPG10',
429
+ self::JPG11 => 'JPG11',
430
+ self::JPG12 => 'JPG12',
431
+ self::JPG13 => 'JPG13',
432
+ self::COM => 'COM'
433
+ );
434
+
435
+ /**
436
+ * Values for marker's descriptions names.
437
+ */
438
+ protected static $jpegMarkerDescriptions = array(
439
+ self::SOF0 => 'Encoding (baseline)',
440
+ self::SOF1 => 'Encoding (extended sequential)',
441
+ self::SOF2 => 'Encoding (progressive)',
442
+ self::SOF3 => 'Encoding (lossless)',
443
+ self::SOF5 => 'Encoding (differential sequential)',
444
+ self::SOF6 => 'Encoding (differential progressive)',
445
+ self::SOF7 => 'Encoding (differential lossless)',
446
+ self::SOF9 => 'Encoding (extended sequential, arithmetic)',
447
+ self::SOF10 => 'Encoding (progressive, arithmetic)',
448
+ self::SOF11 => 'Encoding (lossless, arithmetic)',
449
+ self::SOF13 => 'Encoding (differential sequential, arithmetic)',
450
+ self::SOF14 => 'Encoding (differential progressive, arithmetic)',
451
+ self::SOF15 => 'Encoding (differential lossless, arithmetic)',
452
+ self::SOI => 'Start of image',
453
+ self::EOI => 'End of image',
454
+ self::SOS => 'Start of scan',
455
+ self::COM => 'Comment',
456
+ self::DHT => 'Define Huffman table',
457
+ self::JPG => 'Extension',
458
+ self::DAC => 'Define arithmetic coding conditioning',
459
+ 'RST' => 'Restart %d',
460
+ self::DQT => 'Define quantization table',
461
+ self::DNL => 'Define number of lines',
462
+ self::DRI => 'Define restart interval',
463
+ self::DHP => 'Define hierarchical progression',
464
+ self::EXP => 'Expand reference component',
465
+ 'APP' => 'Application segment %d',
466
+ 'JPG' => 'Extension %d',
467
+ self::COM => 'Comment'
468
+ );
469
+
470
+ /**
471
+ * Check if a byte is a valid JPEG marker.
472
+ * If the byte is recognized true is returned, otherwise false will be returned.
473
+ *
474
+ * @param integer $marker
475
+ * the marker as defined in {@link PelJpegMarker}
476
+ *
477
+ * @return boolean
478
+ */
479
+ public static function isValid($marker)
480
+ {
481
+ return ($marker >= self::SOF0 && $marker <= self::COM);
482
+ }
483
+
484
+ /**
485
+ * Turn a JPEG marker into bytes.
486
+ * This will be a string with just a single byte since all JPEG markers are simply single bytes.
487
+ *
488
+ * @param integer $marker
489
+ * the marker as defined in {@link PelJpegMarker}
490
+ *
491
+ * @return string
492
+ */
493
+ public static function getBytes($marker)
494
+ {
495
+ return chr($marker);
496
+ }
497
+
498
+ /**
499
+ * Return the short name for a marker, e.g., 'SOI' for the Start
500
+ * of Image marker.
501
+ *
502
+ * @param integer $marker
503
+ * the marker as defined in {@link PelJpegMarker}
504
+ *
505
+ * @return string
506
+ */
507
+ public static function getName($marker)
508
+ {
509
+ if (array_key_exists($marker, self::$jpegMarkerShort)) {
510
+ return self::$jpegMarkerShort[$marker];
511
+ } else {
512
+ return Pel::fmt('Unknown marker: 0x%02X', $marker);
513
+ }
514
+ }
515
+
516
+ /**
517
+ * Returns a description of a JPEG marker.
518
+ *
519
+ * @param integer $marker
520
+ * the marker as defined in {@link PelJpegMarker}
521
+ *
522
+ * @return string
523
+ */
524
+ public static function getDescription($marker)
525
+ {
526
+ if (array_key_exists($marker, self::$jpegMarkerShort)) {
527
+ if (array_key_exists($marker, self::$jpegMarkerDescriptions)) {
528
+ return self::$jpegMarkerDescriptions[$marker];
529
+ } else {
530
+ $splitted = preg_split(
531
+ "/(\d+)/",
532
+ self::$jpegMarkerShort[$marker],
533
+ - 1,
534
+ PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
535
+ if ((count($splitted) == 2) && array_key_exists($splitted[0], self::$jpegMarkerDescriptions)) {
536
+ return Pel::fmt(self::$jpegMarkerDescriptions[$splitted[0]], $splitted[1]);
537
+ }
538
+ }
539
+ }
540
+ return Pel::fmt('Unknown marker: 0x%02X', $marker);
541
+ }
542
+ }
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelOverflowException.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * PEL: PHP Exif Library.
5
+ * A library with support for reading and
6
+ * writing all Exif headers in JPEG and TIFF images using PHP.
7
+ *
8
+ * Copyright (C) 2004, 2005, 2006 Martin Geisler.
9
+ *
10
+ * This program is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program in the file COPYING; if not, write to the
22
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23
+ * Boston, MA 02110-1301 USA
24
+ */
25
+ namespace lsolesen\pel;
26
+
27
+ /**
28
+ * Classes for dealing with Exif entries.
29
+ *
30
+ * This file defines two exception classes and the abstract class
31
+ * {@link PelEntry} which provides the basic methods that all Exif
32
+ * entries will have. All Exif entries will be represented by
33
+ * descendants of the {@link PelEntry} class --- the class itself is
34
+ * abstract and so it cannot be instantiated.
35
+ *
36
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
37
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
38
+ * License (GPL)
39
+ * @package PEL
40
+ */
41
+
42
+ /**
43
+ * Exception cast when numbers overflow.
44
+ *
45
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
46
+ * @package PEL
47
+ * @subpackage Exception
48
+ */
49
+ class PelOverflowException extends PelException
50
+ {
51
+
52
+ /**
53
+ * Construct a new overflow exception.
54
+ *
55
+ * @param int $v
56
+ * the value that is out of range.
57
+ *
58
+ * @param int $min
59
+ * the minimum allowed value.
60
+ *
61
+ * @param int $max
62
+ * the maximum allowed value.
63
+ */
64
+ public function __construct($v, $min, $max)
65
+ {
66
+ parent::__construct('Value %.0f out of range [%.0f, %.0f]', $v, $min, $max);
67
+ }
68
+ }
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelTag.php ADDED
@@ -0,0 +1,1723 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * PEL: PHP Exif Library.
5
+ * A library with support for reading and
6
+ * writing all Exif headers in JPEG and TIFF images using PHP.
7
+ *
8
+ * Copyright (C) 2004, 2005, 2006, 2007 Martin Geisler.
9
+ *
10
+ * This program is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program in the file COPYING; if not, write to the
22
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23
+ * Boston, MA 02110-1301 USA
24
+ */
25
+ namespace lsolesen\pel;
26
+
27
+ /**
28
+ * Namespace for functions operating on Exif tags.
29
+ *
30
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
31
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
32
+ * License (GPL)
33
+ * @package PEL
34
+ */
35
+
36
+ /**
37
+ * Class with static methods for Exif tags.
38
+ *
39
+ * This class defines the constants that represents the Exif tags
40
+ * known to PEL. They are supposed to be used whenever one needs to
41
+ * specify an Exif tag, and they will be denoted by the pseudo-type
42
+ * {@link PelTag} throughout the documentation.
43
+ *
44
+ * Please note that the constrains on the format and number of
45
+ * components given here are advisory only. To follow the Exif
46
+ * specification one should obey them, but there is nothing that
47
+ * prevents you from creating an {@link IMAGE_LENGTH} entry with two
48
+ * or more components, even though the standard says that there should
49
+ * be exactly one component.
50
+ *
51
+ * All the methods in this class are static and should be called with
52
+ * the Exif tag on which they should operate.
53
+ *
54
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
55
+ * @package PEL
56
+ */
57
+ class PelTag
58
+ {
59
+
60
+ /**
61
+ * Interoperability index.
62
+ *
63
+ * Format: {@link PelFormat::ASCII}.
64
+ *
65
+ * Components: 4.
66
+ */
67
+ const INTEROPERABILITY_INDEX = 0x0001;
68
+
69
+ /**
70
+ * Interoperability version.
71
+ *
72
+ * Format: {@link PelFormat::UNDEFINED}.
73
+ *
74
+ * Components: 4.
75
+ */
76
+ const INTEROPERABILITY_VERSION = 0x0002;
77
+
78
+ /**
79
+ * Image width.
80
+ *
81
+ * Format: {@link PelFormat::SHORT} or {@link PelFormat::LONG}.
82
+ *
83
+ * Components: 1.
84
+ */
85
+ const IMAGE_WIDTH = 0x0100;
86
+
87
+ /**
88
+ * Image length.
89
+ *
90
+ * Format: {@link PelFormat::SHORT} or {@link PelFormat::LONG}.
91
+ *
92
+ * Components: 1.
93
+ */
94
+ const IMAGE_LENGTH = 0x0101;
95
+
96
+ /**
97
+ * Number of bits per component.
98
+ *
99
+ * Format: {@link PelFormat::SHORT}.
100
+ *
101
+ * Components: 3.
102
+ */
103
+ const BITS_PER_SAMPLE = 0x0102;
104
+
105
+ /**
106
+ * Compression scheme.
107
+ *
108
+ * Format: {@link PelFormat::SHORT}.
109
+ *
110
+ * Components: 1.
111
+ */
112
+ const COMPRESSION = 0x0103;
113
+
114
+ /**
115
+ * Pixel composition.
116
+ *
117
+ * Format: {@link PelFormat::SHORT}.
118
+ *
119
+ * Components: 1.
120
+ */
121
+ const PHOTOMETRIC_INTERPRETATION = 0x0106;
122
+
123
+ /**
124
+ * Fill Order
125
+ *
126
+ * Format: Unknown.
127
+ *
128
+ * Components: Unknown.
129
+ */
130
+ const FILL_ORDER = 0x010A;
131
+
132
+ /**
133
+ * Document Name
134
+ *
135
+ * Format: {@link PelEntryAscii}.
136
+ *
137
+ * Components: any number.
138
+ */
139
+ const DOCUMENT_NAME = 0x010D;
140
+
141
+ /**
142
+ * Image Description
143
+ *
144
+ * Format: {@link PelEntryAscii}.
145
+ *
146
+ * Components: any number.
147
+ */
148
+ const IMAGE_DESCRIPTION = 0x010E;
149
+
150
+ /**
151
+ * Manufacturer
152
+ *
153
+ * Format: {@link PelEntryAscii}.
154
+ *
155
+ * Components: any number.
156
+ */
157
+ const MAKE = 0x010F;
158
+
159
+ /**
160
+ * Model
161
+ *
162
+ * Format: {@link PelFormat::ASCII}.
163
+ *
164
+ * Components: any number.
165
+ */
166
+ const MODEL = 0x0110;
167
+
168
+ /**
169
+ * Strip Offsets
170
+ *
171
+ * Format: {@link PelFormat::SHORT} or {@link PelFormat::LONG}.
172
+ *
173
+ * Components: any number.
174
+ */
175
+ const STRIP_OFFSETS = 0x0111;
176
+
177
+ /**
178
+ * Orientation of image.
179
+ *
180
+ * Format: {@link PelFormat::SHORT}.
181
+ *
182
+ * Components: 1.
183
+ */
184
+ const ORIENTATION = 0x0112;
185
+
186
+ /**
187
+ * Number of components.
188
+ *
189
+ * Format: {@link PelFormat::SHORT}.
190
+ *
191
+ * Components: 1.
192
+ */
193
+ const SAMPLES_PER_PIXEL = 0x0115;
194
+
195
+ /**
196
+ * Rows per Strip
197
+ *
198
+ * Format: {@link PelFormat::SHORT} or {@link PelFormat::LONG}.
199
+ *
200
+ * Components: 1.
201
+ */
202
+ const ROWS_PER_STRIP = 0x0116;
203
+
204
+ /**
205
+ * Strip Byte Count
206
+ *
207
+ * Format: {@link PelFormat::SHORT} or {@link PelFormat::LONG}.
208
+ *
209
+ * Components: any number.
210
+ */
211
+ const STRIP_BYTE_COUNTS = 0x0117;
212
+
213
+ /**
214
+ * Image resolution in width direction.
215
+ *
216
+ * Format: {@link PelFormat::RATIONAL}.
217
+ *
218
+ * Components: 1.
219
+ */
220
+ const X_RESOLUTION = 0x011A;
221
+
222
+ /**
223
+ * Image resolution in height direction.
224
+ *
225
+ * Format: {@link PelFormat::RATIONAL}.
226
+ *
227
+ * Components: 1.
228
+ */
229
+ const Y_RESOLUTION = 0x011B;
230
+
231
+ /**
232
+ * Image data arrangement.
233
+ *
234
+ * Format: {@link PelFormat::SHORT}.
235
+ *
236
+ * Components: 1.
237
+ */
238
+ const PLANAR_CONFIGURATION = 0x011C;
239
+
240
+ /**
241
+ * Unit of X and Y resolution.
242
+ *
243
+ * Format: {@link PelFormat::SHORT}.
244
+ *
245
+ * Components: 1.
246
+ */
247
+ const RESOLUTION_UNIT = 0x0128;
248
+
249
+ /**
250
+ * Transfer function.
251
+ *
252
+ * Format: {@link PelFormat::SHORT}.
253
+ *
254
+ * Components: 3.
255
+ */
256
+ const TRANSFER_FUNCTION = 0x012D;
257
+
258
+ /**
259
+ * Software used.
260
+ *
261
+ * Format: {@link PelFormat::ASCII}.
262
+ *
263
+ * Components: any number.
264
+ */
265
+ const SOFTWARE = 0x0131;
266
+
267
+ /**
268
+ * File change date and time.
269
+ *
270
+ * Format: {@link PelFormat::ASCII}, modelled by the {@link
271
+ * PelEntryTime} class.
272
+ *
273
+ * Components: 20.
274
+ */
275
+ const DATE_TIME = 0x0132;
276
+
277
+ /**
278
+ * Person who created the image.
279
+ *
280
+ * Format: {@link PelFormat::ASCII}.
281
+ *
282
+ * Components: any number.
283
+ */
284
+ const ARTIST = 0x013B;
285
+
286
+ /**
287
+ * White point chromaticity.
288
+ *
289
+ * Format: {@link PelFormat::RATIONAL}.
290
+ *
291
+ * Components: 2.
292
+ */
293
+ const WHITE_POINT = 0x013E;
294
+
295
+ /**
296
+ * Chromaticities of primaries.
297
+ *
298
+ * Format: {@link PelFormat::RATIONAL}.
299
+ *
300
+ * Components: 6.
301
+ */
302
+ const PRIMARY_CHROMATICITIES = 0x013F;
303
+
304
+ /**
305
+ * Transfer Range
306
+ *
307
+ * Format: Unknown.
308
+ *
309
+ * Components: Unknown.
310
+ */
311
+ const TRANSFER_RANGE = 0x0156;
312
+
313
+ /**
314
+ * JPEGProc
315
+ *
316
+ * Format: Unknown.
317
+ *
318
+ * Components: Unknown.
319
+ */
320
+ const JPEG_PROC = 0x0200;
321
+
322
+ /**
323
+ * Offset to JPEG SOI.
324
+ *
325
+ * Format: {@link PelFormat::LONG}.
326
+ *
327
+ * Components: 1.
328
+ */
329
+ const JPEG_INTERCHANGE_FORMAT = 0x0201;
330
+
331
+ /**
332
+ * Bytes of JPEG data.
333
+ *
334
+ * Format: {@link PelFormat::LONG}.
335
+ *
336
+ * Components: 1.
337
+ */
338
+ const JPEG_INTERCHANGE_FORMAT_LENGTH = 0x0202;
339
+
340
+ /**
341
+ * Color space transformation matrix coefficients.
342
+ *
343
+ * Format: {@link PelFormat::RATIONAL}.
344
+ *
345
+ * Components: 3.
346
+ */
347
+ const YCBCR_COEFFICIENTS = 0x0211;
348
+
349
+ /**
350
+ * Subsampling ratio of Y to C.
351
+ *
352
+ * Format: {@link PelFormat::SHORT}.
353
+ *
354
+ * Components: 2.
355
+ */
356
+ const YCBCR_SUB_SAMPLING = 0x0212;
357
+
358
+ /**
359
+ * Y and C positioning.
360
+ *
361
+ * Format: {@link PelFormat::SHORT}.
362
+ *
363
+ * Components: 1.
364
+ */
365
+ const YCBCR_POSITIONING = 0x0213;
366
+
367
+ /**
368
+ * Pair of black and white reference values.
369
+ *
370
+ * Format: {@link PelFormat::RATIONAL}.
371
+ *
372
+ * Components: 6.
373
+ */
374
+ const REFERENCE_BLACK_WHITE = 0x0214;
375
+
376
+ /**
377
+ * Related Image File Format
378
+ *
379
+ * Format: Unknown.
380
+ *
381
+ * Components: Unknown.
382
+ */
383
+ const RELATED_IMAGE_FILE_FORMAT = 0x1000;
384
+
385
+ /**
386
+ * Related Image Width
387
+ *
388
+ * Format: Unknown, probably {@link PelFormat::SHORT}?
389
+ *
390
+ * Components: Unknown, probably 1.
391
+ */
392
+ const RELATED_IMAGE_WIDTH = 0x1001;
393
+
394
+ /**
395
+ * Related Image Length
396
+ *
397
+ * Format: Unknown, probably {@link PelFormat::SHORT}?
398
+ *
399
+ * Components: Unknown, probably 1.
400
+ */
401
+ const RELATED_IMAGE_LENGTH = 0x1002;
402
+
403
+ /**
404
+ * Rating
405
+ *
406
+ * Format: {@link PelFormat::SHORT}
407
+ *
408
+ * Components: 1.
409
+ */
410
+ const RATING = 0x4746;
411
+
412
+ /**
413
+ * CFA Repeat Pattern Dim.
414
+ *
415
+ * Format: {@link PelFormat::SHORT}.
416
+ *
417
+ * Components: 2.
418
+ */
419
+ const CFA_REPEAT_PATTERN_DIM = 0x828D;
420
+
421
+ /**
422
+ * Battery level.
423
+ *
424
+ * Format: Unknown.
425
+ *
426
+ * Components: Unknown.
427
+ */
428
+ const BATTERY_LEVEL = 0x828F;
429
+
430
+ /**
431
+ * Copyright holder.
432
+ *
433
+ * Format: {@link PelFormat::ASCII}, modelled by the {@link
434
+ * PelEntryCopyright} class.
435
+ *
436
+ * Components: any number.
437
+ */
438
+ const COPYRIGHT = 0x8298;
439
+
440
+ /**
441
+ * Exposure Time
442
+ *
443
+ * Format: {@link PelFormat::RATIONAL}.
444
+ *
445
+ * Components: 1.
446
+ */
447
+ const EXPOSURE_TIME = 0x829A;
448
+
449
+ /**
450
+ * FNumber
451
+ *
452
+ * Format: {@link PelFormat::RATIONAL}.
453
+ *
454
+ * Components: 1.
455
+ */
456
+ const FNUMBER = 0x829D;
457
+
458
+ /**
459
+ * IPTC/NAA
460
+ *
461
+ * Format: {@link PelFormat::LONG}.
462
+ *
463
+ * Components: any number.
464
+ */
465
+ const IPTC_NAA = 0x83BB;
466
+
467
+ /**
468
+ * Exif IFD Pointer
469
+ *
470
+ * Format: {@link PelFormat::LONG}.
471
+ *
472
+ * Components: 1.
473
+ */
474
+ const EXIF_IFD_POINTER = 0x8769;
475
+
476
+ /**
477
+ * Inter Color Profile
478
+ *
479
+ * Format: {@link PelFormat::UNDEFINED}.
480
+ *
481
+ * Components: any number.
482
+ */
483
+ const INTER_COLOR_PROFILE = 0x8773;
484
+
485
+ /**
486
+ * Exposure Program
487
+ *
488
+ * Format: {@link PelFormat::SHORT}.
489
+ *
490
+ * Components: 1.
491
+ */
492
+ const EXPOSURE_PROGRAM = 0x8822;
493
+
494
+ /**
495
+ * Spectral Sensitivity
496
+ *
497
+ * Format: {@link PelFormat::ASCII}.
498
+ *
499
+ * Components: any number.
500
+ */
501
+ const SPECTRAL_SENSITIVITY = 0x8824;
502
+
503
+ /**
504
+ * GPS Info IFD Pointer
505
+ *
506
+ * Format: {@link PelFormat::LONG}.
507
+ *
508
+ * Components: 1.
509
+ */
510
+ const GPS_INFO_IFD_POINTER = 0x8825;
511
+
512
+ /**
513
+ * ISO Speed Ratings
514
+ *
515
+ * Format: {@link PelFormat::SHORT}.
516
+ *
517
+ * Components: 2.
518
+ */
519
+ const ISO_SPEED_RATINGS = 0x8827;
520
+
521
+ /**
522
+ * OECF
523
+ *
524
+ * Format: {@link PelFormat::UNDEFINED}.
525
+ *
526
+ * Components: any number.
527
+ */
528
+ const OECF = 0x8828;
529
+
530
+ /**
531
+ * Exif version.
532
+ *
533
+ * Format: {@link PelFormat::UNDEFINED}, modelled by the {@link
534
+ * PelEntryVersion} class.
535
+ *
536
+ * Components: 4.
537
+ */
538
+ const EXIF_VERSION = 0x9000;
539
+
540
+ /**
541
+ * Date and time of original data generation.
542
+ *
543
+ * Format: {@link PelFormat::ASCII}, modelled by the {@link
544
+ * PelEntryTime} class.
545
+ *
546
+ * Components: 20.
547
+ */
548
+ const DATE_TIME_ORIGINAL = 0x9003;
549
+
550
+ /**
551
+ * Date and time of digital data generation.
552
+ *
553
+ * Format: {@link PelFormat::ASCII}, modelled by the {@link
554
+ * PelEntryTime} class.
555
+ *
556
+ * Components: 20.
557
+ */
558
+ const DATE_TIME_DIGITIZED = 0x9004;
559
+
560
+ /**
561
+ * Meaning of each component.
562
+ *
563
+ * Format: {@link PelFormat::UNDEFINED}.
564
+ *
565
+ * Components: 4.
566
+ */
567
+ const COMPONENTS_CONFIGURATION = 0x9101;
568
+
569
+ /**
570
+ * Image compression mode.
571
+ *
572
+ * Format: {@link PelFormat::RATIONAL}.
573
+ *
574
+ * Components: 1.
575
+ */
576
+ const COMPRESSED_BITS_PER_PIXEL = 0x9102;
577
+
578
+ /**
579
+ * Shutter speed
580
+ *
581
+ * Format: {@link PelFormat::SRATIONAL}.
582
+ *
583
+ * Components: 1.
584
+ */
585
+ const SHUTTER_SPEED_VALUE = 0x9201;
586
+
587
+ /**
588
+ * Aperture
589
+ *
590
+ * Format: {@link PelFormat::RATIONAL}.
591
+ *
592
+ * Components: 1.
593
+ */
594
+ const APERTURE_VALUE = 0x9202;
595
+
596
+ /**
597
+ * Brightness
598
+ *
599
+ * Format: {@link PelFormat::SRATIONAL}.
600
+ *
601
+ * Components: 1.
602
+ */
603
+ const BRIGHTNESS_VALUE = 0x9203;
604
+
605
+ /**
606
+ * Exposure Bias
607
+ *
608
+ * Format: {@link PelFormat::SRATIONAL}.
609
+ *
610
+ * Components: 1.
611
+ */
612
+ const EXPOSURE_BIAS_VALUE = 0x9204;
613
+
614
+ /**
615
+ * Max Aperture Value
616
+ *
617
+ * Format: {@link PelFormat::RATIONAL}.
618
+ *
619
+ * Components: 1.
620
+ */
621
+ const MAX_APERTURE_VALUE = 0x9205;
622
+
623
+ /**
624
+ * Subject Distance
625
+ *
626
+ * Format: {@link PelFormat::SRATIONAL}.
627
+ *
628
+ * Components: 1.
629
+ */
630
+ const SUBJECT_DISTANCE = 0x9206;
631
+
632
+ /**
633
+ * Metering Mode
634
+ *
635
+ * Format: {@link PelFormat::SHORT}.
636
+ *
637
+ * Components: 1.
638
+ */
639
+ const METERING_MODE = 0x9207;
640
+
641
+ /**
642
+ * Light Source
643
+ *
644
+ * Format: {@link PelFormat::SHORT}.
645
+ *
646
+ * Components: 1.
647
+ */
648
+ const LIGHT_SOURCE = 0x9208;
649
+
650
+ /**
651
+ * Flash
652
+ *
653
+ * Format: {@link PelFormat::SHORT}.
654
+ *
655
+ * Components: 1.
656
+ */
657
+ const FLASH = 0x9209;
658
+
659
+ /**
660
+ * Focal Length
661
+ *
662
+ * Format: {@link PelFormat::RATIONAL}.
663
+ *
664
+ * Components: 1.
665
+ */
666
+ const FOCAL_LENGTH = 0x920A;
667
+
668
+ /**
669
+ * Subject Area
670
+ *
671
+ * Format: {@link PelFormat::SHORT}.
672
+ *
673
+ * Components: 4.
674
+ */
675
+ const SUBJECT_AREA = 0x9214;
676
+
677
+ /**
678
+ * Maker Note
679
+ *
680
+ * Format: {@link PelFormat::UNDEFINED}.
681
+ *
682
+ * Components: any number.
683
+ */
684
+ const MAKER_NOTE = 0x927C;
685
+
686
+ /**
687
+ * User Comment
688
+ *
689
+ * Format: {@link PelFormat::UNDEFINED}, modelled by the {@link
690
+ * PelEntryUserComment} class.
691
+ *
692
+ * Components: any number.
693
+ */
694
+ const USER_COMMENT = 0x9286;
695
+
696
+ /**
697
+ * SubSec Time
698
+ *
699
+ * Format: {@link PelFormat::ASCII}.
700
+ *
701
+ * Components: any number.
702
+ */
703
+ const SUB_SEC_TIME = 0x9290;
704
+
705
+ /**
706
+ * SubSec Time Original
707
+ *
708
+ * Format: {@link PelFormat::ASCII}.
709
+ *
710
+ * Components: any number.
711
+ */
712
+ const SUB_SEC_TIME_ORIGINAL = 0x9291;
713
+
714
+ /**
715
+ * SubSec Time Digitized
716
+ *
717
+ * Format: {@link PelFormat::ASCII}.
718
+ *
719
+ * Components: any number.
720
+ */
721
+ const SUB_SEC_TIME_DIGITIZED = 0x9292;
722
+
723
+ /**
724
+ * Windows XP Title
725
+ *
726
+ * Format: {@link PelFormat::BYTE}, modelled by the
727
+ * {@link PelEntryWindowsString} class.
728
+ *
729
+ * Components: any number.
730
+ */
731
+ const XP_TITLE = 0x9C9B;
732
+
733
+ /**
734
+ * Windows XP Comment
735
+ *
736
+ * Format: {@link PelFormat::BYTE}, modelled by the
737
+ * {@link PelEntryWindowsString} class.
738
+ *
739
+ * Components: any number.
740
+ */
741
+ const XP_COMMENT = 0x9C9C;
742
+
743
+ /**
744
+ * Windows XP Author
745
+ *
746
+ * Format: {@link PelFormat::BYTE}, modelled by the
747
+ * {@link PelEntryWindowsString} class.
748
+ *
749
+ * Components: any number.
750
+ */
751
+ const XP_AUTHOR = 0x9C9D;
752
+
753
+ /**
754
+ * Windows XP Keywords
755
+ *
756
+ * Format: {@link PelFormat::BYTE}, modelled by the
757
+ * {@link PelEntryWindowsString} class.
758
+ *
759
+ * Components: any number.
760
+ */
761
+ const XP_KEYWORDS = 0x9C9E;
762
+
763
+ /**
764
+ * Windows XP Subject
765
+ *
766
+ * Format: {@link PelFormat::BYTE}, modelled by the
767
+ * {@link PelEntryWindowsString} class.
768
+ *
769
+ * Components: any number.
770
+ */
771
+ const XP_SUBJECT = 0x9C9F;
772
+
773
+ /**
774
+ * Supported Flashpix version
775
+ *
776
+ * Format: {@link PelFormat::UNDEFINED}, modelled by the {@link
777
+ * PelEntryVersion} class.
778
+ *
779
+ * Components: 4.
780
+ */
781
+ const FLASH_PIX_VERSION = 0xA000;
782
+
783
+ /**
784
+ * Color space information.
785
+ *
786
+ * Format: {@link PelFormat::SHORT}.
787
+ *
788
+ * Components: 1.
789
+ */
790
+ const COLOR_SPACE = 0xA001;
791
+
792
+ /**
793
+ * Valid image width.
794
+ *
795
+ * Format: {@link PelFormat::SHORT} or {@link PelFormat::LONG}.
796
+ *
797
+ * Components: 1.
798
+ */
799
+ const PIXEL_X_DIMENSION = 0xA002;
800
+
801
+ /**
802
+ * Valid image height.
803
+ *
804
+ * Format: {@link PelFormat::SHORT} or {@link PelFormat::LONG}.
805
+ *
806
+ * Components: 1.
807
+ */
808
+ const PIXEL_Y_DIMENSION = 0xA003;
809
+
810
+ /**
811
+ * Related audio file.
812
+ *
813
+ * Format: {@link PelFormat::ASCII}.
814
+ *
815
+ * Components: any number.
816
+ */
817
+ const RELATED_SOUND_FILE = 0xA004;
818
+
819
+ /**
820
+ * Interoperability IFD Pointer
821
+ *
822
+ * Format: {@link PelFormat::LONG}.
823
+ *
824
+ * Components: 1.
825
+ */
826
+ const INTEROPERABILITY_IFD_POINTER = 0xA005;
827
+
828
+ /**
829
+ * Flash energy.
830
+ *
831
+ * Format: {@link PelFormat::RATIONAL}.
832
+ *
833
+ * Components: 1.
834
+ */
835
+ const FLASH_ENERGY = 0xA20B;
836
+
837
+ /**
838
+ * Spatial frequency response.
839
+ *
840
+ * Format: {@link PelFormat::UNDEFINED}.
841
+ *
842
+ * Components: any number.
843
+ */
844
+ const SPATIAL_FREQUENCY_RESPONSE = 0xA20C;
845
+
846
+ /**
847
+ * Focal plane X resolution.
848
+ *
849
+ * Format: {@link PelFormat::RATIONAL}.
850
+ *
851
+ * Components: 1.
852
+ */
853
+ const FOCAL_PLANE_X_RESOLUTION = 0xA20E;
854
+
855
+ /**
856
+ * Focal plane Y resolution.
857
+ *
858
+ * Format: {@link PelFormat::RATIONAL}.
859
+ *
860
+ * Components: 1.
861
+ */
862
+ const FOCAL_PLANE_Y_RESOLUTION = 0xA20F;
863
+
864
+ /**
865
+ * Focal plane resolution unit.
866
+ *
867
+ * Format: {@link PelFormat::SHORT}.
868
+ *
869
+ * Components: 1.
870
+ */
871
+ const FOCAL_PLANE_RESOLUTION_UNIT = 0xA210;
872
+
873
+ /**
874
+ * Subject location.
875
+ *
876
+ * Format: {@link PelFormat::SHORT}.
877
+ *
878
+ * Components: 1.
879
+ */
880
+ const SUBJECT_LOCATION = 0xA214;
881
+
882
+ /**
883
+ * Exposure index.
884
+ *
885
+ * Format: {@link PelFormat::RATIONAL}.
886
+ *
887
+ * Components: 1.
888
+ */
889
+ const EXPOSURE_INDEX = 0xA215;
890
+
891
+ /**
892
+ * Sensing method.
893
+ *
894
+ * Format: {@link PelFormat::SHORT}.
895
+ *
896
+ * Components: 1.
897
+ */
898
+ const SENSING_METHOD = 0xA217;
899
+
900
+ /**
901
+ * File source.
902
+ *
903
+ * Format: {@link PelFormat::UNDEFINED}.
904
+ *
905
+ * Components: 1.
906
+ */
907
+ const FILE_SOURCE = 0xA300;
908
+
909
+ /**
910
+ * Scene type.
911
+ *
912
+ * Format: {@link PelFormat::UNDEFINED}.
913
+ *
914
+ * Components: 1.
915
+ */
916
+ const SCENE_TYPE = 0xA301;
917
+
918
+ /**
919
+ * CFA pattern.
920
+ *
921
+ * Format: {@link PelFormat::UNDEFINED}.
922
+ *
923
+ * Components: any number.
924
+ */
925
+ const CFA_PATTERN = 0xA302;
926
+
927
+ /**
928
+ * Custom image processing.
929
+ *
930
+ * Format: {@link PelFormat::SHORT}.
931
+ *
932
+ * Components: 1.
933
+ */
934
+ const CUSTOM_RENDERED = 0xA401;
935
+
936
+ /**
937
+ * Exposure mode.
938
+ *
939
+ * Format: {@link PelFormat::SHORT}.
940
+ *
941
+ * Components: 1.
942
+ */
943
+ const EXPOSURE_MODE = 0xA402;
944
+
945
+ /**
946
+ * White balance.
947
+ *
948
+ * Format: {@link PelFormat::SHORT}.
949
+ *
950
+ * Components: 1.
951
+ */
952
+ const WHITE_BALANCE = 0xA403;
953
+
954
+ /**
955
+ * Digital zoom ratio.
956
+ *
957
+ * Format: {@link PelFormat::RATIONAL}.
958
+ *
959
+ * Components: 1.
960
+ */
961
+ const DIGITAL_ZOOM_RATIO = 0xA404;
962
+
963
+ /**
964
+ * Focal length in 35mm film.
965
+ *
966
+ * Format: {@link PelFormat::RATIONAL}.
967
+ *
968
+ * Components: 1.
969
+ */
970
+ const FOCAL_LENGTH_IN_35MM_FILM = 0xA405;
971
+
972
+ /**
973
+ * Scene capture type.
974
+ *
975
+ * Format: {@link PelFormat::SHORT}.
976
+ *
977
+ * Components: 1.
978
+ */
979
+ const SCENE_CAPTURE_TYPE = 0xA406;
980
+
981
+ /**
982
+ * Gain control.
983
+ *
984
+ * Format: {@link PelFormat::SHORT}.
985
+ *
986
+ * Components: 1.
987
+ */
988
+ const GAIN_CONTROL = 0xA407;
989
+
990
+ /**
991
+ * Contrast.
992
+ *
993
+ * Format: {@link PelFormat::SHORT}.
994
+ *
995
+ * Components: 1.
996
+ */
997
+ const CONTRAST = 0xA408;
998
+
999
+ /**
1000
+ * Saturation.
1001
+ *
1002
+ * Format: {@link PelFormat::SHORT}.
1003
+ *
1004
+ * Components: 1.
1005
+ */
1006
+ const SATURATION = 0xA409;
1007
+
1008
+ /**
1009
+ * Sharpness.
1010
+ *
1011
+ * Format: {@link PelFormat::SHORT}.
1012
+ *
1013
+ * Components: 1.
1014
+ */
1015
+ const SHARPNESS = 0xA40A;
1016
+
1017
+ /**
1018
+ * Device settings description.
1019
+ *
1020
+ * This tag indicates information on the picture-taking conditions
1021
+ * of a particular camera model. The tag is used only to indicate
1022
+ * the picture-taking conditions in the reader.
1023
+ */
1024
+ const DEVICE_SETTING_DESCRIPTION = 0xA40B;
1025
+
1026
+ /**
1027
+ * Subject distance range.
1028
+ *
1029
+ * Format: {@link PelFormat::SHORT}.
1030
+ *
1031
+ * Components: 1.
1032
+ */
1033
+ const SUBJECT_DISTANCE_RANGE = 0xA40C;
1034
+
1035
+ /**
1036
+ * Image unique ID.
1037
+ *
1038
+ * Format: {@link PelFormat::ASCII}.
1039
+ *
1040
+ * Components: 32.
1041
+ */
1042
+ const IMAGE_UNIQUE_ID = 0xA420;
1043
+
1044
+ /**
1045
+ * Gamma.
1046
+ *
1047
+ * Format: {@link PelFormat::RATIONAL}.
1048
+ *
1049
+ * Components: 1.
1050
+ */
1051
+ const GAMMA = 0xA500;
1052
+
1053
+ /**
1054
+ * PrintIM
1055
+ *
1056
+ * Format: {@link PelFormat::UNDEFINED}.
1057
+ *
1058
+ * Components: unknown.
1059
+ */
1060
+ const PRINT_IM = 0xC4A5;
1061
+
1062
+ /**
1063
+ * GPS tag version.
1064
+ *
1065
+ * Format: {@link PelFormat::BYTE}.
1066
+ *
1067
+ * Components: 4.
1068
+ */
1069
+ const GPS_VERSION_ID = 0x0000;
1070
+
1071
+ /**
1072
+ * North or South Latitude.
1073
+ *
1074
+ * Format: {@link PelFormat::ASCII}.
1075
+ *
1076
+ * Components: 2.
1077
+ */
1078
+ const GPS_LATITUDE_REF = 0x0001;
1079
+
1080
+ /**
1081
+ * Latitude.
1082
+ *
1083
+ * Format: {@link PelFormat::RATIONAL}.
1084
+ *
1085
+ * Components: 3.
1086
+ */
1087
+ const GPS_LATITUDE = 0x0002;
1088
+
1089
+ /**
1090
+ * East or West Longitude.
1091
+ *
1092
+ * Format: {@link PelFormat::ASCII}.
1093
+ *
1094
+ * Components: 2.
1095
+ */
1096
+ const GPS_LONGITUDE_REF = 0x0003;
1097
+
1098
+ /**
1099
+ * Longitude.
1100
+ *
1101
+ * Format: {@link PelFormat::RATIONAL}.
1102
+ *
1103
+ * Components: 3.
1104
+ */
1105
+ const GPS_LONGITUDE = 0x0004;
1106
+
1107
+ /**
1108
+ * Altitude reference.
1109
+ *
1110
+ * Format: {@link PelFormat::BYTE}.
1111
+ *
1112
+ * Components: 1.
1113
+ */
1114
+ const GPS_ALTITUDE_REF = 0x0005;
1115
+
1116
+ /**
1117
+ * Altitude.
1118
+ *
1119
+ * Format: {@link PelFormat::RATIONAL}.
1120
+ *
1121
+ * Components: 1.
1122
+ */
1123
+ const GPS_ALTITUDE = 0x0006;
1124
+
1125
+ /**
1126
+ * GPS time (atomic clock).
1127
+ *
1128
+ * Format: {@link PelFormat::RATIONAL}.
1129
+ *
1130
+ * Components: 3.
1131
+ */
1132
+ const GPS_TIME_STAMP = 0x0007;
1133
+
1134
+ /**
1135
+ * GPS satellites used for measurement.
1136
+ *
1137
+ * Format: {@link PelFormat::ASCII}.
1138
+ *
1139
+ * Components: Any.
1140
+ */
1141
+ const GPS_SATELLITES = 0x0008;
1142
+
1143
+ /**
1144
+ * GPS receiver status.
1145
+ *
1146
+ * Format: {@link PelFormat::ASCII}.
1147
+ *
1148
+ * Components: 2.
1149
+ */
1150
+ const GPS_STATUS = 0x0009;
1151
+
1152
+ /**
1153
+ * GPS measurement mode.
1154
+ *
1155
+ * Format: {@link PelFormat::ASCII}.
1156
+ *
1157
+ * Components: 2.
1158
+ */
1159
+ const GPS_MEASURE_MODE = 0x000A;
1160
+
1161
+ /**
1162
+ * Measurement precision.
1163
+ *
1164
+ * Format: {@link PelFormat::RATIONAL}.
1165
+ *
1166
+ * Components: 1.
1167
+ */
1168
+ const GPS_DOP = 0x000B;
1169
+
1170
+ /**
1171
+ * Speed unit.
1172
+ *
1173
+ * Format: {@link PelFormat::ASCII}.
1174
+ *
1175
+ * Components: 2.
1176
+ */
1177
+ const GPS_SPEED_REF = 0x000C;
1178
+
1179
+ /**
1180
+ * Speed of GPS receiver.
1181
+ *
1182
+ * Format: {@link PelFormat::RATIONAL}.
1183
+ *
1184
+ * Components: 1.
1185
+ */
1186
+ const GPS_SPEED = 0x000D;
1187
+
1188
+ /**
1189
+ * Reference for direction of movement.
1190
+ *
1191
+ * Format: {@link PelFormat::ASCII}.
1192
+ *
1193
+ * Components: 2.
1194
+ */
1195
+ const GPS_TRACK_REF = 0x000E;
1196
+
1197
+ /**
1198
+ * Direction of movement.
1199
+ *
1200
+ * Format: {@link PelFormat::RATIONAL}.
1201
+ *
1202
+ * Components: 1.
1203
+ */
1204
+ const GPS_TRACK = 0x000F;
1205
+
1206
+ /**
1207
+ * Reference for direction of image.
1208
+ *
1209
+ * Format: {@link PelFormat::ASCII}.
1210
+ *
1211
+ * Components: 2.
1212
+ */
1213
+ const GPS_IMG_DIRECTION_REF = 0x0010;
1214
+
1215
+ /**
1216
+ * Direction of image.
1217
+ *
1218
+ * Format: {@link PelFormat::RATIONAL}.
1219
+ *
1220
+ * Components: 1.
1221
+ */
1222
+ const GPS_IMG_DIRECTION = 0x0011;
1223
+
1224
+ /**
1225
+ * Geodetic survey data used.
1226
+ *
1227
+ * Format: {@link PelFormat::ASCII}.
1228
+ *
1229
+ * Components: Any.
1230
+ */
1231
+ const GPS_MAP_DATUM = 0x0012;
1232
+
1233
+ /**
1234
+ * Reference for latitude of destination.
1235
+ *
1236
+ * Format: {@link PelFormat::ASCII}.
1237
+ *
1238
+ * Components: 2.
1239
+ */
1240
+ const GPS_DEST_LATITUDE_REF = 0x0013;
1241
+
1242
+ /**
1243
+ * Latitude of destination.
1244
+ *
1245
+ * Format: {@link PelFormat::RATIONAL}.
1246
+ *
1247
+ * Components: 3.
1248
+ */
1249
+ const GPS_DEST_LATITUDE = 0x0014;
1250
+
1251
+ /**
1252
+ * Reference for longitude of destination.
1253
+ *
1254
+ * Format: {@link PelFormat::ASCII}.
1255
+ *
1256
+ * Components: 2.
1257
+ */
1258
+ const GPS_DEST_LONGITUDE_REF = 0x0015;
1259
+
1260
+ /**
1261
+ * Longitude of destination.
1262
+ *
1263
+ * Format: {@link PelFormat::RATIONAL}.
1264
+ *
1265
+ * Components: 3.
1266
+ */
1267
+ const GPS_DEST_LONGITUDE = 0x0016;
1268
+
1269
+ /**
1270
+ * Reference for bearing of destination.
1271
+ *
1272
+ * Format: {@link PelFormat::ASCII}.
1273
+ *
1274
+ * Components: 2.
1275
+ */
1276
+ const GPS_DEST_BEARING_REF = 0x0017;
1277
+
1278
+ /**
1279
+ * Bearing of destination.
1280
+ *
1281
+ * Format: {@link PelFormat::RATIONAL}.
1282
+ *
1283
+ * Components: 1.
1284
+ */
1285
+ const GPS_DEST_BEARING = 0x0018;
1286
+
1287
+ /**
1288
+ * Reference for distance to destination.
1289
+ *
1290
+ * Format: {@link PelFormat::ASCII}.
1291
+ *
1292
+ * Components: 2.
1293
+ */
1294
+ const GPS_DEST_DISTANCE_REF = 0x0019;
1295
+
1296
+ /**
1297
+ * Distance to destination.
1298
+ *
1299
+ * Format: {@link PelFormat::RATIONAL}.
1300
+ *
1301
+ * Components: 1.
1302
+ */
1303
+ const GPS_DEST_DISTANCE = 0x001A;
1304
+
1305
+ /**
1306
+ * Name of GPS processing method.
1307
+ *
1308
+ * Format: {@link PelFormat::UNDEFINED}.
1309
+ *
1310
+ * Components: Any.
1311
+ */
1312
+ const GPS_PROCESSING_METHOD = 0x001B;
1313
+
1314
+ /**
1315
+ * Name of GPS area.
1316
+ *
1317
+ * Format: {@link PelFormat::UNDEFINED}.
1318
+ *
1319
+ * Components: Any.
1320
+ */
1321
+ const GPS_AREA_INFORMATION = 0x001C;
1322
+
1323
+ /**
1324
+ * GPS date.
1325
+ *
1326
+ * Format: {@link PelFormat::ASCII}.
1327
+ *
1328
+ * Components: 11.
1329
+ */
1330
+ const GPS_DATE_STAMP = 0x001D;
1331
+
1332
+ /**
1333
+ * GPS differential correction.
1334
+ *
1335
+ * Format: {@link PelFormat::SHORT}.
1336
+ *
1337
+ * Components: 1.
1338
+ */
1339
+ const GPS_DIFFERENTIAL = 0x001E;
1340
+
1341
+ /**
1342
+ * Values for tags short names.
1343
+ */
1344
+ protected static $exifTagsShort= array(
1345
+ self::INTEROPERABILITY_INDEX => 'InteroperabilityIndex',
1346
+ self::INTEROPERABILITY_VERSION => 'InteroperabilityVersion',
1347
+ self::IMAGE_WIDTH => 'ImageWidth',
1348
+ self::IMAGE_LENGTH => 'ImageLength',
1349
+ self::BITS_PER_SAMPLE => 'BitsPerSample',
1350
+ self::COMPRESSION => 'Compression',
1351
+ self::PHOTOMETRIC_INTERPRETATION => 'PhotometricInterpretation',
1352
+ self::FILL_ORDER => 'FillOrder',
1353
+ self::DOCUMENT_NAME => 'DocumentName',
1354
+ self::IMAGE_DESCRIPTION => 'ImageDescription',
1355
+ self::MAKE => 'Make',
1356
+ self::MODEL => 'Model',
1357
+ self::STRIP_OFFSETS => 'StripOffsets',
1358
+ self::ORIENTATION => 'Orientation',
1359
+ self::SAMPLES_PER_PIXEL => 'SamplesPerPixel',
1360
+ self::ROWS_PER_STRIP => 'RowsPerStrip',
1361
+ self::STRIP_BYTE_COUNTS => 'StripByteCounts',
1362
+ self::X_RESOLUTION => 'XResolution',
1363
+ self::Y_RESOLUTION => 'YResolution',
1364
+ self::PLANAR_CONFIGURATION => 'PlanarConfiguration',
1365
+ self::RESOLUTION_UNIT => 'ResolutionUnit',
1366
+ self::TRANSFER_FUNCTION => 'TransferFunction',
1367
+ self::SOFTWARE => 'Software',
1368
+ self::DATE_TIME => 'DateTime',
1369
+ self::ARTIST => 'Artist',
1370
+ self::WHITE_POINT => 'WhitePoint',
1371
+ self::PRIMARY_CHROMATICITIES => 'PrimaryChromaticities',
1372
+ self::TRANSFER_RANGE => 'TransferRange',
1373
+ self::JPEG_PROC => 'JPEGProc',
1374
+ self::JPEG_INTERCHANGE_FORMAT => 'JPEGInterchangeFormat',
1375
+ self::JPEG_INTERCHANGE_FORMAT_LENGTH => 'JPEGInterchangeFormatLength',
1376
+ self::YCBCR_COEFFICIENTS => 'YCbCrCoefficients',
1377
+ self::YCBCR_SUB_SAMPLING => 'YCbCrSubSampling',
1378
+ self::YCBCR_POSITIONING => 'YCbCrPositioning',
1379
+ self::REFERENCE_BLACK_WHITE => 'ReferenceBlackWhite',
1380
+ self::RELATED_IMAGE_FILE_FORMAT => 'RelatedImageFileFormat',
1381
+ self::RELATED_IMAGE_WIDTH => 'RelatedImageWidth',
1382
+ self::RELATED_IMAGE_LENGTH => 'RelatedImageLength',
1383
+ self::RATING => 'Rating',
1384
+ self::CFA_REPEAT_PATTERN_DIM => 'CFARepeatPatternDim',
1385
+ self::CFA_PATTERN => 'CFAPattern',
1386
+ self::BATTERY_LEVEL => 'BatteryLevel',
1387
+ self::COPYRIGHT => 'Copyright',
1388
+ self::EXPOSURE_TIME => 'ExposureTime',
1389
+ self::FNUMBER => 'FNumber',
1390
+ self::IPTC_NAA => 'IPTC/NAA',
1391
+ self::EXIF_IFD_POINTER => 'ExifIFDPointer',
1392
+ self::INTER_COLOR_PROFILE => 'InterColorProfile',
1393
+ self::EXPOSURE_PROGRAM => 'ExposureProgram',
1394
+ self::SPECTRAL_SENSITIVITY => 'SpectralSensitivity',
1395
+ self::GPS_INFO_IFD_POINTER => 'GPSInfoIFDPointer',
1396
+ self::ISO_SPEED_RATINGS => 'ISOSpeedRatings',
1397
+ self::OECF => 'OECF',
1398
+ self::EXIF_VERSION => 'ExifVersion',
1399
+ self::DATE_TIME_ORIGINAL => 'DateTimeOriginal',
1400
+ self::DATE_TIME_DIGITIZED => 'DateTimeDigitized',
1401
+ self::COMPONENTS_CONFIGURATION => 'ComponentsConfiguration',
1402
+ self::COMPRESSED_BITS_PER_PIXEL => 'CompressedBitsPerPixel',
1403
+ self::SHUTTER_SPEED_VALUE => 'ShutterSpeedValue',
1404
+ self::APERTURE_VALUE => 'ApertureValue',
1405
+ self::BRIGHTNESS_VALUE => 'BrightnessValue',
1406
+ self::EXPOSURE_BIAS_VALUE => 'ExposureBiasValue',
1407
+ self::MAX_APERTURE_VALUE => 'MaxApertureValue',
1408
+ self::SUBJECT_DISTANCE => 'SubjectDistance',
1409
+ self::METERING_MODE => 'MeteringMode',
1410
+ self::LIGHT_SOURCE => 'LightSource',
1411
+ self::FLASH => 'Flash',
1412
+ self::FOCAL_LENGTH => 'FocalLength',
1413
+ self::MAKER_NOTE => 'MakerNote',
1414
+ self::USER_COMMENT => 'UserComment',
1415
+ self::SUB_SEC_TIME => 'SubSecTime',
1416
+ self::SUB_SEC_TIME_ORIGINAL => 'SubSecTimeOriginal',
1417
+ self::SUB_SEC_TIME_DIGITIZED => 'SubSecTimeDigitized',
1418
+ self::XP_TITLE => 'WindowsXPTitle',
1419
+ self::XP_COMMENT => 'WindowsXPComment',
1420
+ self::XP_AUTHOR => 'WindowsXPAuthor',
1421
+ self::XP_KEYWORDS => 'WindowsXPKeywords',
1422
+ self::XP_SUBJECT => 'WindowsXPSubject',
1423
+ self::FLASH_PIX_VERSION => 'FlashPixVersion',
1424
+ self::COLOR_SPACE => 'ColorSpace',
1425
+ self::PIXEL_X_DIMENSION => 'PixelXDimension',
1426
+ self::PIXEL_Y_DIMENSION => 'PixelYDimension',
1427
+ self::RELATED_SOUND_FILE => 'RelatedSoundFile',
1428
+ self::INTEROPERABILITY_IFD_POINTER => 'InteroperabilityIFDPointer',
1429
+ self::FLASH_ENERGY => 'FlashEnergy',
1430
+ self::SPATIAL_FREQUENCY_RESPONSE => 'SpatialFrequencyResponse',
1431
+ self::FOCAL_PLANE_X_RESOLUTION => 'FocalPlaneXResolution',
1432
+ self::FOCAL_PLANE_Y_RESOLUTION => 'FocalPlaneYResolution',
1433
+ self::FOCAL_PLANE_RESOLUTION_UNIT => 'FocalPlaneResolutionUnit',
1434
+ self::SUBJECT_LOCATION => 'SubjectLocation',
1435
+ self::EXPOSURE_INDEX => 'ExposureIndex',
1436
+ self::SENSING_METHOD => 'SensingMethod',
1437
+ self::FILE_SOURCE => 'FileSource',
1438
+ self::SCENE_TYPE => 'SceneType',
1439
+ self::SUBJECT_AREA => 'SubjectArea',
1440
+ self::CUSTOM_RENDERED => 'CustomRendered',
1441
+ self::EXPOSURE_MODE => 'ExposureMode',
1442
+ self::WHITE_BALANCE => 'WhiteBalance',
1443
+ self::DIGITAL_ZOOM_RATIO => 'DigitalZoomRatio',
1444
+ self::FOCAL_LENGTH_IN_35MM_FILM => 'FocalLengthIn35mmFilm',
1445
+ self::SCENE_CAPTURE_TYPE => 'SceneCaptureType',
1446
+ self::GAIN_CONTROL => 'GainControl',
1447
+ self::CONTRAST => 'Contrast',
1448
+ self::SATURATION => 'Saturation',
1449
+ self::SHARPNESS => 'Sharpness',
1450
+ self::DEVICE_SETTING_DESCRIPTION => 'DeviceSettingDescription',
1451
+ self::SUBJECT_DISTANCE_RANGE => 'SubjectDistanceRange',
1452
+ self::IMAGE_UNIQUE_ID => 'ImageUniqueID',
1453
+ self::GAMMA => 'Gamma',
1454
+ self::PRINT_IM => 'PrintIM',
1455
+ );
1456
+
1457
+ /**
1458
+ * Values for tags titles.
1459
+ */
1460
+ protected static $exifTagsTitle = array(
1461
+ self::INTEROPERABILITY_INDEX => 'Interoperability Index',
1462
+ self::INTEROPERABILITY_VERSION => 'Interoperability Version',
1463
+ self::IMAGE_WIDTH => 'Image Width',
1464
+ self::IMAGE_LENGTH => 'Image Length',
1465
+ self::BITS_PER_SAMPLE => 'Bits per Sample',
1466
+ self::COMPRESSION => 'Compression',
1467
+ self::PHOTOMETRIC_INTERPRETATION => 'Photometric Interpretation',
1468
+ self::FILL_ORDER => 'Fill Order',
1469
+ self::DOCUMENT_NAME => 'Document Name',
1470
+ self::IMAGE_DESCRIPTION => 'Image Description',
1471
+ self::MAKE => 'Manufacturer',
1472
+ self::MODEL => 'Model',
1473
+ self::STRIP_OFFSETS => 'Strip Offsets',
1474
+ self::ORIENTATION => 'Orientation',
1475
+ self::SAMPLES_PER_PIXEL => 'Samples per Pixel',
1476
+ self::ROWS_PER_STRIP => 'Rows per Strip',
1477
+ self::STRIP_BYTE_COUNTS => 'Strip Byte Count',
1478
+ self::X_RESOLUTION => 'x-Resolution',
1479
+ self::Y_RESOLUTION => 'y-Resolution',
1480
+ self::PLANAR_CONFIGURATION => 'Planar Configuration',
1481
+ self::RESOLUTION_UNIT => 'Resolution Unit',
1482
+ self::TRANSFER_FUNCTION => 'Transfer Function',
1483
+ self::SOFTWARE => 'Software',
1484
+ self::DATE_TIME => 'Date and Time',
1485
+ self::ARTIST => 'Artist',
1486
+ self::WHITE_POINT => 'White Point',
1487
+ self::PRIMARY_CHROMATICITIES => 'Primary Chromaticities',
1488
+ self::TRANSFER_RANGE => 'Transfer Range',
1489
+ self::JPEG_PROC => 'JPEG Process',
1490
+ self::JPEG_INTERCHANGE_FORMAT => 'JPEG Interchange Format',
1491
+ self::JPEG_INTERCHANGE_FORMAT_LENGTH => 'JPEG Interchange Format Length',
1492
+ self::YCBCR_COEFFICIENTS => 'YCbCr Coefficients',
1493
+ self::YCBCR_SUB_SAMPLING => 'YCbCr Sub-Sampling',
1494
+ self::YCBCR_POSITIONING => 'YCbCr Positioning',
1495
+ self::REFERENCE_BLACK_WHITE => 'Reference Black/White',
1496
+ self::RELATED_IMAGE_FILE_FORMAT => 'Related Image File Format',
1497
+ self::RELATED_IMAGE_WIDTH => 'Related Image Width',
1498
+ self::RELATED_IMAGE_LENGTH => 'Related Image Length',
1499
+ self::CFA_REPEAT_PATTERN_DIM => 'CFA Repeat Pattern Dim',
1500
+ self::CFA_PATTERN => 'CFA Pattern',
1501
+ self::BATTERY_LEVEL => 'Battery Level',
1502
+ self::COPYRIGHT => 'Copyright',
1503
+ self::EXPOSURE_TIME => 'Exposure Time',
1504
+ self::FNUMBER => 'FNumber',
1505
+ self::IPTC_NAA => 'IPTC/NAA',
1506
+ self::EXIF_IFD_POINTER => 'Exif IFD Pointer',
1507
+ self::INTER_COLOR_PROFILE => 'Inter Color Profile',
1508
+ self::EXPOSURE_PROGRAM => 'Exposure Program',
1509
+ self::SPECTRAL_SENSITIVITY => 'Spectral Sensitivity',
1510
+ self::GPS_INFO_IFD_POINTER => 'GPS Info IFD Pointer',
1511
+ self::ISO_SPEED_RATINGS => 'ISO Speed Ratings',
1512
+ self::OECF => 'OECF',
1513
+ self::EXIF_VERSION => 'Exif Version',
1514
+ self::DATE_TIME_ORIGINAL => 'Date and Time (original)',
1515
+ self::DATE_TIME_DIGITIZED => 'Date and Time (digitized)',
1516
+ self::COMPONENTS_CONFIGURATION => 'Components Configuration',
1517
+ self::COMPRESSED_BITS_PER_PIXEL => 'Compressed Bits per Pixel',
1518
+ self::SHUTTER_SPEED_VALUE => 'Shutter speed',
1519
+ self::APERTURE_VALUE => 'Aperture',
1520
+ self::BRIGHTNESS_VALUE => 'Brightness',
1521
+ self::EXPOSURE_BIAS_VALUE => 'Exposure Bias',
1522
+ self::MAX_APERTURE_VALUE => 'Max Aperture Value',
1523
+ self::SUBJECT_DISTANCE => 'Subject Distance',
1524
+ self::METERING_MODE => 'Metering Mode',
1525
+ self::LIGHT_SOURCE => 'Light Source',
1526
+ self::FLASH => 'Flash',
1527
+ self::FOCAL_LENGTH => 'Focal Length',
1528
+ self::MAKER_NOTE => 'Maker Note',
1529
+ self::USER_COMMENT => 'User Comment',
1530
+ self::SUB_SEC_TIME => 'SubSec Time',
1531
+ self::SUB_SEC_TIME_ORIGINAL => 'SubSec Time Original',
1532
+ self::SUB_SEC_TIME_DIGITIZED => 'SubSec Time Digitized',
1533
+ self::XP_TITLE => 'Windows XP Title',
1534
+ self::XP_COMMENT => 'Windows XP Comment',
1535
+ self::XP_AUTHOR => 'Windows XP Author',
1536
+ self::XP_KEYWORDS => 'Windows XP Keywords',
1537
+ self::XP_SUBJECT => 'Windows XP Subject',
1538
+ self::FLASH_PIX_VERSION => 'FlashPix Version',
1539
+ self::COLOR_SPACE => 'Color Space',
1540
+ self::PIXEL_X_DIMENSION => 'Pixel x-Dimension',
1541
+ self::PIXEL_Y_DIMENSION => 'Pixel y-Dimension',
1542
+ self::RELATED_SOUND_FILE => 'Related Sound File',
1543
+ self::INTEROPERABILITY_IFD_POINTER => 'Interoperability IFD Pointer',
1544
+ self::FLASH_ENERGY => 'Flash Energy',
1545
+ self::SPATIAL_FREQUENCY_RESPONSE => 'Spatial Frequency Response',
1546
+ self::FOCAL_PLANE_X_RESOLUTION => 'Focal Plane x-Resolution',
1547
+ self::FOCAL_PLANE_Y_RESOLUTION => 'Focal Plane y-Resolution',
1548
+ self::FOCAL_PLANE_RESOLUTION_UNIT => 'Focal Plane Resolution Unit',
1549
+ self::SUBJECT_LOCATION => 'Subject Location',
1550
+ self::EXPOSURE_INDEX => 'Exposure index',
1551
+ self::SENSING_METHOD => 'Sensing Method',
1552
+ self::FILE_SOURCE => 'File Source',
1553
+ self::SCENE_TYPE => 'Scene Type',
1554
+ self::SUBJECT_AREA => 'Subject Area',
1555
+ self::CUSTOM_RENDERED => 'Custom Rendered',
1556
+ self::EXPOSURE_MODE => 'Exposure Mode',
1557
+ self::WHITE_BALANCE => 'White Balance',
1558
+ self::DIGITAL_ZOOM_RATIO => 'Digital Zoom Ratio',
1559
+ self::FOCAL_LENGTH_IN_35MM_FILM => 'Focal Length In 35mm Film',
1560
+ self::SCENE_CAPTURE_TYPE => 'Scene Capture Type',
1561
+ self::GAIN_CONTROL => 'Gain Control',
1562
+ self::CONTRAST => 'Contrast',
1563
+ self::SATURATION => 'Saturation',
1564
+ self::SHARPNESS => 'Sharpness',
1565
+ self::DEVICE_SETTING_DESCRIPTION => 'Device Setting Description',
1566
+ self::SUBJECT_DISTANCE_RANGE => 'Subject Distance Range',
1567
+ self::IMAGE_UNIQUE_ID => 'Image Unique ID',
1568
+ self::GAMMA => 'Gamma',
1569
+ self::PRINT_IM => 'Print IM',
1570
+ );
1571
+
1572
+ /**
1573
+ * Values for gps tags short names.
1574
+ */
1575
+ protected static $gpsTagsShort = array(
1576
+ self::GPS_VERSION_ID => 'GPSVersionID',
1577
+ self::GPS_LATITUDE_REF => 'GPSLatitudeRef',
1578
+ self::GPS_LATITUDE => 'GPSLatitude',
1579
+ self::GPS_LONGITUDE_REF => 'GPSLongitudeRef',
1580
+ self::GPS_LONGITUDE => 'GPSLongitude',
1581
+ self::GPS_ALTITUDE_REF => 'GPSAltitudeRef',
1582
+ self::GPS_ALTITUDE => 'GPSAltitude',
1583
+ self::GPS_TIME_STAMP => 'GPSTimeStamp',
1584
+ self::GPS_SATELLITES => 'GPSSatellites',
1585
+ self::GPS_STATUS => 'GPSStatus',
1586
+ self::GPS_MEASURE_MODE => 'GPSMeasureMode',
1587
+ self::GPS_DOP => 'GPSDOP',
1588
+ self::GPS_SPEED_REF => 'GPSSpeedRef',
1589
+ self::GPS_SPEED => 'GPSSpeed',
1590
+ self::GPS_TRACK_REF => 'GPSTrackRef',
1591
+ self::GPS_TRACK => 'GPSTrack',
1592
+ self::GPS_IMG_DIRECTION_REF => 'GPSImgDirectionRef',
1593
+ self::GPS_IMG_DIRECTION => 'GPSImgDirection',
1594
+ self::GPS_MAP_DATUM => 'GPSMapDatum',
1595
+ self::GPS_DEST_LATITUDE_REF => 'GPSDestLatitudeRef',
1596
+ self::GPS_DEST_LATITUDE => 'GPSDestLatitude',
1597
+ self::GPS_DEST_LONGITUDE_REF => 'GPSDestLongitudeRef',
1598
+ self::GPS_DEST_LONGITUDE => 'GPSDestLongitude',
1599
+ self::GPS_DEST_BEARING_REF => 'GPSDestBearingRef',
1600
+ self::GPS_DEST_BEARING => 'GPSDestBearing',
1601
+ self::GPS_DEST_DISTANCE_REF => 'GPSDestDistanceRef',
1602
+ self::GPS_DEST_DISTANCE => 'GPSDestDistance',
1603
+ self::GPS_PROCESSING_METHOD => 'GPSProcessingMethod',
1604
+ self::GPS_AREA_INFORMATION => 'GPSAreaInformation',
1605
+ self::GPS_DATE_STAMP => 'GPSDateStamp',
1606
+ self::GPS_DIFFERENTIAL => 'GPSDifferential',
1607
+ );
1608
+
1609
+ /**
1610
+ * Returns a string from container with key $tag and subcontainer index of $idx
1611
+ *
1612
+ * @param array $container
1613
+ * {@link PelTag::EXIF_TAGS_SHORT}, {@link PelTag::EXIF_TAGS_TITLE},
1614
+ * {@link PelTag::GPS_TAGS_SHORT} or {@link PelTag::GPS_TAGS_TITLE} container.
1615
+ * @param PelTag $tag
1616
+ * the tag.
1617
+ *
1618
+ * @return string short name or long name of the tag.
1619
+ */
1620
+ public static function getValue($container, $tag)
1621
+ {
1622
+ if (isset($container[ $tag ])) {
1623
+ return $container[ $tag ];
1624
+ }
1625
+
1626
+ return self::unknownTag($tag);
1627
+ }
1628
+
1629
+ /**
1630
+ * Reverse lookup of a tag id by its short name. Return false for the unknown tag name.
1631
+ *
1632
+ * @param string $name
1633
+ * tag short name.
1634
+ *
1635
+ * @return mixed (bool|int)
1636
+ * the tag.
1637
+ */
1638
+ public static function getTagByName($name)
1639
+ {
1640
+ $k = array_search($name, self::$exifTagsShort);
1641
+ if ($k !== false) {
1642
+ return $k;
1643
+ }
1644
+
1645
+ return array_search($name, static::$gpsTagsShort);
1646
+ }
1647
+
1648
+ /**
1649
+ * Returns string defining unknown tag.
1650
+ *
1651
+ * @param int $tag
1652
+ * the tag.
1653
+ *
1654
+ * @return string
1655
+ * description string.
1656
+ */
1657
+ protected static function unknownTag($tag)
1658
+ {
1659
+ return Pel::fmt('Unknown: 0x%04X', $tag);
1660
+ }
1661
+
1662
+ /**
1663
+ * Returns a short name for an Exif tag.
1664
+ *
1665
+ * @param int $type
1666
+ * the IFD type of the tag, one of {@link PelIfd::IFD0},
1667
+ * {@link PelIfd::IFD1}, {@link PelIfd::EXIF}, {@link PelIfd::GPS},
1668
+ * or {@link PelIfd::INTEROPERABILITY}.
1669
+ *
1670
+ * @param PelTag $tag
1671
+ * the tag.
1672
+ *
1673
+ * @return string the short name of the tag, e.g., 'ImageWidth' for
1674
+ * the {@link IMAGE_WIDTH} tag. If the tag is not known, the string
1675
+ * 'Unknown:0xTTTT' will be returned where 'TTTT' is the hexadecimal
1676
+ * representation of the tag.
1677
+ */
1678
+ public static function getName($type, $tag)
1679
+ {
1680
+ switch ($type) {
1681
+ case PelIfd::IFD0:
1682
+ case PelIfd::IFD1:
1683
+ case PelIfd::EXIF:
1684
+ case PelIfd::INTEROPERABILITY:
1685
+ return self::getValue(self::$exifTagsShort, $tag);
1686
+ case PelIfd::GPS:
1687
+ return self::getValue(self::$gpsTagsShort, $tag);
1688
+ }
1689
+
1690
+ return self::unknownTag($tag);
1691
+ }
1692
+
1693
+ /**
1694
+ * Returns a title for an Exif tag.
1695
+ *
1696
+ * @param int $type
1697
+ * the IFD type of the tag, one of {@link PelIfd::IFD0},
1698
+ * {@link PelIfd::IFD1}, {@link PelIfd::EXIF}, {@link PelIfd::GPS},
1699
+ * or {@link PelIfd::INTEROPERABILITY}.
1700
+ *
1701
+ * @param PelTag $tag
1702
+ * the tag.
1703
+ *
1704
+ * @return string the title of the tag, e.g., 'Image Width' for the
1705
+ * {@link IMAGE_WIDTH} tag. If the tag isn't known, the string
1706
+ * 'Unknown Tag: 0xTT' will be returned where 'TT' is the
1707
+ * hexadecimal representation of the tag.
1708
+ */
1709
+ public function getTitle($type, $tag)
1710
+ {
1711
+ switch ($type) {
1712
+ case PelIfd::IFD0:
1713
+ case PelIfd::IFD1:
1714
+ case PelIfd::EXIF:
1715
+ case PelIfd::INTEROPERABILITY:
1716
+ return Pel::tra(self::getValue(self::$exifTagsTitle, $tag));
1717
+ case PelIfd::GPS:
1718
+ return Pel::tra(self::getValue(self::$gpsTagsShort, $tag));
1719
+ }
1720
+
1721
+ return self::unknownTag($tag);
1722
+ }
1723
+ }
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelTiff.php ADDED
@@ -0,0 +1,314 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * PEL: PHP Exif Library.
5
+ * A library with support for reading and
6
+ * writing all Exif headers in JPEG and TIFF images using PHP.
7
+ *
8
+ * Copyright (C) 2004, 2005, 2006 Martin Geisler.
9
+ *
10
+ * This program is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program in the file COPYING; if not, write to the
22
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23
+ * Boston, MA 02110-1301 USA
24
+ */
25
+ namespace lsolesen\pel;
26
+
27
+ /**
28
+ * Classes for dealing with TIFF data.
29
+ *
30
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
31
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
32
+ * License (GPL)
33
+ * @package PEL
34
+ */
35
+
36
+ /**
37
+ * Class for handling TIFF data.
38
+ *
39
+ * Exif data is actually an extension of the TIFF file format. TIFF
40
+ * images consist of a number of {@link PelIfd Image File Directories}
41
+ * (IFDs), each containing a number of {@link PelEntry entries}. The
42
+ * IFDs are linked to each other --- one can get hold of the first one
43
+ * with the {@link getIfd()} method.
44
+ *
45
+ * To parse a TIFF image for Exif data one would do:
46
+ *
47
+ * <code>
48
+ * $tiff = new PelTiff($data);
49
+ * $ifd0 = $tiff->getIfd();
50
+ * $exif = $ifd0->getSubIfd(PelIfd::EXIF);
51
+ * $ifd1 = $ifd0->getNextIfd();
52
+ * </code>
53
+ *
54
+ * Should one have some image data of an unknown type, then the {@link
55
+ * PelTiff::isValid()} function is handy: it will quickly test if the
56
+ * data could be valid TIFF data. The {@link PelJpeg::isValid()}
57
+ * function does the same for JPEG images.
58
+ *
59
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
60
+ * @package PEL
61
+ */
62
+ class PelTiff
63
+ {
64
+
65
+ /**
66
+ * TIFF header.
67
+ *
68
+ * This must follow after the two bytes indicating the byte order.
69
+ */
70
+ const TIFF_HEADER = 0x002A;
71
+
72
+ /**
73
+ * The first Image File Directory, if any.
74
+ *
75
+ * If set, then the type of the IFD must be {@link PelIfd::IFD0}.
76
+ *
77
+ * @var PelIfd
78
+ */
79
+ private $ifd = null;
80
+
81
+ /**
82
+ * Construct a new object for holding TIFF data.
83
+ *
84
+ * The new object will be empty (with no {@link PelIfd}) unless an
85
+ * argument is given from which it can initialize itself. This can
86
+ * either be the filename of a TIFF image or a {@link PelDataWindow}
87
+ * object.
88
+ *
89
+ * Use {@link setIfd()} to explicitly set the IFD.
90
+ *
91
+ * @param boolean|string|PelDataWindow $data;
92
+ */
93
+ public function __construct($data = false)
94
+ {
95
+ if ($data === false) {
96
+ return;
97
+ }
98
+ if (is_string($data)) {
99
+ Pel::debug('Initializing PelTiff object from %s', $data);
100
+ $this->loadFile($data);
101
+ } elseif ($data instanceof PelDataWindow) {
102
+ Pel::debug('Initializing PelTiff object from PelDataWindow.');
103
+ $this->load($data);
104
+ } else {
105
+ throw new PelInvalidArgumentException('Bad type for $data: %s', gettype($data));
106
+ }
107
+ }
108
+
109
+ /**
110
+ * Load TIFF data.
111
+ *
112
+ * The data given will be parsed and an internal tree representation
113
+ * will be built. If the data cannot be parsed correctly, a {@link
114
+ * PelInvalidDataException} is thrown, explaining the problem.
115
+ *
116
+ * @param
117
+ * d
118
+ * PelDataWindow the data from which the object will be
119
+ * constructed. This should be valid TIFF data, coming either
120
+ * directly from a TIFF image or from the Exif data in a JPEG image.
121
+ */
122
+ public function load(PelDataWindow $d)
123
+ {
124
+ Pel::debug('Parsing %d bytes of TIFF data...', $d->getSize());
125
+
126
+ /*
127
+ * There must be at least 8 bytes available: 2 bytes for the byte
128
+ * order, 2 bytes for the TIFF header, and 4 bytes for the offset
129
+ * to the first IFD.
130
+ */
131
+ if ($d->getSize() < 8) {
132
+ throw new PelInvalidDataException('Expected at least 8 bytes of TIFF ' . 'data, found just %d bytes.', $d->getSize());
133
+ }
134
+ /* Byte order */
135
+ if ($d->strcmp(0, 'II')) {
136
+ Pel::debug('Found Intel byte order');
137
+ $d->setByteOrder(PelConvert::LITTLE_ENDIAN);
138
+ } elseif ($d->strcmp(0, 'MM')) {
139
+ Pel::debug('Found Motorola byte order');
140
+ $d->setByteOrder(PelConvert::BIG_ENDIAN);
141
+ } else {
142
+ throw new PelInvalidDataException('Unknown byte order found in TIFF ' . 'data: 0x%2X%2X', $d->getByte(0), $d->getByte(1));
143
+ }
144
+
145
+ /* Verify the TIFF header */
146
+ if ($d->getShort(2) != self::TIFF_HEADER) {
147
+ throw new PelInvalidDataException('Missing TIFF magic value.');
148
+ }
149
+ /* IFD 0 offset */
150
+ $offset = $d->getLong(4);
151
+ Pel::debug('First IFD at offset %d.', $offset);
152
+
153
+ if ($offset > 0) {
154
+ /*
155
+ * Parse the first IFD, this will automatically parse the
156
+ * following IFDs and any sub IFDs.
157
+ */
158
+ $this->ifd = new PelIfd(PelIfd::IFD0);
159
+ $this->ifd->load($d, $offset);
160
+ }
161
+ }
162
+
163
+ /**
164
+ * Load data from a file into a TIFF object.
165
+ *
166
+ * @param string $filename
167
+ * the filename. This must be a readable file.
168
+ */
169
+ public function loadFile($filename)
170
+ {
171
+ $this->load(new PelDataWindow(file_get_contents($filename)));
172
+ }
173
+
174
+ /**
175
+ * Set the first IFD.
176
+ *
177
+ * @param PelIfd $ifd
178
+ * the new first IFD, which must be of type {@link
179
+ * PelIfd::IFD0}.
180
+ */
181
+ public function setIfd(PelIfd $ifd)
182
+ {
183
+ if ($ifd->getType() != PelIfd::IFD0) {
184
+ throw new PelInvalidDataException('Invalid type of IFD: %d, expected %d.', $ifd->getType(), PelIfd::IFD0);
185
+ }
186
+ $this->ifd = $ifd;
187
+ }
188
+
189
+ /**
190
+ * Return the first IFD.
191
+ *
192
+ * @return PelIfd the first IFD contained in the TIFF data, if any.
193
+ * If there is no IFD null will be returned.
194
+ */
195
+ public function getIfd()
196
+ {
197
+ return $this->ifd;
198
+ }
199
+
200
+ /**
201
+ * Turn this object into bytes.
202
+ *
203
+ * TIFF images can have {@link PelConvert::LITTLE_ENDIAN
204
+ * little-endian} or {@link PelConvert::BIG_ENDIAN big-endian} byte
205
+ * order, and so this method takes an argument specifying that.
206
+ *
207
+ * @param PelByteOrder $order
208
+ * the desired byte order of the TIFF data.
209
+ * This should be one of {@link PelConvert::LITTLE_ENDIAN} or {@link
210
+ * PelConvert::BIG_ENDIAN}.
211
+ *
212
+ * @return string the bytes representing this object.
213
+ */
214
+ public function getBytes($order = PelConvert::LITTLE_ENDIAN)
215
+ {
216
+ if ($order == PelConvert::LITTLE_ENDIAN) {
217
+ $bytes = 'II';
218
+ } else {
219
+ $bytes = 'MM';
220
+ }
221
+
222
+ /* TIFF magic number --- fixed value. */
223
+ $bytes .= PelConvert::shortToBytes(self::TIFF_HEADER, $order);
224
+
225
+ if ($this->ifd !== null) {
226
+ /*
227
+ * IFD 0 offset. We will always start IDF 0 at an offset of 8
228
+ * bytes (2 bytes for byte order, another 2 bytes for the TIFF
229
+ * header, and 4 bytes for the IFD 0 offset make 8 bytes
230
+ * together).
231
+ */
232
+ $bytes .= PelConvert::longToBytes(8, $order);
233
+
234
+ /*
235
+ * The argument specifies the offset of this IFD. The IFD will
236
+ * use this to calculate offsets from the entries to their data,
237
+ * all those offsets are absolute offsets counted from the
238
+ * beginning of the data.
239
+ */
240
+ $bytes .= $this->ifd->getBytes(8, $order);
241
+ } else {
242
+ $bytes .= PelConvert::longToBytes(0, $order);
243
+ }
244
+
245
+ return $bytes;
246
+ }
247
+
248
+ /**
249
+ * Save the TIFF object as a TIFF image in a file.
250
+ *
251
+ * @param
252
+ * string the filename to save in. An existing file with the
253
+ * same name will be overwritten!
254
+ *
255
+ * @return integer|FALSE The number of bytes that were written to the
256
+ * file, or FALSE on failure.
257
+ */
258
+ public function saveFile($filename)
259
+ {
260
+ return file_put_contents($filename, $this->getBytes());
261
+ }
262
+
263
+ /**
264
+ * Return a string representation of this object.
265
+ *
266
+ * @return string a string describing this object. This is mostly useful
267
+ * for debugging.
268
+ */
269
+ public function __toString()
270
+ {
271
+ $str = Pel::fmt("Dumping TIFF data...\n");
272
+ if ($this->ifd !== null) {
273
+ $str .= $this->ifd->__toString();
274
+ }
275
+
276
+ return $str;
277
+ }
278
+
279
+ /**
280
+ * Check if data is valid TIFF data.
281
+ *
282
+ * This will read just enough data from the data window to determine
283
+ * if the data could be a valid TIFF data. This means that the
284
+ * check is more like a heuristic than a rigorous check.
285
+ *
286
+ * @param PelDataWindow $d
287
+ * the bytes that will be examined.
288
+ *
289
+ * @return boolean true if the data looks like valid TIFF data,
290
+ * false otherwise.
291
+ *
292
+ * @see PelJpeg::isValid()
293
+ */
294
+ public static function isValid(PelDataWindow $d)
295
+ {
296
+ /* First check that we have enough data. */
297
+ if ($d->getSize() < 8) {
298
+ return false;
299
+ }
300
+
301
+ /* Byte order */
302
+ if ($d->strcmp(0, 'II')) {
303
+ $d->setByteOrder(PelConvert::LITTLE_ENDIAN);
304
+ } elseif ($d->strcmp(0, 'MM')) {
305
+ Pel::debug('Found Motorola byte order');
306
+ $d->setByteOrder(PelConvert::BIG_ENDIAN);
307
+ } else {
308
+ return false;
309
+ }
310
+
311
+ /* Verify the TIFF header */
312
+ return $d->getShort(2) == self::TIFF_HEADER;
313
+ }
314
+ }
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelUnexpectedFormatException.php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * PEL: PHP Exif Library.
5
+ * A library with support for reading and
6
+ * writing all Exif headers in JPEG and TIFF images using PHP.
7
+ *
8
+ * Copyright (C) 2004, 2005, 2006 Martin Geisler.
9
+ *
10
+ * This program is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program in the file COPYING; if not, write to the
22
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23
+ * Boston, MA 02110-1301 USA
24
+ */
25
+ namespace lsolesen\pel;
26
+
27
+ /**
28
+ * Classes for dealing with Exif entries.
29
+ *
30
+ * This file defines two exception classes and the abstract class
31
+ * {@link PelEntry} which provides the basic methods that all Exif
32
+ * entries will have. All Exif entries will be represented by
33
+ * descendants of the {@link PelEntry} class --- the class itself is
34
+ * abstract and so it cannot be instantiated.
35
+ *
36
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
37
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
38
+ * License (GPL)
39
+ * @package PEL
40
+ */
41
+
42
+ /**
43
+ * Exception indicating that an unexpected format was found.
44
+ *
45
+ * The documentation for each tag in {@link PelTag} will detail any
46
+ * constrains.
47
+ *
48
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
49
+ * @package PEL
50
+ * @subpackage Exception
51
+ */
52
+ class PelUnexpectedFormatException extends PelEntryException
53
+ {
54
+
55
+ /**
56
+ * Construct a new exception indicating an invalid format.
57
+ *
58
+ * @param int $type
59
+ * the type of IFD.
60
+ *
61
+ * @param int $tag
62
+ * the tag for which the violation was found as defined in {@link PelTag}
63
+ *
64
+ * @param int $found
65
+ * the format found as defined in {@link PelFormat}
66
+ *
67
+ * @param int $expected
68
+ * the expected as defined in {@link PelFormat}
69
+ */
70
+ public function __construct($type, $tag, $found, $expected)
71
+ {
72
+ parent::__construct(
73
+ 'Unexpected format found for %s tag: PelFormat::%s. Expected PelFormat::%s instead.',
74
+ PelTag::getName($type, $tag),
75
+ strtoupper(PelFormat::getName($found)),
76
+ strtoupper(PelFormat::getName($expected)));
77
+ $this->tag = $tag;
78
+ $this->type = $type;
79
+ }
80
+ }
products/photocrati_nextgen/modules/nextgen_data/pel-0.9.6/src/PelWrongComponentCountException.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * PEL: PHP Exif Library.
5
+ * A library with support for reading and
6
+ * writing all Exif headers in JPEG and TIFF images using PHP.
7
+ *
8
+ * Copyright (C) 2004, 2005, 2006 Martin Geisler.
9
+ *
10
+ * This program is free software; you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation; either version 2 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * This program is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with this program in the file COPYING; if not, write to the
22
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23
+ * Boston, MA 02110-1301 USA
24
+ */
25
+ namespace lsolesen\pel;
26
+
27
+ /**
28
+ * Classes for dealing with Exif entries.
29
+ *
30
+ * This file defines two exception classes and the abstract class
31
+ * {@link PelEntry} which provides the basic methods that all Exif
32
+ * entries will have. All Exif entries will be represented by
33
+ * descendants of the {@link PelEntry} class --- the class itself is
34
+ * abstract and so it cannot be instantiated.
35
+ *
36
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
37
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
38
+ * License (GPL)
39
+ * @package PEL
40
+ */
41
+ use lsolesen\pel\PelTag;
42
+
43
+ /**
44
+ * Exception indicating that an unexpected number of components was
45
+ * found.
46
+ *
47
+ * Some tags have strict limits as to the allowed number of
48
+ * components, and this exception is thrown if the data violates such
49
+ * a constraint. The documentation for each tag in {@link PelTag}
50
+ * explains the expected number of components.
51
+ *
52
+ * @author Martin Geisler <mgeisler@users.sourceforge.net>
53
+ * @package PEL
54
+ * @subpackage Exception
55
+ */
56
+ class PelWrongComponentCountException extends \lsolesen\pel\PelEntryException
57
+ {
58
+
59
+ /**
60
+ * Construct a new exception indicating a wrong number of
61
+ * components.
62
+ *
63
+ * @param int $type
64
+ * the type of IFD.
65
+ *
66
+ * @param PelTag $tag
67
+ * the tag for which the violation was found.
68
+ *
69
+ * @param int $found
70
+ * the number of components found.
71
+ *
72
+ * @param int $expected
73
+ * the expected number of components.
74
+ */
75
+ public function __construct($type, $tag, $found, $expected)
76
+ {
77
+ parent::__construct('Wrong number of components found for %s tag: %d. ' . 'Expected %d.', PelTag::getName($type, $tag), $found, $expected);
78
+ $this->tag = $tag;
79
+ $this->type = $type;
80
+ }
81
+ }
products/photocrati_nextgen/modules/nextgen_gallery_display/package.module.nextgen_gallery_display.php CHANGED
@@ -2291,6 +2291,38 @@ class Mixin_Display_Type_Form extends Mixin
2291
  {
2292
  $this->object->implement('I_Display_Type_Form');
2293
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2294
  /**
2295
  * Returns the name of the display type. Sub-class should override
2296
  * @throws Exception
2291
  {
2292
  $this->object->implement('I_Display_Type_Form');
2293
  }
2294
+ /**
2295
+ * A wrapper to wp_enqueue_script() and ATP's mark_script()
2296
+ *
2297
+ * Unlike wp_enqueue_script() the version parameter is last as NGG should always use NGG_SCRIPT_VERSION
2298
+ * @param string $handle
2299
+ * @param string $source
2300
+ * @param array $dependencies
2301
+ * @param bool $in_footer
2302
+ * @param string $version
2303
+ */
2304
+ public function enqueue_script($handle, $source = '', $dependencies = array(), $in_footer = FALSE, $version = NGG_SCRIPT_VERSION)
2305
+ {
2306
+ wp_enqueue_script($handle, $source, $dependencies, $version, $in_footer);
2307
+ $atp = C_Attach_Controller::get_instance();
2308
+ if ($atp !== NULL) {
2309
+ $atp->mark_script($handle);
2310
+ }
2311
+ }
2312
+ /**
2313
+ * A wrapper to wp_enqueue_style()
2314
+ *
2315
+ * Unlike wp_enqueue_style() the version parameter is last as NGG should always use NGG_SCRIPT_VERSION
2316
+ * @param string $handle
2317
+ * @param string $source
2318
+ * @param array $dependencies
2319
+ * @param string $media
2320
+ * @param string $version
2321
+ */
2322
+ public function enqueue_style($handle, $source = '', $dependencies = array(), $media = 'all', $version = NGG_SCRIPT_VERSION)
2323
+ {
2324
+ wp_enqueue_style($handle, $source, $dependencies, $version, $media);
2325
+ }
2326
  /**
2327
  * Returns the name of the display type. Sub-class should override
2328
  * @throws Exception
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: photocrati, imagely
3
  Tags: wordpress gallery plugin, gallery, nextgen, nextgen gallery, photo gallery, image gallery, photography, slideshow, images, photo, photo album, watermark
4
  Requires at least: 4.0.0
5
- Stable tag: 2.2.12
6
- Tested up to: 4.8.0
7
  License: GPLv2
8
 
9
  The most popular WordPress gallery plugin and one of the most popular plugins of all time with over 18 million downloads.
@@ -187,6 +187,10 @@ For more information, feel free to visit the official website for the NextGEN Ga
187
 
188
  == Changelog ==
189
 
 
 
 
 
190
  = V2.2.12 - 08.01.2017 =
191
  * Secured: Disabled Flash backend in plupload
192
  * Changed: Upgraded PHP-Parser version used when building plugin zips
2
  Contributors: photocrati, imagely
3
  Tags: wordpress gallery plugin, gallery, nextgen, nextgen gallery, photo gallery, image gallery, photography, slideshow, images, photo, photo album, watermark
4
  Requires at least: 4.0.0
5
+ Stable tag: 2.3.0
6
+ Tested up to: 4.8.1
7
  License: GPLv2
8
 
9
  The most popular WordPress gallery plugin and one of the most popular plugins of all time with over 18 million downloads.
187
 
188
  == Changelog ==
189
 
190
+ = V2.2.14 - 09.18.2017 =
191
+ * NEW: EXIF and IPTC metadata are copied to new images when generating thumbnails, watermarks, or new sizes
192
+ * Fixed: Metadata is read and preserved when "Resized images after upload" feature is enabled
193
+
194
  = V2.2.12 - 08.01.2017 =
195
  * Secured: Disabled Flash backend in plupload
196
  * Changed: Upgraded PHP-Parser version used when building plugin zips