Im trying to use the ImageMagick library in order to chorma key an image programmaticly in php. So far i've installed the ImageMagick extension onto my server and made sure it is working using some simple commands in the terminal itself. My goal is to get this working as php code but currently im just trying to find a script that works for me. My problem is that I cant get the greenscreen script from fred's imagemagick scripts to work. when trying to excute the scripti get a file does not exist or is not an ordinary file not readable or has zero size error.
The same is true when I try to use any of the imagemagick/fred's scripts on php.
I've tried:
In php:
giving everything 777 permissions
specifying full paths from the root directory of the server
chagning the temp dir within the script itself
In the terminal:
works with regular scripts though didn't find a script the does real life chroma key
can't make it use freds scripts
Update: Got the Imagemagick fred's script to work in the terminal though the image is returned in black and white. currently working on getting it to work as php code using exec()
Update 2: using this exec on my php
exec("/bin/bash /home/full_path_within_server/public_html/imagemagictest/greenscreen.sh shirt.jpg t.png",$out,$returnval);
I get the following error message: "FILE shirt.jpg DOES NOT EXIST OR IS NOT AN ORDINARY FILE, NOT READABLE OR HAS ZERO"
Found a solution, change the all instances of the convert in the script to the full path of the convert function.
Related
I'm having issues using oowriter to convert a doc to a pdf using php exec(). The line i'm running below works fine in CLI, just not in php using exec().
$stdin = "/usr/bin/oowriter --headless --convert-to pdf -outdir /var/data/uploads/ /var/data/uploads/lorem.docx";
exec($stdin,$stdout,$return_int);
$stdout returns an empty Array and $return_int returns 0.
I've searched around and the only possible solution I could find was adding the path to oowriter (which you can see i have done). Is there a permissions issue running this command as the apache user? There are a few posts on exec() not working in general, but I can successfully run commands for imagemagick using this method. Therefore it seems to me that this an application specific configuration issue with openoffice.
Appears to be a duplicate of the following, but no answers have been posted:
unable to run oowriter as web user
FYI I'm using CentOS V6.1 and PHP v5.3.3. Thanks.
When I try to convert pdf to php via command line:
convert 1.pdf 2.jpg
it works and gives me jpg image. But then I try to convert via php exec() it doesn't work.
exec("convert 1.pdf 2.jpg");
Process starts but I haven't result. I try to use
putenv("PATH=/usr/local/bin:/usr/bin:/bin")
and full path to file but it doesn't help.
I have a new detail of my problem: when I run my php script via command line - it works. But when I try to run it in my browser process starts and works a few seconds (~15 sec) but I haven't result.
I also had a development where I needed to convert pdf to image. I also used imagemagick. In my case, my web hoster has disabled the PHP function exec() for security reason. Is it possible that you have the same problem?
So, I was not able to use PHP to run imagemagick. My web hoster asks me to use a Pearl script and then it was working.
I hope my remark can help you.
Try using the PECL library for ImageMagick. Gives you a lot of options using PHP to work with imagemagick
http://php.net/manual/en/book.imagick.php
I have ImageMagick, IIS 6, Ghostscript, and PHP 5.3.1 installed on a Windows Server 2008 box and am trying to convert a PDF file into a JPG thumbnail.
However, it doesn't seem to be working-- the call to exec() produces a return code of 1 (which to my understanding, means that some general error has occurred). The output variable is simply an empty array. $output is simply an empty array. The same occurs if I use system() instead of exec()
Running the command from the command line seems to work, so my initial guess would be a simple permission issue... The directory is writable by PHP because the script that uploads a PDF to the directory works, and I have verified that everyone has permission to write to the directory as well.
Also, safe mode is off.
Any ideas as to what the issue could be?
Relevant code:
<?php
$output = array();
$ret = 0;
echo exec('convert D:\content\myfile.pdf[0] D:\content\myfile_thumb_1.jpg', $output, $ret);
var_dump($ret);
?>
Note: While I would test this on Apache on Mac OS X, I can't seem to get ImageMagick or Ghostscript installed correctly.
I've also ensured the following:
Correct case for the file names (all lowercase anyways)
Using the full path of convert.exe in addition to simply convert.exe
UPDATE:
After checking the task manager, convert.exe is being run and is taking up CPU time, suggesting to me that it is file permissions of some sort... I'm going to check it out now.
It turns out there was a permission issue with something in IIS-- the website ran under a different user than the command from CMD, which obviously results in it not working under IIS because it has lesser permissions than from CMD.
I have a bit of a unique situation. I'm trying to run a video encoding program from a PHP script called Diascope, which relies on the 'convert' command provided by ImageMagick. I have a bash script that executes a really simple conversion and then it runs the application called Diascope. This is the conversion code, and the following does work, it creates the new file
convert image.jpg image.png
Shows no errors, but then I run Diascope like this
diascope -clean audio.txt
And I can see that Diascope loads property because it prints "Diascope 0.2.1":
diascope 0.2.1 (ms 2006-2010) slideshow generator See
http://diascope.sf.net for documentation and updates.
Error: executable program not found: convert Please see the
requirements for diascope in the release notes.
When I run shell_exec("whoami"); it prints "nobody"
So why can I run convert by itself, but the "diascope" process can't seem to utilize it? I have tried going into /usr/local/bin/convert and chmoding it to 777, but it didn't seem to have any effect, what else could I try here?
UPDATE: I should probably add that when I try to run diascope -clean audio.txt as root on the terminal, it creates the audio.flv file like it should, also I can't seem to sudo su nobody it returns This account is currently not available.
PHP runs as the same user as apache, which is typically www-data or nobody. I believe you can use suPHP+apache to change the user that PHP runs under.
exec("fun.exe input/input.txt ");
I want to run an CUDA program in PHP,
the task is:
load data from an input.txt. (argument)
calculating.
write an output.txt.
and PHP read ouput.txt to do next task.
In server1(Apache ,Windows XP), it can run perfectly,
but in server2,3(Apache, Windows 7),the output is wrong.
The program doesn't crash and there's no any error message in the page,
it seems like something wrong during the execution.
Next I try exec the All CPU-side version (same calculation),server2,3 can run correctly.
If I exec the fun.exe(CUDA version) in server2,3 directly(double click or in command line),the program also run perfectly.
Any idea on why server2,3 can't run the program? Thanks.
First, try using the full path to the executable. Then the full path to the input file too.
If that doesn't work, then try modifying the file permissions (try with full 777 permissions, if that works then you know where your problem lies).
Try to use the entire path (windows version using backslash).