From d19606b96ba0f5ed56e9e736b8fe88210528577c Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Sat, 11 Jul 2009 00:58:19 +0000 Subject: I will probably regret this - opening up imagemagick command line to all --- docs/configure_server.txt | 5 ++++- languages/en.php | 2 +- lib/resize.php | 2 +- system.php | 11 ++++++++++- views/default/tidypics/forms/admin.php | 36 +++++++++++++++++++++------------- 5 files changed, 38 insertions(+), 18 deletions(-) diff --git a/docs/configure_server.txt b/docs/configure_server.txt index 057c4ee82..4d77816d6 100644 --- a/docs/configure_server.txt +++ b/docs/configure_server.txt @@ -13,11 +13,14 @@ along these lines: "Tidypics warning: user exceeded post limit on image upload" GD: Elgg requires GD for image resizing. Tidypics uses GD by default for resizing. There are two versions GD and GD2. It generally does not matter which one you are using and it isn't always apparent which one you are -running anyways. +running anyway. ImageMagick: A significantly better image library than GD. It uses less memory during resizing. Use this if it is available. +exec: Calls to ImageMagick command line utilities like convert require that +exec() be available. On some servers it will be for security reasons. + Memory Available to PHP: The amount of RAM available to a single PHP process. This can have an effect on how large an image you can resize (especially if you are running Tidypics with GD). The best place to diff --git a/languages/en.php b/languages/en.php index 114fa3eff..76604f543 100644 --- a/languages/en.php +++ b/languages/en.php @@ -58,7 +58,7 @@ 'tidypics:settings:maxfilesize' => "Maximum image size in megabytes (MB):", 'tidypics:settings:quota' => "User/Group Quota (MB) - 0 equals no quota", 'tidypics:settings:watermark' => "Enter text to appear in the watermark - ImageMagick Cmdline must be selected for the image library", - 'tidypics:settings:im_path' => "Enter the path to your ImageMagick commands", + 'tidypics:settings:im_path' => "Enter the path to your ImageMagick commands (with trailing slash)", 'tidypics:settings:img_river_view' => "How many entries in river for each batch of uploaded images", 'tidypics:settings:album_river_view' => "Show the album cover or a set of photos for new album", 'tidypics:settings:largesize' => "Primary image size", diff --git a/lib/resize.php b/lib/resize.php index 8561e1f4a..a2c522eb8 100644 --- a/lib/resize.php +++ b/lib/resize.php @@ -527,7 +527,7 @@ } if(substr($im_path, strlen($im_path)-1, 1) != "/") $im_path .= "/"; $command = $im_path . "convert \"$input_name\" -resize ".$newwidth."x".$newheight."^ -gravity center -extent ".$newwidth."x".$newheight." \"$output_name\""; - system($command); + exec($command); return $output_name; } diff --git a/system.php b/system.php index 833722db8..24295c715 100644 --- a/system.php +++ b/system.php @@ -39,6 +39,10 @@ return $size; } + $disablefunc = explode(',', ini_get('disable_functions')); + $exec_avail = "Disabled"; + if (is_callable('exec') && !in_array('exec',$disablefunc)) + $exec_avail = "Enabled"; ob_start(); @@ -57,10 +61,15 @@ Elgg requires the GD extension to be loaded - ImageMagick + ImageMagick PHP + + exec() + + Required for ImageMagick command line + Memory Available to PHP B diff --git a/views/default/tidypics/forms/admin.php b/views/default/tidypics/forms/admin.php index a80fff91d..0ade3d885 100644 --- a/views/default/tidypics/forms/admin.php +++ b/views/default/tidypics/forms/admin.php @@ -12,29 +12,37 @@ $action = $vars['url'] . 'action/tidypics/settings'; $plugin = find_plugin_settings('tidypics'); + + + if (extension_loaded('imagick')) + $img_lib_options['ImageMagickPHP'] = 'ImageMagick'; + + $disablefunc = explode(',', ini_get('disable_functions')); + if (is_callable('exec') && !in_array('exec',$disablefunc)) + $img_lib_options['ImageMagick'] = 'ImageMagick Cmdline'; + + $img_lib_options['GD'] = 'GD'; - // Image Library - need to update values! + // Image Library $image_lib = $plugin->image_lib; if (!$image_lib) $image_lib = 'GD'; $form_body = '

' . elgg_echo('tidypics:settings:image_lib'); $form_body .= elgg_view('input/pulldown', array( 'internalname' => 'params[image_lib]', - 'options_values' => array( - 'GD' => 'GD', - 'ImageMagickPHP' => 'ImageMagick', -/* 'ImageMagick' => 'ImageMagick Cmdline', */ - ), + 'options_values' => $img_lib_options, 'value' => $image_lib )); - $form_body .= '

'; -/* - // Image Magick Path - $im_path = $plugin->im_path; - if(!$im_path) $im_path = "/usr/bin/"; - $form_body .= "

" . elgg_echo('tidypics:settings:im_path') . "
"; - $form_body .= elgg_view("input/text",array('internalname' => 'params[im_path]', 'value' => $im_path)) . "

"; -*/ + $form_body .= '
Note: If you want to select ImageMagick Command Line, first confirm that it is installed on your server.

'; + + if (is_callable('exec') && !in_array('exec',$disablefunc)) { + // Image Magick Path + $im_path = $plugin->im_path; + if(!$im_path) $im_path = "/usr/bin/"; + $form_body .= "

" . elgg_echo('tidypics:settings:im_path') . "
"; + $form_body .= elgg_view("input/text",array('internalname' => 'params[im_path]', 'value' => $im_path)) . "

"; + } + // Tagging $tagging = $plugin->tagging; if(!$tagging) $tagging = "enabled"; -- cgit v1.2.3