source: extensions/external_ImageMagick/branch/2.1/main.inc.php @ 9860

Last change on this file since 9860 was 9860, checked in by patdenice, 13 years ago

Do not use temp file

File size: 1.5 KB
Line 
1<?php
2/*
3Plugin Name: External ImageMagick
4Version: auto
5Description: Use external ImageMagick installation
6Plugin URI: auto
7Author: P@t
8Author URI: http://www.gauchon.com
9*/
10
11if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
12
13define('IMAGICK_EXEC_PATH' , PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/');
14
15add_event_handler('get_admin_plugin_menu_links', 'imagick_exec_init');
16add_event_handler('ws_add_methods', 'ws_add_method_load_imagick_exec_functions');
17
18function imagick_exec_init($menu)
19{
20  global $conf, $page;
21
22  if (in_array($page['page'], array('intro','plugins_list','photos_add')) and !test_imagick_exec())
23  {
24    array_push($page['warnings'], l10n('Unable to locate ImageMagick directory. Please fill $conf[\'imagick_directory\'] in your local configuration file.'));
25  }
26  elseif (($page['page'] == 'photos_add' or script_basename() == 'uploadify') and test_imagick_exec())
27  {
28    include_once(IMAGICK_EXEC_PATH.'functions.inc.php');
29    include_once(IMAGICK_EXEC_PATH.'imagick.class.php');
30  }
31
32  return $menu;
33}
34
35function ws_add_method_load_imagick_exec_functions()
36{
37  if (test_imagick_exec())
38  {
39    include_once(IMAGICK_EXEC_PATH.'functions.inc.php');
40    include_once(IMAGICK_EXEC_PATH.'imagick.class.php');
41  }
42}
43
44function test_imagick_exec()
45{
46  global $conf;
47
48  $imagick_dir = isset($conf['imagick_dir']) ? rtrim($conf['imagick_dir'], ' /\\').'/' : '';
49  @exec($imagick_dir.'convert', $returnarray, $returnvalue);
50  return (!$returnvalue and !empty($returnarray[0]) and preg_match('/ImageMagick/', $returnarray[0]));
51}
52
53?>
Note: See TracBrowser for help on using the repository browser.