Report as a site status when the graphics toolkit doesn't support Raw Photos.
This commit is contained in:
parent
8500fba8a0
commit
6013e96cf3
|
@ -29,6 +29,7 @@ class Admin_RawPhoto_Controller extends Admin_Controller {
|
|||
$toolkit_names = array("imagemagick" => "ImageMagick",
|
||||
"graphicsmagick" => "GraphicsMagick");
|
||||
$toolkit_id = module::get_var("gallery", "graphics_toolkit");
|
||||
$toolkit_names = rawphoto_graphics::get_supported_toolkits();
|
||||
$view->content->toolkit_name = array_key_exists($toolkit_id, $toolkit_names) ?
|
||||
$toolkit_names[$toolkit_id] : "none";
|
||||
$view->content->icc_path = isset($icc_path) ?
|
||||
|
|
|
@ -31,4 +31,8 @@ class rawphoto_event_Core {
|
|||
"bay", "bmq", "cr2", "crw", "cs1", "dc2", "dcr", "dng", "fff", "k25", "kdc",
|
||||
"mos", "mrw", "nef", "orf", "pef", "raf", "raw", "rdc", "srf", "x3f");
|
||||
}
|
||||
|
||||
static function graphics_toolkit_change($toolkit_id) {
|
||||
rawphoto_graphics::report_ppm_support($toolkit_id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,23 @@ class rawphoto_graphics {
|
|||
return $dcraw;
|
||||
}
|
||||
|
||||
static function get_supported_toolkits() {
|
||||
return array("imagemagick" => "ImageMagick",
|
||||
"graphicsmagick" => "GraphicsMagick");
|
||||
}
|
||||
|
||||
static function report_ppm_support($toolkit_id) {
|
||||
if (array_key_exists($toolkit_id, rawphoto_graphics::get_supported_toolkits())) {
|
||||
site_status::clear("rawphoto_needs_ppm_support");
|
||||
} else {
|
||||
site_status::warning(
|
||||
t('The Raw Photos module requires a supporting graphics toolkit. ' .
|
||||
'<a href="%activate_url">Activate</a> either ImageMagick or GraphicsMagick.',
|
||||
array("activate_url" => url::site("admin/graphics"))),
|
||||
"rawphoto_needs_ppm_support");
|
||||
}
|
||||
}
|
||||
|
||||
static function convert($input_file, $output_file) {
|
||||
$success = false;
|
||||
$dcraw = rawphoto_graphics::detect_dcraw();
|
||||
|
@ -52,7 +69,7 @@ class rawphoto_graphics {
|
|||
$cmd .= escapeshellarg($input_file);
|
||||
|
||||
// Then use the graphics toolkit to convert the stream to a JPEG.
|
||||
$cmd .= "| ";
|
||||
$cmd .= " | ";
|
||||
$toolkit_id = module::get_var("gallery", "graphics_toolkit");
|
||||
$toolkit_path = module::get_var("gallery", "graphics_toolkit_path");
|
||||
$image_quality = module::get_var("gallery", "image_quality");
|
||||
|
@ -77,6 +94,7 @@ class rawphoto_graphics {
|
|||
|
||||
if ($toolkit_compat) {
|
||||
exec($cmd, $output, $return_var);
|
||||
// Failure is common, because dcraw will abort unless the original image is a raw photo.
|
||||
$success = ($return_var == 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,11 +26,14 @@ class rawphoto_installer {
|
|||
foreach (array("thumb", "resize") as $target) {
|
||||
graphics::add_rule("rawphoto", $target, "rawphoto_graphics::convert", array(), 10);
|
||||
}
|
||||
$toolkit_id = module::get_var("gallery", "graphics_toolkit");
|
||||
rawphoto_graphics::report_ppm_support($toolkit_id);
|
||||
}
|
||||
|
||||
static function deactivate() {
|
||||
foreach (array("thumb", "resize") as $target) {
|
||||
graphics::remove_rule("rawphoto", $target, "rawphoto_graphics::convert");
|
||||
}
|
||||
site_status::clear("rawphoto_needs_ppm_support");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<? if ($toolkit_name == "none"): ?>
|
||||
<p class="g-module-status g-error g-block">
|
||||
<?= t('No suitable graphics toolkit was detected. ' .
|
||||
'Please <a href="%activate_url">activate</a> either ImageMagick or GraphicsMagick.',
|
||||
'<a href="%activate_url">Activate</a> either ImageMagick or GraphicsMagick.',
|
||||
array("activate_url" => url::site("admin/graphics"))) ?>
|
||||
</p>
|
||||
<? else: ?>
|
||||
|
|
Reference in New Issue
Block a user