static function activate()
 {
     rawphoto_version::report_item_conversion_support();
     $dcraw = rawphoto_graphics::detect_dcraw();
     rawphoto_graphics::report_dcraw_support($dcraw);
     $toolkit_id = module::get_var("gallery", "graphics_toolkit");
     rawphoto_graphics::report_ppm_support($toolkit_id);
 }
 public function _validate_icc_path(Validation $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>", 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"));
         }
     }
 }
 static function convert($input_file, $output_file)
 {
     $success = false;
     $dcraw = rawphoto_graphics::detect_dcraw();
     if ($dcraw->installed) {
         // Use dcraw to convert from a raw image to a standard pixmap.
         $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");
         if (!empty($icc_path) && version_compare($dcraw->version, "8.00", ">=")) {
             $cmd .= "-p " . escapeshellarg($icc_path) . " ";
         }
         $cmd .= escapeshellarg($input_file);
         // Then use the graphics toolkit to convert the stream to a JPEG.
         $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");
         $toolkit_compat = false;
         switch ($toolkit_id) {
             case 'imagemagick':
                 $cmd .= escapeshellcmd("{$toolkit_path}/convert");
                 $cmd .= " -quality " . escapeshellarg($image_quality . "%");
                 $cmd .= " - " . escapeshellarg($output_file);
                 $toolkit_compat = true;
                 break;
             case 'graphicsmagick':
                 $cmd .= escapeshellcmd("{$toolkit_path}/gm");
                 $cmd .= " convert -quality " . escapeshellarg($image_quality . "%");
                 $cmd .= " - " . escapeshellarg($output_file);
                 $toolkit_compat = true;
                 break;
             default:
                 log::warning("rawphoto", "Cannot convert raw photo with graphics toolkit: " . $toolkit_id->active);
         }
         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;
             if (!$success) {
                 @unlink($output_file);
             }
         }
     }
     return $success;
 }
 static function graphics_toolkit_change($toolkit_id)
 {
     rawphoto_graphics::report_ppm_support($toolkit_id);
 }