469,086 Members | 1,238 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,086 developers. It's quick & easy.

Php and ImageMagick in Windows?

I am trying to use ImageMagick from a Php script running under Windows XP.

I have installed the latest version of ImageMagick - 6.2.1-7 and even
tried backing up to version 5.5.7 (based on a recommendation I found
during a Google search), but I can not get ImageMagick to work in Php
(using exec or system).

ImageMagick works from a Windows Command prompt -

e.g., convert C:\apache\htdocs\testing\temp_.jpg
C:\apache\htdocs\testing\temp_.png

but that same command using the system function -

i.e., system("convert C:\apache\htdocs\testing\temp_.jpg
C:\apache\htdocs\testing\temp_.png", $retval);

always fails with a retval of either 4 or 1. (The retval was 4 until I
rebooted and tried again, and now it is always 1).

I am able to execute other windows commands (e.g. dir) from within the
system and exec functions in Php.

Can anyone help me figure out how to get ImageMagick to run from a Php
script - in Windows? I have tired using the full path to the convert
command, but that does not change anything (the ImageMagick installation
adds itself to the PATH environment variable anyway).

TIA

--
*****************************
Chuck Anderson • Boulder, CO
http://www.CycleTourist.com
Integrity is obvious.
The lack of it is common.
*****************************
Jul 17 '05 #1
3 6732
Chuck Anderson wrote:
I am trying to use ImageMagick from a Php script running under Windows
XP.

I have installed the latest version of ImageMagick - 6.2.1-7 and even
tried backing up to version 5.5.7 (based on a recommendation I found
during a Google search), but I can not get ImageMagick to work in Php
(using exec or system).

ImageMagick works from a Windows Command prompt -

e.g., convert C:\apache\htdocs\testing\temp_.jpg
C:\apache\htdocs\testing\temp_.png

but that same command using the system function -

i.e., system("convert C:\apache\htdocs\testing\temp_.jpg
C:\apache\htdocs\testing\temp_.png", $retval);

always fails with a retval of either 4 or 1. (The retval was 4 until
I rebooted and tried again, and now it is always 1).

I am able to execute other windows commands (e.g. dir) from within the
system and exec functions in Php.

Can anyone help me figure out how to get ImageMagick to run from a Php
script - in Windows? I have tired using the full path to the convert
command, but that does not change anything (the ImageMagick
installation adds itself to the PATH environment variable anyway).


You probably need to escape the \ characters, or switch them around so
they're / instead.

--
Chris Hope | www.electrictoolbox.com | www.linuxcdmall.com
Jul 17 '05 #2
"Chuck Anderson" <we************@seemy.sig> wrote in message
news:jL********************@comcast.com...
I am trying to use ImageMagick from a Php script running under Windows XP.

I have installed the latest version of ImageMagick - 6.2.1-7 and even
tried backing up to version 5.5.7 (based on a recommendation I found
during a Google search), but I can not get ImageMagick to work in Php
(using exec or system).

ImageMagick works from a Windows Command prompt -

e.g., convert C:\apache\htdocs\testing\temp_.jpg
C:\apache\htdocs\testing\temp_.png

but that same command using the system function -

i.e., system("convert C:\apache\htdocs\testing\temp_.jpg
C:\apache\htdocs\testing\temp_.png", $retval);


You know you need to escape backslashes in strings, right?
Jul 17 '05 #3
Chung Leong wrote:
"Chuck Anderson" <we************@seemy.sig> wrote in message
news:jL********************@comcast.com...

I am trying to use ImageMagick from a Php script running under Windows XP.

I have installed the latest version of ImageMagick - 6.2.1-7 and even
tried backing up to version 5.5.7 (based on a recommendation I found
during a Google search), but I can not get ImageMagick to work in Php
(using exec or system).

ImageMagick works from a Windows Command prompt -

e.g., convert C:\apache\htdocs\testing\temp_.jpg
C:\apache\htdocs\testing\temp_.png

but that same command using the system function -

i.e., system("convert C:\apache\htdocs\testing\temp_.jpg
C:\apache\htdocs\testing\temp_.png", $retval);


You know you need to escape backslashes in strings, right?

Thanks for the replies. I must admit that I was being a little ignorant
on that count ... but, I had already tried reversing the slashes:

system("convert.exe C:/apache/htdocs/testing/temp_.jpg
C:/apache/htdocs/testing/temp_.png", $retval);

and after these two replies, I tried escaping the backslashes:

system("convert.exe C:\\apache\\htdocs\\testing\\temp_.jpg
C:\\apache\\htdocs\\testing\\temp_.png", $retval);

But both methods still gave me a retval of 1.

However, I then tried using a relative path - or no path (leave off the c:):

system("convert.exe temp_.jpg temp_.png", $retval);

or (placing the images in a sub folder)

system("convert.exe photos/temp_.jpg photos/temp_.png", $retval);

and then it it works.

It seems that I can not use an absolute path
(c:\apache\htdocs\testing\temp_.png). I'm not sure why the c: part is a
problem, but using relative paths is all I really need to do. I was only
using full paths to be sure I was pointing to the right location of the
files while testing.

Thanks for the help.

--
*****************************
Chuck Anderson Boulder, CO
http://www.CycleTourist.com
Integrity is obvious.
The lack of it is common.
*****************************
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Randell D. | last post: by
reply views Thread by Andrew Crowe | last post: by
3 posts views Thread by Joe | last post: by
5 posts views Thread by nawfer | last post: by
1 post views Thread by shanergb | last post: by
6 posts views Thread by eholz1 | last post: by
2 posts views Thread by azrael | last post: by
reply views Thread by Tony Adamoli | last post: by
reply views Thread by Tony Adamoli | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by kglaser89 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.