1
0

Selectively omit dcraw options that would not be supported by the currently installed version.

This commit is contained in:
Chad Parry 2011-06-09 22:10:53 -06:00
parent bb9715a293
commit 8ad55995ae
3 changed files with 34 additions and 17 deletions

View File

@ -60,9 +60,15 @@ class Admin_RawPhoto_Controller extends Admin_Controller {
} }
public function _validate_icc_path(Validation $post, $field) { public function _validate_icc_path(Validation $post, $field) {
if (!empty($post->$field) && !@is_file($post->$field)) { if (!empty($post->$field)) {
if (!@is_file($post->$field)) {
$post->add_error($field, t("No ICC profile exists at the location <code>%icc_path</code>", $post->add_error($field, t("No ICC profile exists at the location <code>%icc_path</code>",
array("icc_path" => $post->$field))); array("icc_path" => $post->$field)));
} }
$dcraw = rawphoto_graphics::detect_dcraw();
if (version_compare($dcraw->version, "8.00", "<")) {
$post->add_error($field, t("Versions of <em>dcraw</em> before <code>8.00</code> do not support an ICC profile"));
}
}
} }
} }

View File

@ -24,18 +24,22 @@ class rawphoto_graphics {
if (empty($path)) { if (empty($path)) {
$dcraw->installed = false; $dcraw->installed = false;
$dcraw->error = t("The <em>dcraw</em> tool could not be located on your system."); $dcraw->error = t("The <em>dcraw</em> tool could not be located on your system.");
} else if (!@is_file($path)) { } else {
$dcraw->path = $path;
if (!@is_file($path)) {
$dcraw->installed = false; $dcraw->installed = false;
$dcraw->error = t("The <em>dcraw</em> tool is installed, but PHP's " . $dcraw->error = t("The <em>dcraw</em> tool is installed, " .
"<code>open_basedir</code> restriction prevents Gallery from using it."); "but PHP's <code>open_basedir</code> restriction " .
"prevents Gallery from using it.");
} else if (!preg_match('/^Raw [Pp]hoto [Dd]ecoder(?: "dcraw")? v(\S+)$/m', } else if (!preg_match('/^Raw [Pp]hoto [Dd]ecoder(?: "dcraw")? v(\S+)$/m',
shell_exec(escapeshellcmd($path) . " 2>&1"), $matches)) { shell_exec(escapeshellcmd($path) . " 2>&1"), $matches)) {
$dcraw->installed = false; $dcraw->installed = false;
$dcraw->error = t("The <em>dcraw</em> tool is installed, but the version is not recognized."); $dcraw->error = t("The <em>dcraw</em> tool is installed, " .
"but the version is not recognized.");
} else { } else {
$dcraw->installed = true;
$dcraw->path = $path;
$dcraw->version = $matches[1]; $dcraw->version = $matches[1];
$dcraw->installed = true;
}
} }
return $dcraw; return $dcraw;
} }
@ -73,9 +77,15 @@ class rawphoto_graphics {
$dcraw = rawphoto_graphics::detect_dcraw(); $dcraw = rawphoto_graphics::detect_dcraw();
if ($dcraw->installed) { if ($dcraw->installed) {
// Use dcraw to convert from a raw image to a standard pixmap. // Use dcraw to convert from a raw image to a standard pixmap.
$cmd = escapeshellcmd($dcraw->path) . " -c -w -W -t 0 "; $cmd = escapeshellcmd($dcraw->path) . " -c -w ";
if (version_compare($dcraw->version, "6.00", ">=")) {
$cmd .= "-t 0 ";
}
if (version_compare($dcraw->version, "8.81", ">=")) {
$cmd .= "-W ";
}
$icc_path = module::get_var("rawphoto", "icc_path"); $icc_path = module::get_var("rawphoto", "icc_path");
if (!empty($icc_path)) { if (!empty($icc_path) && version_compare($dcraw->version, "8.00", ">=")) {
$cmd .= "-p " . escapeshellarg($icc_path) . " "; $cmd .= "-p " . escapeshellarg($icc_path) . " ";
} }
$cmd .= escapeshellarg($input_file); $cmd .= escapeshellarg($input_file);

View File

@ -19,8 +19,9 @@
<fieldset> <fieldset>
<legend><?= t("Paths") ?></legend> <legend><?= t("Paths") ?></legend>
<? if ($dcraw->installed): ?> <? if ($dcraw->installed): ?>
<p><?= t("The <em>dcraw</em> tool was detected at <code>%path</code>.", <p><?= t("The <em>dcraw</em> tool was detected at <code>%path</code> " .
array("path" => $dcraw->path)) ?></p> "with version <code>%version</code>.",
array("path" => $dcraw->path, "version" => $dcraw->version)) ?></p>
<? else: ?> <? else: ?>
<p class="g-module-status g-error g-block"><?= $dcraw->error ?></p> <p class="g-module-status g-error g-block"><?= $dcraw->error ?></p>
<? endif; ?> <? endif; ?>