Image tools: Use which() instead of reimplementing (should also work on win32 now)
authorDan
Fri, 12 Jun 2009 11:38:43 -0400
changeset 73 1f55c324efcf
parent 72 b8730fcd64a9
child 74 7719085707d8
Image tools: Use which() instead of reimplementing (should also work on win32 now)
imagetools.php
--- a/imagetools.php	Tue May 26 15:26:59 2009 -0400
+++ b/imagetools.php	Fri Jun 12 11:38:43 2009 -0400
@@ -93,18 +93,9 @@
   }
     
   // try to find convert in the PATH
-  // FIXME: unix specific (won't work on windows)
-  $path = ( isset($_ENV['PATH']) ) ? $_ENV['PATH'] : ( isset($_SERVER['PATH']) ? $_SERVER['PATH'] : '/usr/local/bin:/usr/bin:/bin' );
-  $path = explode(':', $path);
-  foreach ( $path as $dir )
-  {
-    if ( file_exists("$dir/convert") && is_executable("$dir/convert") )
-    {
-      $magick_path = "$dir/convert";
-    }
-  }
+  $magick_path = which('convert');
   
-  $can_use_magick = isset($magick_path);
+  $can_use_magick = !empty($magick_path);
   $can_use_gd = (
       function_exists('getimagesize')         &&
       function_exists('imagecreatetruecolor') &&