Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Raw photo support #65

Merged
merged 39 commits into from over 2 years ago

2 participants

Chad Parry Bharat Mediratta
Chad Parry

This patch provides raw photo support in a third party module. When a raw photo is uploaded, it is immediately converted to a JPEG. All subsequent Gallery operations work exclusively with the JPEG. Changes also had to be made to the Keep Original module, because it was only listening to rotate events, and because that event handler was broken. This patch relies on small changes to the framework, (see gallery/gallery3#47). This pull request supercedes request #62.

added some commits April 21, 2011
Chad Parry Add support for raw photo formats. 8500fba
Chad Parry Report as a site status when the graphics toolkit doesn't support Raw…
… Photos.
6013e96
Chad Parry Use the "self" reference. b276808
Chad Parry Merge branch 'master' of github.com:chadparry/gallery3-contrib into r…
…awphoto
1080f65
Chad Parry Don't forget to escape unsafe characters in error messages. 50d7feb
Chad Parry Error messages should be able to contain HTML.
This reverts commit 50d7feb.
1347f03
Chad Parry Convert raw photos during an item_created event rather than a graphic…
…s rule.
078d81a
Chad Parry Use the system::tempnam substitute so that extensions are handled saf…
…ely.
c39fc9a
Chad Parry Update a deprecated method and poor preg syntax so that the Keep Orig…
…inal module will work.
dd6c9f2
Chad Parry Extend the Keep Original module so that it is triggered by updated da…
…ta files.
e3db324
Chad Parry Use the new get_data_file() helper instead of reaching inside the item. 79f0bc8
Chad Parry Mark an internal helper method as private. ab93a47
Chad Parry Merge branch 'master' of git://github.com/gallery/gallery3-contrib in…
…to rawphoto
a9a0871
Chad Parry Add a TODO to point out that the original's extension shouldn't be ch…
…anged.
add2406
Chad Parry Warn the user if they are using the Raw Photos module but not the Kee…
…p Original module.
7b8ceac
Chad Parry Fill in the extra new fields for the module info. e1a15fb
Chad Parry Add a site status warning for when dcraw is not installed. 9796ea6
Chad Parry Merge branch 'master' of git://github.com/gallery/gallery3-contrib in…
…to rawphoto
63c657f
Chad Parry Remove a newline at the end of the file that I accidentally introduced. dcc3fb9
Chad Parry Change the name of the extensions helper to legal_file. 89775a6
Chad Parry The signature of system::tempname changed. 3a90b86
Chad Parry The data_file field is public, so we don't need to use an accessor me…
…thod.
a7ab445
Chad Parry Merge branch 'master' of git://github.com/gallery/gallery3-contrib in…
…to rawphoto
9e8f733
Chad Parry Avoid "self::" because Kohana can't override it. 4c4e4ef
Chad Parry Add a missing semicolon pointed out by @floridave. cf8e465
Chad Parry Merge branch 'master' of git://github.com/gallery/gallery3-contrib in…
…to rawphoto
127070d
Chad Parry Handle the new legal_file events. 5de3500
Chad Parry Some versions of dcraw emit usage info to stderr instead of stdout. A…
…lso, italicize dcraw and module titles.
bb9715a
Chad Parry Selectively omit dcraw options that would not be supported by the cur…
…rently installed version.
8ad5599
Chad Parry Upgrade to version 2, since older versions of dcraw are now supported. 190b5e0
Chad Parry Fix the module version to match module.info 9d0d193
Chad Parry Merge branch 'master' into rawphoto a7ebe43
Chad Parry Require a version of the Gallery framework that supports the new item…
… conversion features
d0a90e4
Chad Parry Bump the version number to 3 9e3e3c5
Chad Parry Improve handling for more raw image types from rawsamples.ch 0ea4670
Chad Parry Remove a newline at the end of the file that I accidentally introduce…
…d again!
d9e5444
Chad Parry Avoid "self::" because Kohana can't override it. 3a3c394
Chad Parry Remove a trailing newline again! 5c5fc56
Chad Parry Merge branch 'master' into rawphoto 18688da
Chad Parry

Now that the Gallery framework changes are committed, and also pull request #80 is in, this version of my module is ready to be committed. Thanks!

Bharat Mediratta bharat merged commit 53abda7 into from August 20, 2011
Bharat Mediratta bharat closed this August 20, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 39 unique commits by 1 author.

Apr 21, 2011
Chad Parry Add support for raw photo formats. 8500fba
Chad Parry Report as a site status when the graphics toolkit doesn't support Raw…
… Photos.
6013e96
Chad Parry Use the "self" reference. b276808
Apr 22, 2011
Chad Parry Merge branch 'master' of github.com:chadparry/gallery3-contrib into r…
…awphoto
1080f65
Chad Parry Don't forget to escape unsafe characters in error messages. 50d7feb
Chad Parry Error messages should be able to contain HTML.
This reverts commit 50d7feb.
1347f03
Apr 23, 2011
Chad Parry Convert raw photos during an item_created event rather than a graphic…
…s rule.
078d81a
Chad Parry Use the system::tempnam substitute so that extensions are handled saf…
…ely.
c39fc9a
Chad Parry Update a deprecated method and poor preg syntax so that the Keep Orig…
…inal module will work.
dd6c9f2
Chad Parry Extend the Keep Original module so that it is triggered by updated da…
…ta files.
e3db324
Apr 24, 2011
Chad Parry Use the new get_data_file() helper instead of reaching inside the item. 79f0bc8
Chad Parry Mark an internal helper method as private. ab93a47
Chad Parry Merge branch 'master' of git://github.com/gallery/gallery3-contrib in…
…to rawphoto
a9a0871
Chad Parry Add a TODO to point out that the original's extension shouldn't be ch…
…anged.
add2406
Chad Parry Warn the user if they are using the Raw Photos module but not the Kee…
…p Original module.
7b8ceac
Apr 25, 2011
Chad Parry Fill in the extra new fields for the module info. e1a15fb
Chad Parry Add a site status warning for when dcraw is not installed. 9796ea6
Apr 27, 2011
Chad Parry Merge branch 'master' of git://github.com/gallery/gallery3-contrib in…
…to rawphoto
63c657f
Chad Parry Remove a newline at the end of the file that I accidentally introduced. dcc3fb9
Apr 30, 2011
Chad Parry Change the name of the extensions helper to legal_file. 89775a6
Chad Parry The signature of system::tempname changed. 3a90b86
Chad Parry The data_file field is public, so we don't need to use an accessor me…
…thod.
a7ab445
Chad Parry Merge branch 'master' of git://github.com/gallery/gallery3-contrib in…
…to rawphoto
9e8f733
May 04, 2011
Chad Parry Avoid "self::" because Kohana can't override it. 4c4e4ef
May 05, 2011
Chad Parry Add a missing semicolon pointed out by @floridave. cf8e465
May 18, 2011
Chad Parry Merge branch 'master' of git://github.com/gallery/gallery3-contrib in…
…to rawphoto
127070d
Chad Parry Handle the new legal_file events. 5de3500
Jun 09, 2011
Chad Parry Some versions of dcraw emit usage info to stderr instead of stdout. A…
…lso, italicize dcraw and module titles.
bb9715a
Chad Parry Selectively omit dcraw options that would not be supported by the cur…
…rently installed version.
8ad5599
Chad Parry Upgrade to version 2, since older versions of dcraw are now supported. 190b5e0
Jul 27, 2011
Chad Parry Fix the module version to match module.info 9d0d193
Chad Parry Merge branch 'master' into rawphoto a7ebe43
Chad Parry Require a version of the Gallery framework that supports the new item…
… conversion features
d0a90e4
Chad Parry Bump the version number to 3 9e3e3c5
Chad Parry Improve handling for more raw image types from rawsamples.ch 0ea4670
Jul 28, 2011
Chad Parry Remove a newline at the end of the file that I accidentally introduce…
…d again!
d9e5444
Chad Parry Avoid "self::" because Kohana can't override it. 3a3c394
Chad Parry Remove a trailing newline again! 5c5fc56
Chad Parry Merge branch 'master' into rawphoto 18688da
This page is out of date. Refresh to see the latest.
74  3.0/modules/rawphoto/controllers/admin_rawphoto.php
... ...
@@ -0,0 +1,74 @@
  1
+<?php defined("SYSPATH") or die("No direct script access.");
  2
+/**
  3
+ * Gallery - a web based photo album viewer and editor
  4
+ * Copyright (C) 2011 Chad Parry
  5
+ *
  6
+ * This program is free software; you can redistribute it and/or modify
  7
+ * it under the terms of the GNU General Public License as published by
  8
+ * the Free Software Foundation; either version 2 of the License, or (at
  9
+ * your option) any later version.
  10
+ *
  11
+ * This program is distributed in the hope that it will be useful, but
  12
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
  13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14
+ * General Public License for more details.
  15
+ *
  16
+ * You should have received a copy of the GNU General Public License
  17
+ * along with this program; if not, write to the Free Software
  18
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA  02110-1301, USA.
  19
+ */
  20
+class Admin_RawPhoto_Controller extends Admin_Controller {
  21
+  public function index() {
  22
+    print $this->_get_view();
  23
+  }
  24
+
  25
+  private function _get_view($errors = array(), $icc_path = null) {
  26
+    $dcraw = rawphoto_graphics::detect_dcraw();
  27
+    rawphoto_graphics::report_dcraw_support($dcraw);
  28
+
  29
+    $view = new Admin_View("admin.html");
  30
+    $view->content = new View("admin_rawphoto.html");
  31
+    $view->content->is_keeporiginal_active = module::is_active("keeporiginal");
  32
+    $view->content->dcraw = $dcraw;
  33
+    $toolkit_names = array("imagemagick" => "ImageMagick",
  34
+                           "graphicsmagick" => "GraphicsMagick");
  35
+    $toolkit_id = module::get_var("gallery", "graphics_toolkit");
  36
+    $toolkit_names = rawphoto_graphics::get_supported_toolkits();
  37
+    $view->content->toolkit_name = array_key_exists($toolkit_id, $toolkit_names) ?
  38
+                                   $toolkit_names[$toolkit_id] : "none";
  39
+    $view->content->icc_path = isset($icc_path) ?
  40
+                               $icc_path : module::get_var("rawphoto", "icc_path");
  41
+    $view->content->errors = $errors;
  42
+    return $view;
  43
+  }
  44
+
  45
+  public function saveprefs() {
  46
+    // Prevent Cross Site Request Forgery
  47
+    access::verify_csrf();
  48
+
  49
+    $post = new Validation($_POST);
  50
+    $post->add_callbacks("IccPath", array($this, "_validate_icc_path"));
  51
+    $icc_path = Input::instance()->post("IccPath");
  52
+    if ($post->validate()) {
  53
+      module::set_var("rawphoto", "icc_path", $icc_path);
  54
+      message::success(t("Your preferences have been saved."));
  55
+    } else {
  56
+      message::error(t("Your preferences are not valid."));
  57
+    }
  58
+
  59
+    print $this->_get_view($post->errors(), $icc_path);
  60
+  }
  61
+
  62
+  public function _validate_icc_path(Validation $post, $field) {
  63
+    if (!empty($post->$field)) {
  64
+      if (!@is_file($post->$field)) {
  65
+        $post->add_error($field, t("No ICC profile exists at the location <code>%icc_path</code>",
  66
+                                   array("icc_path" => $post->$field)));
  67
+      }
  68
+      $dcraw = rawphoto_graphics::detect_dcraw();
  69
+      if (version_compare($dcraw->version, "8.00", "<")) {
  70
+        $post->add_error($field, t("Versions of <em>dcraw</em> before <code>8.00</code> do not support an ICC profile"));
  71
+      }
  72
+    }
  73
+  }
  74
+}
66  3.0/modules/rawphoto/helpers/rawphoto_event.php
... ...
@@ -0,0 +1,66 @@
  1
+<?php defined("SYSPATH") or die("No direct script access.");
  2
+/**
  3
+ * Gallery - a web based photo album viewer and editor
  4
+ * Copyright (C) 2011 Chad Parry
  5
+ *
  6
+ * This program is free software; you can redistribute it and/or modify
  7
+ * it under the terms of the GNU General Public License as published by
  8
+ * the Free Software Foundation; either version 2 of the License, or (at
  9
+ * your option) any later version.
  10
+ *
  11
+ * This program is distributed in the hope that it will be useful, but
  12
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
  13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14
+ * General Public License for more details.
  15
+ *
  16
+ * You should have received a copy of the GNU General Public License
  17
+ * along with this program; if not, write to the Free Software
  18
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA  02110-1301, USA.
  19
+ */
  20
+class rawphoto_event_Core {
  21
+  static function item_created($item) {
  22
+    if ($item->is_photo()) {
  23
+      $input_file = $item->file_path();
  24
+      $output_file = system::temp_filename("rawphoto-", "jpg");
  25
+      $success = rawphoto_graphics::convert($input_file, $output_file);
  26
+      if ($success) {
  27
+        $item->set_data_file($output_file);
  28
+        $item->save();
  29
+        unlink($output_file);
  30
+      }
  31
+    }
  32
+  }
  33
+
  34
+  static function admin_menu($menu, $theme) {
  35
+    $menu->get("settings_menu")
  36
+         ->append(Menu::factory("link")
  37
+         ->id("rawphoto")
  38
+         ->label(t("Raw Photos"))
  39
+         ->url(url::site("admin/rawphoto")));
  40
+  }
  41
+
  42
+  static function legal_photo_extensions($extensions_wrapper) {
  43
+    array_push($extensions_wrapper->extensions,
  44
+               "3fr", "arw", "bay", "bmq", "cr2", "crw", "cs1", "dc2", "dcr", "dng", "erf",
  45
+               "fff", "k25", "kdc", "mef", "mos", "mrw", "nef", "orf", "pef", "raf", "raw",
  46
+               "rdc", "rw2", "sr2", "srf", "x3f");
  47
+  }
  48
+
  49
+  static function legal_photo_types($types_wrapper) {
  50
+    array_push($types_wrapper->types,
  51
+               // Most raw photos are detected as TIFF.
  52
+               "image/tiff",
  53
+               // Minolta raw photos are mis-detected as wireless bitmap format.
  54
+               "image/vnd.wap.wbmp",
  55
+               // All other raw photos have unrecognized formats.
  56
+               "");
  57
+  }
  58
+
  59
+  static function module_change($changes) {
  60
+    rawphoto_version::report_item_conversion_support();
  61
+  }
  62
+
  63
+  static function graphics_toolkit_change($toolkit_id) {
  64
+    rawphoto_graphics::report_ppm_support($toolkit_id);
  65
+  }
  66
+}
128  3.0/modules/rawphoto/helpers/rawphoto_graphics.php
... ...
@@ -0,0 +1,128 @@
  1
+<?php defined("SYSPATH") or die("No direct script access.");
  2
+/**
  3
+ * Gallery - a web based photo album viewer and editor
  4
+ * Copyright (C) 2011 Chad Parry
  5
+ *
  6
+ * This program is free software; you can redistribute it and/or modify
  7
+ * it under the terms of the GNU General Public License as published by
  8
+ * the Free Software Foundation; either version 2 of the License, or (at
  9
+ * your option) any later version.
  10
+ *
  11
+ * This program is distributed in the hope that it will be useful, but
  12
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
  13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14
+ * General Public License for more details.
  15
+ *
  16
+ * You should have received a copy of the GNU General Public License
  17
+ * along with this program; if not, write to the Free Software
  18
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA  02110-1301, USA.
  19
+ */
  20
+class rawphoto_graphics {
  21
+  static function detect_dcraw() {
  22
+    $dcraw = new stdClass();
  23
+    $path = system::find_binary("dcraw");
  24
+    if (empty($path)) {
  25
+      $dcraw->installed = false;
  26
+      $dcraw->error = t("The <em>dcraw</em> tool could not be located on your system.");
  27
+    } else {
  28
+      $dcraw->path = $path;
  29
+      if (!@is_file($path)) {
  30
+        $dcraw->installed = false;
  31
+        $dcraw->error = t("The <em>dcraw</em> tool is installed, " .
  32
+                          "but PHP's <code>open_basedir</code> restriction " .
  33
+                          "prevents Gallery from using it.");
  34
+      } else if (!preg_match('/^Raw [Pp]hoto [Dd]ecoder(?: "dcraw")? v(\S+)$/m',
  35
+                             shell_exec(escapeshellcmd($path) . " 2>&1"), $matches)) {
  36
+        $dcraw->installed = false;
  37
+        $dcraw->error = t("The <em>dcraw</em> tool is installed, " .
  38
+                          "but the version is not recognized.");
  39
+      } else {
  40
+        $dcraw->version = $matches[1];
  41
+        $dcraw->installed = true;
  42
+      }
  43
+    }
  44
+    return $dcraw;
  45
+  }
  46
+
  47
+  static function get_supported_toolkits() {
  48
+    return array("imagemagick" => "ImageMagick",
  49
+                 "graphicsmagick" => "GraphicsMagick");
  50
+  }
  51
+
  52
+  static function report_dcraw_support($dcraw) {
  53
+    if ($dcraw->installed) {
  54
+      site_status::clear("rawphoto_needs_dcraw");
  55
+    } else {
  56
+      site_status::warning(
  57
+        t('The <em>Raw Photos</em> module requires the <a href="%dcraw_url"><em>dcraw</em> tool</a> to be installed.',
  58
+          array("dcraw_url" => "http://www.cybercom.net/~dcoffin/dcraw/")),
  59
+        "rawphoto_needs_dcraw");
  60
+    }
  61
+  }
  62
+
  63
+  static function report_ppm_support($toolkit_id) {
  64
+    if (array_key_exists($toolkit_id, rawphoto_graphics::get_supported_toolkits())) {
  65
+      site_status::clear("rawphoto_needs_ppm_support");
  66
+    } else {
  67
+      site_status::warning(
  68
+        t('The <em>Raw Photos</em> module requires a supporting graphics toolkit. ' .
  69
+          '<a href="%activate_url">Activate</a> either ImageMagick or GraphicsMagick.',
  70
+          array("activate_url" => url::site("admin/graphics"))),
  71
+        "rawphoto_needs_ppm_support");
  72
+    }
  73
+  }
  74
+
  75
+  static function convert($input_file, $output_file) {
  76
+    $success = false;
  77
+    $dcraw = rawphoto_graphics::detect_dcraw();
  78
+    if ($dcraw->installed) {
  79
+      // Use dcraw to convert from a raw image to a standard pixmap.
  80
+      $cmd = escapeshellcmd($dcraw->path) . " -c -w ";
  81
+      if (version_compare($dcraw->version, "6.00", ">=")) {
  82
+        $cmd .= "-t 0 ";
  83
+      }
  84
+      if (version_compare($dcraw->version, "8.81", ">=")) {
  85
+        $cmd .= "-W ";
  86
+      }
  87
+      $icc_path = module::get_var("rawphoto", "icc_path");
  88
+      if (!empty($icc_path) && version_compare($dcraw->version, "8.00", ">=")) {
  89
+        $cmd .= "-p " . escapeshellarg($icc_path) . " ";
  90
+      }
  91
+      $cmd .= escapeshellarg($input_file);
  92
+
  93
+      // Then use the graphics toolkit to convert the stream to a JPEG.
  94
+      $cmd .= " | ";
  95
+      $toolkit_id = module::get_var("gallery", "graphics_toolkit");
  96
+      $toolkit_path = module::get_var("gallery", "graphics_toolkit_path");
  97
+      $image_quality = module::get_var("gallery", "image_quality");
  98
+      $toolkit_compat = false;
  99
+      switch ($toolkit_id) {
  100
+        case 'imagemagick':
  101
+          $cmd .= escapeshellcmd("$toolkit_path/convert");
  102
+          $cmd .= " -quality " . escapeshellarg($image_quality . "%");
  103
+          $cmd .= " - " . escapeshellarg($output_file);
  104
+          $toolkit_compat = true;
  105
+          break;
  106
+        case 'graphicsmagick':
  107
+          $cmd .= escapeshellcmd("$toolkit_path/gm");
  108
+          $cmd .= " convert -quality " . escapeshellarg($image_quality . "%");
  109
+          $cmd .= " - " . escapeshellarg($output_file);
  110
+          $toolkit_compat = true;
  111
+          break;
  112
+        default:
  113
+          log::warning("rawphoto", "Cannot convert raw photo with graphics toolkit: " .
  114
+                                   $toolkit_id->active);
  115
+      }
  116
+
  117
+      if ($toolkit_compat) {
  118
+        exec($cmd, $output, $return_var);
  119
+        // Failure is common, because dcraw will abort unless the original image is a raw photo.
  120
+        $success = ($return_var == 0);
  121
+        if (!$success) {
  122
+          @unlink($output_file);
  123
+        }
  124
+      }
  125
+    }
  126
+    return $success;
  127
+  }
  128
+}
38  3.0/modules/rawphoto/helpers/rawphoto_installer.php
... ...
@@ -0,0 +1,38 @@
  1
+<?php defined("SYSPATH") or die("No direct script access.");
  2
+/**
  3
+ * Gallery - a web based photo album viewer and editor
  4
+ * Copyright (C) 2011 Chad Parry
  5
+ *
  6
+ * This program is free software; you can redistribute it and/or modify
  7
+ * it under the terms of the GNU General Public License as published by
  8
+ * the Free Software Foundation; either version 2 of the License, or (at
  9
+ * your option) any later version.
  10
+ *
  11
+ * This program is distributed in the hope that it will be useful, but
  12
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
  13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14
+ * General Public License for more details.
  15
+ *
  16
+ * You should have received a copy of the GNU General Public License
  17
+ * along with this program; if not, write to the Free Software
  18
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA  02110-1301, USA.
  19
+ */
  20
+class rawphoto_installer {
  21
+  static function install() {
  22
+    module::set_version("rawphoto", 3);
  23
+  }
  24
+
  25
+  static function activate() {
  26
+    rawphoto_version::report_item_conversion_support();
  27
+    $dcraw = rawphoto_graphics::detect_dcraw();
  28
+    rawphoto_graphics::report_dcraw_support($dcraw);
  29
+    $toolkit_id = module::get_var("gallery", "graphics_toolkit");
  30
+    rawphoto_graphics::report_ppm_support($toolkit_id);
  31
+  }
  32
+
  33
+  static function deactivate() {
  34
+    site_status::clear("rawphoto_needs_item_conversion_support");
  35
+    site_status::clear("rawphoto_needs_dcraw");
  36
+    site_status::clear("rawphoto_needs_ppm_support");
  37
+  }
  38
+}
46  3.0/modules/rawphoto/helpers/rawphoto_version.php
... ...
@@ -0,0 +1,46 @@
  1
+<?php defined("SYSPATH") or die("No direct script access.");
  2
+/**
  3
+ * Gallery - a web based photo album viewer and editor
  4
+ * Copyright (C) 2011 Chad Parry
  5
+ *
  6
+ * This program is free software; you can redistribute it and/or modify
  7
+ * it under the terms of the GNU General Public License as published by
  8
+ * the Free Software Foundation; either version 2 of the License, or (at
  9
+ * your option) any later version.
  10
+ *
  11
+ * This program is distributed in the hope that it will be useful, but
  12
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
  13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14
+ * General Public License for more details.
  15
+ *
  16
+ * You should have received a copy of the GNU General Public License
  17
+ * along with this program; if not, write to the Free Software
  18
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA  02110-1301, USA.
  19
+ */
  20
+class rawphoto_version {
  21
+  const MIN_RELEASE_VERSION = "3.0.3";
  22
+  const MIN_BUILD_NUMBER = "164";
  23
+
  24
+  static function report_item_conversion_support() {
  25
+    if (gallery::RELEASE_CHANNEL == "release") {
  26
+      if (version_compare(gallery::VERSION, rawphoto_version::MIN_RELEASE_VERSION, ">=")) {
  27
+        site_status::clear("rawphoto_needs_item_conversion_support");
  28
+      } else {
  29
+        site_status::warning(
  30
+          t("The <em>Raw Photos</em> module requires Gallery %version or higher.",
  31
+            array("version" => rawphoto_version::MIN_RELEASE_VERSION)),
  32
+          "rawphoto_needs_item_conversion_support");
  33
+      }
  34
+    } else {
  35
+      if (version_compare(gallery::build_number(), rawphoto_version::MIN_BUILD_NUMBER, ">=")) {
  36
+        site_status::clear("rawphoto_needs_item_conversion_support");
  37
+      } else {
  38
+        site_status::warning(
  39
+          t("The <em>Raw Photos</em> module requires Gallery %version, build %build_number or higher.",
  40
+            array("version" => gallery::VERSION,
  41
+                  "build_number" => rawphoto_version::MIN_BUILD_NUMBER)),
  42
+          "rawphoto_needs_item_conversion_support");
  43
+      }
  44
+    }
  45
+  }
  46
+}
7  3.0/modules/rawphoto/module.info
... ...
@@ -0,0 +1,7 @@
  1
+name = "Raw Photos"
  2
+description = "Use raw photos produced by a digital camera."
  3
+version = 3
  4
+author_name = "Chad Parry"
  5
+author_url = "http://codex.gallery2.org/User:Chadparry"
  6
+info_url = "http://codex.gallery2.org/Gallery3:Modules:rawphoto"
  7
+discuss_url = "http://gallery.menalto.com/node/101817"
50  3.0/modules/rawphoto/views/admin_rawphoto.html.php
... ...
@@ -0,0 +1,50 @@
  1
+<?php defined("SYSPATH") or die("No direct script access.") ?>
  2
+<div id="g-rawphoto-admin">
  3
+  <h2> <?= t("Raw Photos") ?> </h2>
  4
+  <?= form::open("admin/rawphoto/saveprefs") ?>
  5
+  <?= access::csrf_form_field() ?>
  6
+  <p><?= t('<a href="%raw_url">Raw photo</a> processing depends on the ' .
  7
+           '<a href="%dcraw_url"><em>dcraw</em> tool</a>, which must be installed separately. ' .
  8
+           'It also depends on either the ImageMagick or GraphicsMagick graphics toolkits.',
  9
+           array("raw_url" =>
  10
+                 "http://www.adamcoupe.com/whitepapers/photography_technique_benefits_of_shooting_in_raw.htm",
  11
+                 "dcraw_url" => "http://www.cybercom.net/~dcoffin/dcraw/")) ?></p>
  12
+  <? if (!$is_keeporiginal_active): ?>
  13
+      <p class="g-module-status g-warning g-block">
  14
+        <?= t('The photos will not be preserved in their raw format unless you ' .
  15
+              '<a href="%modules_url">activate the <em>Keep Original</em> module</a>.',
  16
+              array("modules_url" => url::site("admin/modules"))) ?>
  17
+      </p>
  18
+  <? endif; ?>
  19
+  <fieldset>
  20
+    <legend><?= t("Paths") ?></legend>
  21
+    <? if ($dcraw->installed): ?>
  22
+      <p><?= t("The <em>dcraw</em> tool was detected at <code>%path</code> " .
  23
+               "with version <code>%version</code>.",
  24
+               array("path" => $dcraw->path, "version" => $dcraw->version)) ?></p>
  25
+    <? else: ?>
  26
+      <p class="g-module-status g-error g-block"><?= $dcraw->error ?></p>
  27
+    <? endif; ?>
  28
+    <? if ($toolkit_name == "none"): ?>
  29
+      <p class="g-module-status g-error g-block">
  30
+        <?= t('No suitable graphics toolkit was detected. ' .
  31
+              '<a href="%activate_url">Activate</a> either ImageMagick or GraphicsMagick.',
  32
+              array("activate_url" => url::site("admin/graphics"))) ?>
  33
+      </p>
  34
+    <? else: ?>
  35
+      <p><?= t("The %toolkit_name graphics toolkit was detected.",
  36
+               array("toolkit_name" => $toolkit_name)) ?></p>
  37
+    <? endif; ?>
  38
+    <? if (!empty($errors["IccPath"])): ?>
  39
+      <p class="g-module-status g-error g-block"><?= $errors["IccPath"] ?></p>
  40
+    <? endif; ?>
  41
+    <?= form::label("IccPath", t('Path to <a href="%icc_url">ICC profile</a>', array("icc_url" =>
  42
+          "http://www.permajet.com/30/Downloads/76/What_are_ICC_Profiles,_and_why_do_I_need_them.html"))) ?>
  43
+    <?= form::input(array("name" => "IccPath", "id" => "IccPath"), $icc_path) ?>
  44
+    <?if (empty($icc_path) || !empty($errors["IccPath"])): ?>
  45
+      <em>An ICC profile is optional. If you don't know what it is, then you don't need it.</em>
  46
+    <? endif; ?>
  47
+  </fieldset>
  48
+  <?= form::submit("SavePrefs", "Save") ?>
  49
+  </form>
  50
+</div>
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.