Page 1 of 1
php windows vs linux differences
Posted: 2011-03-18T01:22:31-07:00
by javismiles
hi, i have a website that uses a lot of imagemagick from php, all works great, and i have been executing commands using the shell commands, you know
directly "convert -background none .. etc etc "
now i have moved to a linux server, i installed imagemagick all well, and from php i can execute commands, basic ones, like "convert pic1.jpg pic2.png"
but most of the commands that worked perfect in windows are not executing in linux,
could somebody explain the precautions and differences we have to be aware of when moving PHP code that calls imagemagick, from a windows server environment
to a Linux CentOS server environment?
all taking into account that the installation has worked and php has permissions and basic commands are working,
but most other commands are not working, clearly some issues related to syntax, and the OS environment,
could somebody give tips about what to be aware of, anything different regarding quotes? slashes?
for example
a command such as this that i had in windows, works now also well in linux
"convert " . " {$source} -quality 80 -resize x{$width} {$thumb}
however a command such as the following one, just as simple, i cant manage to make it work
$cmd =' convert -background none -fill red -gravity center -font Arial -size 140x92 caption:rose ..\..\uploaded-images\example.png';
finally in windows i was using passthrough always, in linux is there any advantage to use passthrough, exec or system,
i have noticed that some commands run on exec but not on passthrough
thank you very much
jav
Re: php windows vs linux differences
Posted: 2011-03-18T01:35:22-07:00
by javismiles
i dont get it, how can a simple convert image1.jpg image2.png work with no problems including a -resize
but this however doesnt work
$cmd =' convert -background none -fill red -pointsize 51 label:TEST '.$target_image;
i dont get it,
you see, things as simple as that that were working in windows, dont seem to work in linux,
however its not like nothing works, a basic conversion with resize does work,
so im totally puzzled
whats wrong in this one in linux-php?
$cmd =' convert -background none -fill red -pointsize 51 label:TEST '.$target_image;
Re: php windows vs linux differences
Posted: 2011-03-18T01:42:12-07:00
by javismiles
seems like in linux when i specify a source image it works, but if not it doesnt, from php i mean,
from the shell in linux everything works, all,
its from php that most things dont work but some do, totally puzzling
and these are the very same commands that worked in windows, all of them,
Re: php windows vs linux differences
Posted: 2011-03-18T01:46:38-07:00
by javismiles
so look at this
this works
$cmd = "convert " . " {$source_image} -background none -fill red -pointsize 51 label:VIVA {$target_image}";
this doesnt work! (and this would be right syntax not the previous one!)
$cmd = "convert " . " -background none -fill red -pointsize 51 label:VIVA {$target_image}";
how is this possible?
Re: php windows vs linux differences
Posted: 2011-03-18T01:52:03-07:00
by javismiles
how is this possible, i dont get it
this doesnt work (which it should)
$cmd = "convert " . " -background none -fill red -pointsize 51 label:TEST {$target_image}";
and this one works however
$cmd = "convert " . " {$source_image} -background none -fill red -pointsize 51 label:TEST {$target_image}";
its absurd the first one doesnt work from php when it works great from the Shell,
and even more absurd when the second one works, with that source parameter which is just not needed and should not be there
Re: php windows vs linux differences
Posted: 2011-03-18T02:19:55-07:00
by javismiles
i see that some things are also different, see this command
convert -background none -fill #559933 -font type/palace/palace_normal.ttf -pointsize 22 -rotate 0 -gravity West label:"A FILM" venga.png
error:
convert: missing an image filename `-fill' @ error/convert.c/ConvertImageCommand/2974.
when executed from the shell also fails, it says that -fill requires an image, which was not the case in windows
what do you think?
is this because of the version i compiled for this linux? well, i followed the instructions
Re: php windows vs linux differences
Posted: 2011-03-18T02:27:14-07:00
by javismiles
seeing a lot of people around google with this same problem of
"missing an image filename" error, and considering the other very weird problems i have
i start to consider if maybe my linux imagemagick installation although it seemed to work great, maybe it didnt and some things are missing?
what do u think? how do i know?
Re: php windows vs linux differences
Posted: 2011-03-18T05:43:31-07:00
by anthony
javismiles wrote:i see that some things are also different, see this command
convert -background none -fill #559933 -font type/palace/palace_normal.ttf -pointsize 22 -rotate 0 -gravity West label:"A FILM" venga.png
error:
convert: missing an image filename `-fill' @ error/convert.c/ConvertImageCommand/2974.
when executed from the shell also fails, it says that -fill requires an image, which was not the case in windows
what do you think?
is this because of the version i compiled for this linux? well, i followed the instructions
The # is a comment character in Linux Shell, and so must quotes (inside the PHP quotes). Remember the command is running in a linux shell now, NOT a Windows DOS shell. As such you need to obey Linux Shell Syntax when making command calls.
<start soapbox>
It is a shame that PHP has little high level functions to call sub-programs without invoking the shell to parse the sting into separate work arguments. To me security requires it, and PERL (which I am an avid user) has such functions. Why doesn't PHP! It is ridiculous. Would make things much easier if it did.
<end soapbox>
Re: php windows vs linux differences
Posted: 2011-03-18T14:22:30-07:00
by javismiles
thank you Anthony
like always im grateful for your help
but still doesnt work, see this command
$cmd = "convert -background none -fill red -pointsize 51 label:TEST {$target_image}";
how can this possibly not work from php,
it works from shell
why wouldnt it work from php?
i see no parameter anywhere that could interfere with the lynux shell what do u think?
thank u so much
jav
Re: php windows vs linux differences
Posted: 2011-03-18T14:26:01-07:00
by javismiles
to demonstrate that php is working with imagemagick, this command does work
$cmd = "convert {$source_image} {$target_image}";
that works
but when i dont put a source image, it never works
like
$cmd = "convert -background none -fill red -pointsize 51 label:TEST {$target_image}";
why is this, is it getting confused with the paths?
i dont get it
thank u so much
jav
Re: php windows vs linux differences
Posted: 2011-03-18T14:36:21-07:00
by fmw42
Re: php windows vs linux differences
Posted: 2011-03-18T20:16:24-07:00
by anthony
javismiles wrote:thank you Anthony
like always im grateful for your help
but still doesnt work, see this command
$cmd = "convert -background none -fill red -pointsize 51 label:TEST {$target_image}";
how can this possibly not work from php,
it works from shell
why wouldnt it work from php?
i see no parameter anywhere that could interfere with the lynux shell what do u think?
thank u so much
jav
If you arrange to log your PHP errors you will find that is a syntax error!!!
In fact it wouldn't work on a normal shell command line either!!!
Try...
Code: Select all
$cmd = "convert -background none -fill red -pointsize 51 label:TEST $target_image";
Re: php windows vs linux differences
Posted: 2011-03-19T10:20:34-07:00
by fmw42
$cmd = "convert -background none -fill red -pointsize 51 label:TEST {$target_image}";
if $target_image is a variable, then either leave off the { } or put the $ outside the { } as
$cmd = "convert -background none -fill red -pointsize 51 label:TEST ${target_image}";
Re: php windows vs linux differences
Posted: 2011-03-19T12:32:21-07:00
by javismiles
nothing of that was the problem,
those commands worked indeed in both bash and php
and i had php error login active
the problem was that we had two versions of imagemagick installed, and bash was calling the newest
and php was calling the oldest, thats why
now that we put the path to the new version all works
thank u very much again for your help