ImageAPI ImageMagick doesn't work in Windows 7

drimsun - January 17, 2009 - 12:57
Project:ImageAPI
Version:7.x-1.x-dev
Component:ImageAPI Imagick
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

I know Win7 is still beta, but I was wondering if anyone got ImageMagick to work with ImageAPI?

Although the path to convert.exe can be set, ImageAPI fails to communicate with ImageMagick. That is, there's no output coming back from ImageMagick (version information, errors, ...) nor are images processed, they're uploaded 1:1. ImageMagick works fine from the command prompt, though.

At first I thought there might be something wrong with Win7 permissions, but after trying out different settings the problem remained.

#1

drimsun - March 24, 2009 - 23:10
Status:postponed (maintainer needs more info)» needs review

Ok so I have been investigating the problem a bit and it appears that the variable $convert_path which is passed to proc_open() in _imageapi_imagemagick_convert_exec() (imageapi_imagemagick.module: line 194) is the culprit.

If its value is changed from start "windows title" /D"path_to_drupal_root" /B "path_to_convert" to simply convert, ImageAPI can read out Imagemagick's version info just fine.

However, because the image file paths in IM commands are relative to the web root directory, $cwd (current working directory) in proc_open() needs to be set to $_SERVER['DOCUMENT_ROOT']. After that all IM commands work fine.

#2

drimsun - March 24, 2009 - 23:13
Version:5.x-1.4» 6.x-1.5

Changing version to Drupal 6 as I've updated since posting the initial issue.

#3

drewish - March 24, 2009 - 23:44

drimsun, are you able to test this under XP? I'm reluctant to make a change like this without testing the previous versions and I don't have a windows box anymore.

#4

drimsun - March 25, 2009 - 17:26

Hi drewish,

I just tested the attached patch on Windows XP/7 and Linux CentOS 4.0 with ImageAPI, ImageCache and im_raw. Everything seemed to work fine.

PS: The patch is just meant for highlighting the change =)

AttachmentSize
imageapi_imagemagick.module.patch 684 bytes

#5

drewish - April 17, 2009 - 17:34

marked #350953: Imagick Unable to Find and Convert as a duplicate since the symptoms seem identical.

#6

drewish - April 17, 2009 - 17:48

This patch doesn't change the $convert_path variable but sets the current working directory. I'm not going to remove the full path because you need to be able to specify which binary you want even if it's not in the system path.

AttachmentSize
imageapi_360193.patch 896 bytes

#7

drewish - April 17, 2009 - 17:59
Status:needs review» fixed

i went ahead and committed the last patch to HEAD, DRUPAL-6--1, and DRUPAL-5 since it's a clear improvement. if you're still having problems finding the path on windows let's re-open the issue.

#8

yesterday - April 17, 2009 - 19:46

Yo, this patch doesn't work for folks like myself with a drupal install in a subfolder of $_SERVER["DOCUMENT_ROOT"]. Maybe you should use something like $base_path.

Thanks.

#9

drewish - April 17, 2009 - 19:54
Version:6.x-1.5» 6.x-1.x-dev
Status:fixed» active

#10

scafmac - April 22, 2009 - 13:26

This patch appears to break imagemagick on a D5 site using ImageAPI 5.x-1.5. When I upgraded to the latest version, all of sudden it could no longer find the source images even though nothing has changed.

I've reverted this one line of the patch and the problem went away. My server is running Linux with Php 5.1.6. Not sure if that is related or not. I'll try to figure out some more details. Shall I open another issue for 5.1.6?

#12

drewish - April 22, 2009 - 17:18

i'm going to close #441586: Patch for 6.x-1.x-dev breaks imageapi_imagemagick on multisite configurations on Linux and keep the discussion over here since this fix caused the problem

#13

drewish - April 22, 2009 - 17:19
Status:active» needs review

