As it is now again possible to select the ImageMagick toolkit from /admin/settings (see drupal.org/node/50078), I have found that the textfield Location of the "convert" binary is not displayed. May be image.imagemagik.inc has not been converted for Drupal 4.7?

As my provider does not offer ImageMagick, I had to install it myself in a directory different from /usr/bin/convert which is the default of image.imagemagik.inc.
Unable to do my settings from /admin/settings, I overwrote the defaut path with my path and it worked.

I did that mod at line 16 (below is the original function):

function image_imagemagick_settings() {
  $convert_file = variable_get('image_imagemagick_convert', '/usr/bin/convert');

  if (!file_exists($convert_file)) {
    form_set_error('image_imagemagick_convert', t('%file does not exist or is not executable.', array('%file' => "<em>$convert_file</em>")));
  }
  
  return form_textfield(t('Location of the "convert" binary'), 'image_imagemagick_convert', $convert_file, 64, 64);
}

and also at line 68.

Comments

darren oh’s picture

Version: 6.x-1.x-dev » 4.7.x-1.x-dev
Status: Active » Needs work
StatusFileSize
new1.02 KB

I replaced form_textfield in an attempt to make it 4.7 compatible, but it still doesn't work for me. The attached patch includes changes from issue 29528.

urbanfalcon’s picture

The problem is that the new form API isn't letting the imagemagick.inc file's toolkit settings display in the system.module image handling box. In fact, it isn't even calling it at all. I had to a.) move my image.imagemagick.inc file into my root /includes directory and b.) hack my system.module file so that the image handling area read as:

  // Image handling:
  $toolkits_available = image_get_available_toolkits();
  if (count($toolkits_available) > 1) {
    $form['image'] = array('#type' => 'fieldset', '#title' => t('Image handling'), '#collapsible' => TRUE, '#collapsed' => true);
    $form['image']['image_toolkit'] = array(
      '#type' => 'radios', '#title' => t('Select an image processing toolkit'),
      '#default_value' => variable_get('image_toolkit', image_get_toolkit()), '#options' => $toolkits_available
    );
	$form['image']['image_imagemagick_convert'] = array(
		'#type' => 'textfield',
		'#title' => t('Location of the "convert" binary'),
		'#default_value' => variable_get('image_imagemagick_convert', '/usr/bin/convert'),
		'#size' => 64,
		'#maxlength' => 64,
	  );
	$convert_file = variable_get('image_imagemagick_convert', '/usr/bin/convert');
	if (!file_exists($convert_file)) {
		form_set_error('image_imagemagick_convert', t('%file does not exist or is not executable.', array('%file' => "<em>".$convert_file."</em>")));
		}	  
	}

It wasn't pretty, but it seems to have worked. There's got to be a better method of dealing with this, though.

darren oh’s picture

StatusFileSize
new1.02 KB

I created a patch from your changes, but it did not work for me. Even though I can use /usr/bin/convert from the command line, Drupal claimed that it did not exist or was not executable.

L. Allen Poole’s picture

Changing the convert install path may not be sufficient:
http://drupal.org/node/66311#comment-144309

Suggestions?

darren oh’s picture

I have tested different paths in the "Location of the convert binary" field, and every time I submit a new path I get the message, "/usr/bin/convert does not exist or is not executable. The settings have not been saved because of the errors." The system module is testing not the newly submitted path but the old path. I haven't had time to find out how to make it test the submitted path.

darren oh’s picture

Status: Needs work » Reviewed & tested by the community

It turns out that my problem was caused by my hosting provider's server configuration. PHP was not able to access the directory where the ImageMagick binary was located. Linking to the binary from other directories didn't work because PHP resolves all symbolic links.

To determine if the problem is caused by your hosting provider, look in the log for this message after trying to set the ImageMagick path:

