i am trying to bend text using imagemagik in PHP. but the commands shown in the website are not working.
http://www.fmwconcepts.com/imagemagick/texteffect/index.php
how can i run these scripts in PHP ? somebody please help me..
NB :-t \'SOME ARCHBOTTOM TEXT\' -s outline -e arch-bottom -d 1.0 -f Arial -p 48 -c skyblue -b white -o black -l 1 -u lightpink
Translate them to the PHP ImageMagick API
dear you can use exec or passthru command to run image magic commands in php, no need of any API, just installed the latest imagemagick, if you are searching on php.net site the you will det the message like "Not documented"..
Are you using magickwand? I had a similar problem, I didn't have my PHP installation properly configured to use Imagemagick. This link helped
http://www.ioncannon.net/php/75/how-to-compile-imagemagick-for-php-by-hand/
Related
There is literally nothing on this anywhere, the little there is does not work and is too advanced for me. If you can answer this you would make my life. How do I run ffmpeg commands from php which is running on my localhost? I prefer XAMPP, but MAMP will do just fine, at this stage I will use anything. Do I need to install ffmpeg on the XAMPP server itself, or does it just need to be installed on the mac? I can run the ffmpeg commands fine from terminal, for example,
ffmpeg -i Tmpfile.mp4 -c:v libx264 -preset ultrafast video.mp4
works fine, but
echo shell_exec("ffmpeg -i Tmpfile.mp4 -c:v libx264 -preset ultrafast video.mp4");
does nothing when I load the webpage with the index.php that that code is in.
I will buy you a cookie if you can solve my problem :)
You should be more specific when describing the problem, e.g. including OSX version, ffmpeg version, etc.
I successfully managed to reproduce your case, here it is the procedure:
1. ffmpeg
I installed ffmpeg via brew. ffmpeg version is currently 3.2.4.
2. PHP server
On macOS Sierra (but other previous versions offer this feature as well), you can start a PHP server by just typing
$ php -S 0.0.0.0:8080
in your shell. The web server will listen on port 8080 in that case.
3. The PHP script
I basically used the script you gave in your question, with a little modification:
<?php
echo "loading, please wait...";
echo shell_exec("ffmpeg -i temp.mp4 -c:v libx264 -preset ultrafast video.mp4 2>&1");
Did you notice the 2>&1? It is used to redirect the sterr output to the stdoutput as ffmpeg would not print anything on standard output :)
4. Safe mode?
Please be sure to disable PHP safe mode, as the shell_exec method is disabled when safe mode is ON (reference here).
Ah, I have found the answer. I needed to add this to the beginning of the php script
exec('unset DYLD_LIBRARY_PATH ;');
putenv('DYLD_LIBRARY_PATH');
putenv('DYLD_LIBRARY_PATH=/usr/bin');
I am working with prolog and php. I am using php, to call prolog.
I am using swi-prolog Version 7.1.17 and XAMPP 1.7.7 [PHP: 5.3.8].My command :
$cmd ='swipl -q -f C:\Users\MyComp\Desktop\test.pl -g test,halt';
Here C:\Users\MyComp\Desktop\test.pl is prolog file directory. It is worked properly. but Now I update the XAMPP version(above 1.7.7) then it is not work. but the command it is work properly in cmd in windows.How can i solve this kind of problem? Any command will using All XAMPP version for call prolog from php.
You Try with
nice -n15 /software/bin/pl -f /home/popx/cgi-bin/test.pl -g test,halt
This may be work with your specification.
See the reference
Does simple ffmpeg package also work fine when we execute its command from PHP via exec? Or we have some different ffmpeg package for that purpose?
Please help me solving it.
PHP's ffmpeg and the vanilla ffmpeg are independent packages. The php5-ffmpeg package comes with the ffmpeg binary as a dynamic library. This means that you can install only php5-ffmeg without installing the command line ffmpeg package or vice versa or you can have both of them installed.
Therefore, the answer is yes, PHP will work with the command line ffmpeg given it is installed.
I usually prefer using the command line ffmpeg in PHP via exec. This allows for testing certain operations on the command line and once the result is as desired, the command can be used in PHP's exec. On the other hand, in some situations, it may be preferable to use the php5-ffmpeg package because it gives you the ability to use object oriented coding style when dealing with videos, conversion, etc.
Yes simple ffmpeg does work through PHP exec if you have necessary permissions.
Sample command
<?php
/*** convert video to flash ***/
exec("ffmpeg -i video.avi -ar 22050 -ab 32 -f flv -s 320x240 video.flv");
?>
Source
I have installed ffmpeg on my server and it works fine via my terminal. I'm able to successfully convert a file to webm format, so I'm sure the installation is fine. I'm also sure that I only have one installation of ffmpeg installed on my machine.
A problem arises when I try to convert files through PHP via PHP's exec(). When I run the same commands, I ran in the terminal, nothing happens. I looked around stackoverflow and other parts of the net for some help. I tried this to see the output:
exec($cmd, $out, $rv);
echo "output is:\n".implode("\n", $out)."\n exit code:$rv\n";
The output is: "output is: exit code:127"
The command I'm using is in this format:
ffmpeg -i "sample.mov" -vcodec libvpx -r 30 -b "644k" -acodec libvorbis -ab 128000 -ar "44100" -ac 2 -s "352x198" "sample.webm"
I've tried replacing "ffmpeg" with the full path to FFmpeg but that did not work.
Why isn't the script running the command correctly and converting the files?
Thank you!
Error code 127 means the executable (ffmpeg) couldn't be found. Try specifying the whole path (you can that out find in your terminal with which ffmpeg) or compare the value of the PATH environment variable in your php script and terminal.
I have similar problem with ant target executions from php. I can't get whole output from ant command only first few rows and ant target was not executed. In other words is partial executed.
With bellow command I've managed to run it but output of the command is append to log_file.log.
$commandString = 'you_command_here >> log_file.log 2>&1 &';
$command = exec($commandString);
Hope this will work for you.
I am trying to Fill in a PDF from PHP script. I am following the article by Sid Steward at the following URL.
I have configured PDFTk package on CentOS linux distribution and I am able to execute the pdftk from the command prompt and it merges the FDF form with the PDF and successfully generates the flattened(Filled) PDF. I am using following command to test the Pdftk using shell.
pdftk /tmp/form.pdf fill_form /tmp/fdfbm0pe7 output /tmp/filledform.pdf flatten
But When try to execute a similar command through PHP, I am getting the error. The passthru command is failing with error code 11. Following is the php code I am using to execute the command:
$command = 'pdftk form.pdf fill_form '. $fdf_fn. ' output - flatten';
passthru($command, $error);
The $fdf_fn above has the FDF file name. The form.pdf is the fill-able pdf form. Both the form.pdf and the PHP script file from which I have given the above lines of code are in the same folder. I have checked that PDFtk is executing correctly through PHP by echoing shell_exec('pdftk') and it was returning the standard help details.
Just to provide more details, the path to pdftk is /usr/bin/ and PHP script and PDF form files are located under /var/www/html/pdfmerge.
Can some one please guide what I am doing wrong that the command execution through PHP is failing with error code 11?
I had the exact same issue with PHP running PDFTK on CentOS and spent a number of hours hunting things down, so I hope someone will find this useful. My specific use for PDFTK is for the FillPDF module on Drupal. The solution to the exit code 11 issue was setting a local policy module to allow httpd to run PDFTK. If you grep /var/log/audit/audit.log for pdftk like this
grep -i pdftk /var/log/audit/audit.log
you should see some errors, probably one for 'execmem', amongst others. Here is what I did to fix the issue...
Running this command will pull the errors out of the log and put them into a file for you to review.
grep -i pdftk /var/log/audit/audit.log | audit2allow -m pdftklocal > pdftklocal.te
If the output looks good (e.g. there IS output), run this command to create the module.
grep -i pdftk /var/log/audit/audit.log | audit2allow -M pdftklocal
Once the module is created, you make the policy active by running this command.
/usr/sbin/semodule -i pdftklocal.pp
PDFTK should run now from PHP. If it does not, check to see if httpd_enable_cgi is on by running
getsebool httpd_enable_cgi
If it is not on, turn it on by running
setsebool -P httpd_enable_cgi 1
Details on the policy module can be found here: http://wiki.centos.org/HowTos/SELinux#head-faa96b3fdd922004cdb988c1989e56191c257c01
I had a similar issue to what you were having and it turns out that PHP didn't have access to read the .pdf, .fdf and did not have access to create the flattened .pdf file in the /tmp directory.
to see if that is the issue try doing
chmod 777 /tmp
to see if that fixes the issue. I wouldn't recommend leaving at 777 but maybe moving it back to 700 or so.