Page 1 of 1

How to run Fred's ImageMagick Scripts in PHP under Windows?

Posted: 2012-11-21T12:28:23-07:00
by MrDark
Hi!

I'm a totally new user of ImageMagick.
So please be patient with my lack of knowledge!

I am trying to eventually get a Fred's ImageMagick Script to process a big batch of images using PHP under XAMPP in a Windows environment.

I have managed to get ImageMagic to perform this commands successfully:

Code: Select all

<?php 
header("Content-Type: text/plain"); 
system("convert -version"); 
?>
and

Code: Select all

<?php 
exec("convert inimg/IMG_2247.JPG -thumbnail 100x100 outimg/IMG_2247.png");
?>
But I can not get Fred's ImageMagick Script aspectpad to work
I have downloaded the aspectpad script and placed it in htdocs folder.
http://www.fmwconcepts.com/imagemagick/ ... /index.php

When I try to perform the following commands

Code: Select all

<?php 
$result = exec("aspectpad -a 1 -m l inimg/IMG_2248.JPG outimg/IMG_2248.png 2>&1"); 
echo $result;
?> 
I get this output:
aspectpad is not an internal or external command

I'm stuck! Please help me!

Re: How to run Fred's ImageMagick Scripts in PHP under Windo

Posted: 2012-11-21T12:46:22-07:00
by fmw42
try

<?php
$result = exec("fullpath2/aspectpad -a 1 -m l inimg/IMG_2248.JPG outimg/IMG_2248.png 2>&1");
echo $result;
?>

or

<?php
$result = exec("bash fullpath2/aspectpad -a 1 -m l inimg/IMG_2248.JPG outimg/IMG_2248.png 2>&1");
echo $result;
?>

If the above does not work, then see my home page for Pointers when using PHP.

Re: How to run Fred's ImageMagick Scripts in PHP under Windo

Posted: 2012-11-21T14:39:09-07:00
by Bonzo
I do not think you can run them under XAMMP on windows as some required commands are not part of the windows software and not includded in XAMMP.

I think people have run them when Cgwyn or whatever it is called was installed.

Out of interest on a server with php I need to use the full path to aspectpad and CHMOD it to 777

Re: How to run Fred's ImageMagick Scripts in PHP under Windo

Posted: 2012-11-21T15:11:00-07:00
by fmw42
I believe what Bonzo meant was that you cannot run it on Windows native without PHP. But with PHP, it should work, though he knows best. But his point about making the script executable may also be one of your issues. chmod u+x aspectpad. Also be sure that the file has its suffix removed or if it is really .sh, then add .sh to the script name in your command and when making it exectuable.



<?php
$result = exec("fullpath2/aspectpad.sh -a 1 -m l inimg/IMG_2248.JPG outimg/IMG_2248.png 2>&1");
echo $result;
?>

Re: How to run Fred's ImageMagick Scripts in PHP under Windo

Posted: 2012-11-22T15:21:52-07:00
by MrDark
Thanks both for your help!

i used this PHP script to perform the command chmod u+x aspectpad in a windows environment.

Code: Select all

 <?php 
$result = chmod("aspectpad", 0777); 
echo $result;
?> 
Is that enough?

I get a 1 in return indicating that the command was successful.
I also tried to change the code to
chmod("aspectpadxxx", 0777);
resulting in the following error message:
Warning: chmod(): No such file or directory in D:\xampp\htdocs\chmod.php on line 2

So I know that the path to aspectpad is correct.
Somehow I cannot get aspectpad to be an executable in windows.

Re: How to run Fred's ImageMagick Scripts in PHP under Windo

Posted: 2012-11-22T15:59:48-07:00
by fmw42
Sorry I am not a Windows user. Bonzo, perhaps, can help with file permissions on Windoows.

Can you find where you put the file? If so, right click on the file and select the preferences for the file and see if you can change them in the preferences window that opens. Otherwise, hopefully Bonzo or some other Windows user can help.

Did you try adding the full path to the script as per


<?php
$result = exec("fullpath2/aspectpad.sh -a 1 -m l inimg/IMG_2248.JPG outimg/IMG_2248.png 2>&1");
echo $result;
?>

with or without the .sh

Re: How to run Fred's ImageMagick Scripts in PHP under Windo

Posted: 2012-11-23T00:50:39-07:00
by whugemann
I remember that I once tested one of Fred's scripts under Windows, but I cannot find the corresponding thread on this forum. Anyway, my experience with it resulted in my remarks at http://www.imagemagick.org/Usage/windows/#cygwin, so I would rather try what's written there, instead of dealing with XXAMP & Co. Seem's like you're almost done after the installation of Cygwin.

Re: How to run Fred's ImageMagick Scripts in PHP under Windo

Posted: 2012-11-23T01:02:20-07:00
by Bonzo
Thats interesting whugemann; I could never even get a bash file running on XAMMP.

I posted on another forum about it and the concensus was that it was not possible mostly due to functions and external programs that are not available on Windows by default.

One user here said he had a bash file running under XAMMP but I could not reproduce his method; but then he had cgwyn installed.

Re: How to run Fred's ImageMagick Scripts in PHP under Windo

Posted: 2012-11-23T05:55:59-07:00
by whugemann
Just to clarify terms:

I spoke of cygwin, which is a complete Unix bash shell under Windows (well, at least kind of, I hope).

XAMMP, however, is a special WAMP (= Windows + Apache + MySQL + PHP), which is something different. In this environment, PHP cannot rely on certain Unix functionalities to be present and this may indeed cause problems with certain scripts that rely on Unix functionality.

Re: How to run Fred's ImageMagick Scripts in PHP under Windo

Posted: 2012-11-23T06:01:15-07:00
by Bonzo
That is what I was saying as well in a round about way.