i'm trying use imagemagick command "convert" create .tif image .png one.
what i've come is:
$exec = "/opt/local/bin/convert -adaptive-resize 150% ".$pos.".png ".$pos.".tif"; exec($exec);
if run cli "which convert" path: /opt/local/bin/convert
. i've tried without path, /opt/local/bin/convert -adaptive-resize 150% ".$pos.".png ".$pos.".tif
, /etc/local/bin/convert -adaptive-resize 150% ".$pos.".png ".$pos.".tif
.
if i'm running command terminal works expected when i'm trying use php script doesn't work.
edit: i've tried without success create .sh file following code:
#! /bin/bash convert -adaptive-resize 150% 1.png 1.tif convert -adaptive-resize 150% 2.png 2.tif convert -adaptive-resize 150% 3.png 3.tif convert -adaptive-resize 150% 4.png 4.tif convert -adaptive-resize 150% 5.png 5.tif convert -adaptive-resize 150% 6.png 6.tif convert -adaptive-resize 150% 7.png 7.tif convert -adaptive-resize 150% 8.png 8.tif convert -adaptive-resize 150% 9.png 9.tif
if run terminal works charm. instead if try execute simple php file doesn't create .tif file.
<?php $exec = "./convertpngtif.sh"; exec($exec); ?>
the clue in hieu nguyen answer above: when run command line php -r
, works. when run in browser, doesn't. leads 1 of 3 possible issues.
the critical thing remember when run exec, script, user, path , working directory run same user/permissions php running at.
when running php in command line, php run user logged in ("you"), , therefore exec() run "you". same user use write shell script in. permissions therefore same yours, , works (great).
when php runs in apache (or iis) may or may not "you". in case, isn't script doesn't work - php running "apache" or "http" or "www" or named user.
this leads 1 of 3 possible issues. check:
1) , 2) path , working directory.
been suggested above 1 @ time, it's safer stipulate absolute paths (i.e. full paths, starting @ root /
) files - executable command, input file , output file. rules out differences in paths or working directories may arise. if uses shell script, stipulate full paths shell script , full paths within (or set paths / directories @ top)
3) permissions
again suggested above, everyone's been concentrating on files. have checked permissions of convert
executable command itself?
also shell script, have set permissions of executable user php running as? rwxr--r-- owned "you" isn't satisfactory if you're running different user within apache.
there couple of other solutions if struggling those:
you can make php run "you" in apache using fastcgi install. way know user/path/working directory running both php scripts as. (i'd still recommend full paths, still alleviates permission issues)
you can debug script logging in "apache" or "www" or "http" etc , setting permissions / paths script works.
Comments
Post a Comment