here's scafmac's patch from #441586: Patch for 6.x-1.x-dev breaks imageapi_imagemagick on multisite configurations on Linux

AttachmentSize
imageapi_patch.txt 598 bytes

#14

Paul Kishimoto - May 4, 2009 - 20:09

Also broken for me using 6.x-1.6 on Drupal 6.11. My configuration:

  • PHP 5.2.0
  • Apache/1.3.37 (Unix) mod_auth_passthrough/1.8 mod_log_bytes/1.2 mod_bwlimited/1.4 mod_ssl/2.8.28 OpenSSL/0.9.7a PHP-CGI/0.1b
  • ImageMagick 6.0.7 05/03/07 Q16

Under my web root (/home/example/public_html) I have a directory named 'drupal'. Requests to the webroot are redirected via configuration in /home/example/public_html/.htaccess to /home/example/public_html/drupal/index.php

As a result, not even scarfmac's suggested patch works. $_SERVER['DOCUMENT_ROOT'] is "/home/example/public_html" and base_path() returns "/", so ImageMagick still doesn't know about the "drupal" directory in the path.

The attached patch, however, does work. I have stolen some code from conf_path() to determine the base path of the Drupal installation. It should probably be checked on a server without my .htaccess trickery, and also on a Windows server, so that the original bug isn't reintroduced. At the moment I am not able to do so.

AttachmentSize
imageapi_imagemagick_path.patch 675 bytes

#15

drewish - May 5, 2009 - 15:21

Yeah we're going to need some testing on that. Also going to need some comments explaining what's going on there. I'd also like an isset() in the ?: operation.

#16

bspellmeyer - May 11, 2009 - 14:54

The patch in 14 fixes the problem for my drupal installation in a subdirectory below $_SERVER['DOCUMENT_ROOT'] (Drupal 6.11, ImageAPI 6.x-1.6, Apache/2.2.9 (Ubuntu) PHP/5.2.6-2ubuntu4.2 with Suhosin-Patch).

#17

sebsebseb123 - May 14, 2009 - 03:07

that patch totally worked.

thanks

#18

drewish - May 14, 2009 - 16:13

sebsebseb123, what platform are you using?

#19

drewish - May 14, 2009 - 16:37
Version:6.x-1.x-dev» 7.x-1.x-dev

this actually needs to go into head first.

AttachmentSize
imageapi_360193.patch 1.77 KB

#20

deviantintegral - May 14, 2009 - 18:51

The patch in #19 fixes the issue for me having a site in a subdirectory. I'm using MAMP on OS X, and will be testing the site on a FreeBSD server shortly.

#21

perusio - May 29, 2009 - 17:42

Patch in #19 fixes also the same bug with imageapi 5.x-1.5.

#22

drewish - May 29, 2009 - 17:49
Status:needs review» fixed

okay, committed to HEAD, DRUPAL-6--1, and DRUPAL-5. everyone please try out the -dev release and make sure it's still working for you.

#23

System Message - June 12, 2009 - 17:50
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

#24

Brian@brianpucc... - June 13, 2009 - 05:11

Just wanted to chime in that I had this problem (on Ubuntu and Debian) and updating to the dev version (I've got the May 29 one) fixes it for me with no apparent ill side-effects.

Thanks!

#25

tehwalrus - September 10, 2009 - 21:45

Was this ever committed to a stable branch? 1.6 is still showing as the latest stable version, and this has broken my dev setup in MAMP/OS X (i.e. it couldn't see the files, and reverting to 1.5 fixed the problem).

please take a look at threads at

http://drupal.org/node/519348

and linked from there, and get back to us poor end users with some info! :) I explain my setup and fix in more detail there.

Thanks for the hard work guys, once I get this mod working I will never have to try and write a gallery site again :)

#26

drewish - September 12, 2009 - 23:28

tehwalrus, try the -dev as was advised above. it's probably time to roll new releases.

 
 

Drupal is a registered trademark of Dries Buytaert.