[Mediawiki-l] problems getting ImageMagic to work

Ralph list.mediawiki at junkdrawer.ml1.net
Tue Jan 18 23:43:59 UTC 2005


I had problems running ImageMagick on Windows XP too.  I also go this 
error and found that the problem was in the php when it called the 
convert EXE.  It was using the wrong quoting character.  I am using 
1.3.7, and found that I had to change Image.php

in function: function createThumb( $width ):
originally:
                $cmd  =  $wgImageMagickConvertCommand .
                    " -quality 85 -background white -geometry {$width} ".
                    escapeshellarg($this->imagePath) . " " .
                    escapeshellarg($thumbPath);

to:
                $cmd  =  $wgImageMagickConvertCommand .
                    " -quality 85 -background white -geometry {$width} ".
                    "\"$this->imagePath\" \"$thumbPath\"";

I'd give a diff, but I also later changed image.php to support a limited 
image gallery I was working on, which is unrelated to this fix.  Try 
this and let me know if it works.

Ralph

Diederik Oudshoorn wrote:

> Hello,
>
> At the moment i am buiding a intranet using an instance of the MediaWiki.
> There are a few issues I cannot resolve though. Any help would be 
> appreciated!
>
> ImageMagic:
> I cannot get te resizing of Images to work. I have done the following:
>
> 1)Installed a version of ImageMagic in directory C:\Program 
> Files\ImageMagick-6.1.8-Q8 (using 
> ImageMagick-6.1.8-Q8-windows-static.exe);
> The environment variable PATH is set correctly
>
> 2)Made a copy of convert.exe (ImageMagic) to c:\ (To avoid problems 
> with the space in "Program Files" in the path to the original 
> convert.exe);
> C:\convert.exe  works from the command shell, I checked that.
>
> 3)Placed a copy of   php_imagick.dll  in C:\EasyPHP\php\extensions
>
> 4) added   extension=php_imagick.dll   to php.ini in the C:\Windows 
> directory
>
> 5)Placed a copy of  ImageMagickObject.dll  in the  C:\WINDOWS\system32 
> directory
>
> 6) Changed  LocalSettings.php to:
> <snip>
> ## To enable image uploads, make sure the 'images' directory
> ## is writable, then uncomment this:
> $wgDisableUploads        = false;
> $wgUseImageResize        = true;
> $wgUseImageMagick = true;
> $wgImageMagickConvertCommand = "C:\convert.exe";
> </snip>
>
> When I Upload an Image (BenR.jpg 1022 x 1363 pixels, deliberatly big 
> in size) through the [upload] link of the wiki, the image itself loads 
> correctly, but the resized one (to fit on the image's info page) does 
> not appear. I get a "broken picture" frame from my browser instead, as 
> well as 2 errors rendered into the HTML of the page:
> <snip>
> <b>Warning</b>:  stat(): Stat failed for 
> c:\easyphp\www\mediawiki/images/thumb/9/92/450px-BenR.jpg (errno=2 - 
> No such file or directory) in 
> <b>c:\easyphp\www\mediawiki\includes\Image.php</b> on line 
> <b>530</b><br />
> <br />
> <b>Warning</b>: 
> unlink(c:\easyphp\www\mediawiki/images/thumb/9/92/450px-BenR.jpg): No 
> such file or directory in 
> <b>c:\easyphp\www\mediawiki\includes\Image.php</b> on line 
> <b>533</b><br />
> </snip>
>
> When cleaned they read:
> Warning:  stat(): Stat failed for 
> c:\easyphp\www\mediawiki/images/thumb/9/92/450px-BenR.jpg (errno=2 - 
> No such file or directory) in 
> c:\easyphp\www\mediawiki\includes\Image.php on line 530
>
> Warning 
> unlink(c:\easyphp\www\mediawiki/images/thumb/9/92/450px-BenR.jpg): No 
> such file or directory in c:\easyphp\www\mediawiki\includes\Image.php 
> on line 533
>
> This left me at a loss as to what is going on. The error log of Apache 
> shows another strange thing (apart from the error from convert.exe or 
> is it PHP's?)
>
> <snip>
> [Tue Jan 18 16:15:37 2005] [error] [client 127.0.0.1] Filename is not 
> valid: c:/easyphp/www/speciaal:upload
> [Tue Jan 18 16:15:43 2005] [error] [client 127.0.0.1] Filename is not 
> valid: c:/easyphp/www/afbeelding:benr.jpg
> convert.exe: unable to open image 
> `'c:\easyphp\www\mediawiki/images/e/e1/BenR.jpg'': Invalid argument.
> [Tue Jan 18 16:15:44 2005] [error] PHP Warning:  stat(): Stat failed 
> for c:\easyphp\www\mediawiki/images/thumb/9/92/450px-BenR.jpg (errno=2 
> - No such file or directory) in 
> c:\easyphp\www\mediawiki\includes\Image.php on line 530
> [Tue Jan 18 16:15:44 2005] [error] PHP Warning: 
> unlink(c:\easyphp\www\mediawiki/images/thumb/9/92/450px-BenR.jpg): No 
> such file or directory in c:\easyphp\www\mediawiki\includes\Image.php 
> on line 533
> [Tue Jan 18 16:15:45 2005] [error] [client 127.0.0.1] File does not 
> exist: c:/easyphp/www/mediawiki/images/thumb/9/92/450px-benr.jpg
> </snip>
>
> I'm guessing that the Apache-error "invalid Filename" induces some 
> kind of illegal filename to begin with. When that is offered to 
> convert.exe or to convert.exe via PHP things go wrong.
>
> -- The documentation on ImageMagic is scarce on the Internet
> -- I am using the wiki in the Dutch (nl) language, hence the 
> 'speciaal:' en 'afbeelding:' in the Apache log. 'Afbeelding:' meaning 
> 'Image', and 'speciaal', well I'm not sure ;-)
> -- I do not have a trailing slash in my DocumentRoot
>
> I am using
>
> >MediaWIki   mediawiki-1.4beta3
> >easyphp1-7 (with apache 1.3.27, PHP 4.3.3. Mysql 4.0.15, phpadmin 2.5.3)
> > Windows XP (SP2) Home edition 1GB RAM
>
> I would be very gratefull for any answers or suggestions!
>
>
> Diederik Oudshoorn
> _______________________________________________
> MediaWiki-l mailing list
> MediaWiki-l at Wikimedia.org
> http://mail.wikipedia.org/mailman/listinfo/mediawiki-l




More information about the MediaWiki-l mailing list