file_exists() [function.file-exists]: open_basedir restriction in effect. File(/home/darrenoh/convert) is not within the allowed path(s): (/home/darrenoh/:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/darrenoh/public_html/includes/image.imagemagick.inc on line 69.

After my hosting provider modified the server configuration, I was able to test this patch successfully and can confirm that it is ready to be committed.

darren oh’s picture

Project: Image » Drupal core
Version: 4.7.x-1.x-dev » 4.7.3
Component: imagemagick toolkit » system.module
Status: Reviewed & tested by the community » Needs review
killes@www.drop.org’s picture

Project: Drupal core » Image
Version: 4.7.3 » 4.7.x-1.x-dev
Component: system.module » imagemagick toolkit

Moving back to image.module

jvandyk’s picture

StatusFileSize
new4.74 KB

This patch adds a textbox designating the location of the convert binary to image settings when the imagemagick toolkit is selected.

It works by updating image_imagemagick_settings to use fapi and by calling in to those settings during image.module's settings hook:

  $image_toolkit_settings = 'image_' . image_get_toolkit() . '_settings';
  if (function_exists($image_toolkit_settings)) {
    $form = array_merge($form, $image_toolkit_settings());
  }
darren oh’s picture

Status: Needs review » Needs work

This patch makes sense and works great when ImageMagick is selected; but, when it isn't selected, I can't open the image settings page. While the page is trying to open, the following message is stored in the error log, over and over again:

array_shift() [function.array-shift]: The argument should be an array in /home/darrenoh/public_html/includes/form.inc on line 473.
darren oh’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new3.96 KB

After modifying the third line of code in comment #9, it works:

if (is_array($image_toolkit_settings()) && function_exists($image_toolkit_settings)) {
walkah’s picture

Status: Reviewed & tested by the community » Needs work

I don't like the usage of $_POST in this patch... Also - the intention is to have the setting on admin/settings, since image.module is not the only place where the image.inc / toolkit is used.

darren oh’s picture

Priority: Normal » Critical
Status: Needs work » Needs review

Then the patch you want is in comment #3. Killes rejected it because it modified the system module. If we are not allowed to modify the system module, the patch in comment #11 may be our only solution.

darren oh’s picture

Title: Location of ImageMagick binary setting broken. » Update image.imagemagick.inc for Drupal 4.7
StatusFileSize
new652 bytes

Here's what happened the "location of convert binary" field. It was never updated to work with Drupal 4.7. As a result, it caused errors on the system settings page. See issue 50078.

In order to get image toolkit selection to work, image_toolkit_invoke('settings') was removed from system.module by CVS commit 26667.

So the solution is to update image.imagemagick.inc for Drupal 4.7 and then pursuade the Drupal maintainers to restore image_toolkit_invoke('settings') to system.module.

I have attached a patch here to take care of the Image project side of things. See issue 99160 for the system.module patch.

darren oh’s picture

StatusFileSize
new1.25 KB

New patch includes update for form validation.

darren oh’s picture

StatusFileSize
new1.25 KB

I learned a little more about the validate element. Corrected patch attached.

darren oh’s picture

Status: Needs review » Reviewed & tested by the community
walkah’s picture

Darren : it looks like your latest patch no longer includes UI for the settings? I recognize the core issue... and if killes says no, then we need to resort to adding the UI on admin/settings/image. Can you add this to your patch?

thanks!

walkah’s picture

Status: Reviewed & tested by the community » Needs work
darren oh’s picture

Status: Needs work » Reviewed & tested by the community

Image toolkit settings have been restored to Drupal core.

walkah’s picture

Status: Reviewed & tested by the community » Fixed

great. thanks darren !

Anonymous’s picture

Status: Fixed » Closed (fixed)
Axel_V’s picture

I've applied the patch but I have the following problem. My path to the convert reads something like
/kunden/homepages/18/d12345678/htdocs/newSiteDevelopment/ImageMagick-6.2.9/utilities/convert
If I add this as the location to the new version of the image.imagemagick.inc the string gets cut off somewhere in the middle and obviously I get the error message that 'convert does not exist or is not executable'. With the last version I didn't have a problem.
xl

Axel_V’s picture

changed '#maxlength' => to 128 and now it works.
xl

darren oh’s picture

Opened issue 109188 to deal with the bug reported by Axel_V.

darren oh’s picture

Status: Closed (fixed) » Patch (to be ported)

This fix needs to be ported to the 4.7 branch, where the issue originally appeared. This was done once, but for some reason the fix was reversed in CVS commit 47484.

darren oh’s picture

Tagged issue 108157 as a duplicate of this issue.

walkah’s picture

Status: Patch (to be ported) » Fixed
ajwwong’s picture

I just downloaded the latest image.imagemagick.inc for drupal 4.7...

// $Id: image.imagemagick.inc,v 1.2.2.2 2006/12/08 15:18:26 walkah Exp $

however, it appears as if this utilizes a "form_textfield" that is undefined in 4.7 on line 22 "Call to undefined function on line 22"

Thanks for all your hard work!

Blessings,
Albert
www.ithou.org

ajwwong’s picture

Status: Fixed » Active
darren oh’s picture

form_textfield is a relic of Drupal 4.6. It appears that the fix has been completely reversed.

darren oh’s picture

Title: Update image.imagemagick.inc for Drupal 4.7 » 4.7 image.imagemagick.inc was reverted to 4.6
Status: Active » Reviewed & tested by the community
StatusFileSize
new1.61 KB
walkah’s picture

Status: Reviewed & tested by the community » Fixed

committed. sorry about the bad commit guys. fixed now. thanks darren!

Anonymous’s picture

Status: Fixed » Closed (fixed)