php windows vs linux differences

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
javismiles
Posts: 180
Joined: 2010-11-27T01:42:06-07:00
Authentication code: 8675308

php windows vs linux differences

Post 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
javismiles
Posts: 180
Joined: 2010-11-27T01:42:06-07:00
Authentication code: 8675308

Re: php windows vs linux differences

Post 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;
javismiles
Posts: 180
Joined: 2010-11-27T01:42:06-07:00
Authentication code: 8675308

Re: php windows vs linux differences

Post 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,
javismiles
Posts: 180
Joined: 2010-11-27T01:42:06-07:00
Authentication code: 8675308

Re: php windows vs linux differences

Post 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?
javismiles
Posts: 180
Joined: 2010-11-27T01:42:06-07:00
Authentication code: 8675308

Re: php windows vs linux differences

Post 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
javismiles
Posts: 180
Joined: 2010-11-27T01:42:06-07:00
Authentication code: 8675308

Re: php windows vs linux differences

Post 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
javismiles
Posts: 180
Joined: 2010-11-27T01:42:06-07:00
Authentication code: 8675308

Re: php windows vs linux differences

Post 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?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: php windows vs linux differences

Post 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>
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
javismiles
Posts: 180
Joined: 2010-11-27T01:42:06-07:00
Authentication code: 8675308

Re: php windows vs linux differences

Post 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
javismiles
Posts: 180
Joined: 2010-11-27T01:42:06-07:00
Authentication code: 8675308

Re: php windows vs linux differences

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: php windows vs linux differences

Post by fmw42 »

User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: php windows vs linux differences

Post 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";
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: php windows vs linux differences

Post 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}";
javismiles
Posts: 180
Joined: 2010-11-27T01:42:06-07:00
Authentication code: 8675308

Re: php windows vs linux differences

Post 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
Post Reply