I have successfully installed ImageMagick on my local Windows 7 PC. And test the convert C:\xampp\htdocs\test\images\a.jpg C:\xampp\htdocs\test\images\b.jpg
But when I am trying to this from a PHP file named C:\xampp\htdocs\test\index.php
with the code
<?php
exec("C:\Program Files\ImageMagick-6.8.9-Q16\convert C:\xampp\htdocs\test\images\a.jpg C:\xampp\htdocs\test\images\b.jpg", $output, $return);
?>
It does not work. The a.jpg file exists. and I am using the browser to run the index.php file with the path http://localhost/test/index.php
$output is blank and $return is 1.
However when I use
<?php
exec("C:\Program Files\ImageMagick-6.8.9-Q16\convert", $output, $return);
?>
I get the output as Imagemagick version...
The same output if I run the command "convert" in the command prompt.
I am using xamp in windows 7.
I have searched a lot, but the issues mentioned there is not which I face.
Because when I used only "convert" in PHP exec I got the output.
So could not understand what is the actual problem.
I've been banging my head against this issue for several hours now.
exec("C:\Program Files\ImageMagick-6.8.9-Q16\convert C:\xampp\htdocs\test\images\a.jpg C:\xampp\htdocs\test\images\b.jpg", $output, $return);
This code should work fine, just one issue, try running "C:\Program Files\ImageMagick-6.8.9-Q16\convert C:\xampp\htdocs\test\images\a.jpg C:\xampp\htdocs\test\images\b.jpg" without the quotes in a command prompt and you get 'C:\Program' is not recognized.
Need to quote the path to the convert exe.
Try this exec('"C:\Program Files\ImageMagick-6.8.9-Q16\convert" C:\xampp\htdocs\test\images\a.jpg C:\xampp\htdocs\test\images\b.jpg', $output, $return);
It should work.
Cheers!
I know this question has already been answered but I was banging my head against a wall for 5 hours last night trying to do this.
I think it's worth noting that if any of your paths have spaces in them (the executable, input file and output file) then they need to each be quoted separately:
i.e.
exec('"C:\Program Files\ImageMagick-6.9.1-Q16\convert" "C:\Documents\Web Dev\test.jpg" -resize 50x50 "C:\Documents\Web Dev\output.jpg"', $output, $return);
I hope this helps to save 5 hours of someone else's life.
Related
I am able to do use the ImageMagick convert function on the command line with no problems:
/usr/local/magick/bin/convert a.pdf b.png
I then put it in a one-line PHP file named testconvert.php:
system("/usr/local/magick/bin/convert a.pdf b.png", $code);
and it works fine as a command line call from PHP:
php testconvert.php
But, when I run the script from my browser on localhost:
http://localhost/~me/testconvert.php
I get the error:
convert: no images defined `b.png' # error/convert.c/ConvertImageCommand/3253
I found a lot of folks who have encountered similar problems and fixes ranged from using the absolute path for the files (didn't help) to installing ghostscript (didn't help, either). I'm going a bit gaga with this. Would anyone have any thoughts about what I can possibly try?
Thanks!
Change your system() line to:
system("pwd");
and you will see which directory your script is running in.
When I try using this Command: opencv_createsamples -img image.jpg -bg bg.txt -info /info/info.lst -pngoutput info -num 2600 it tells me: Invalid background description file.
I now tried:
./neg/1.jpg
./net/2.jpg
Didn't work.
./neg/1.jpg
./neg/2.jpg
Didn't work as well.
neg/1.jpg
neg/2.jpg
Same problem
neg/1.jpg
neg/2.jpg
Also not working.
Any ideas?? I really need help.
Thanks
FritzFurtz
I had the same problem and tried many different things (adding full path names in the bg.txt, convert to UTF-8,...) - which resulted in getting slightly different looking errors - but still, no success. I am following this tutorial - and I am preparing all the files on my windows laptop & then pushing them to a ubuntu server.
Then I read it might be caused by difference in line ending (CLRF and LF) and checked my file (on the ubuntu server):
$ file bg.txt
bg.txt: UTF-8 Unicode (with BOM) text, with CRLF line terminators
I converted the file from dos2unix:
$ sudo apt install dos2unix
$ dos2unix bg.txt
dos2unix: converting file bg.txt to Unix format ...
$ file bg.txt
bg.txt: ASCII text
And now the opencv_createsamples command worked.
I was experiencing the same problem and it was very frustrating. But now it's solved.
1) CTRL + A ; CTRL + C; on your background description file to copy all it's content.
2) Create a new background description file (e.g.: bg2.txt), and CTRL + V to paste all the content you copied. Save it.
3) Run your command again, using, of course, the new bg description file (-bg bg2.txt).
It worked for me and might work for you.
Cheers,
Geraldo Neto
I had the exact same problem. I tried changing the bg.txt encoding and it made no difference. I deleted all instances of OpenCV on my Ubuntu server and rebooted. I typed:
git clone https://github.com/Itseez/opencv.git
into the terminal.
Once downloaded, rebooted the server and proceeded with:
opencv_createsamples -img image.jpg -bg bg.txt -info /info/info.lst -pngoutput info -num 1500
That seemed to fix my "Invalid background description file" error.
Bear in mind that I tried to create a new folder and add a fresh download of OpenCV to use on a separate project and it just copied my existing file.
Delete all instances of the OpenCV folder before rebooting and redownloading it!
I had this problem too and I solved it by changing encoding of my bg.txt to UTF-8. Also, my file looks like:
neg/1.jpg
neg/2.jpg
On Linux (Ubuntu) adding one more empty line doe snot work. File was in utf-8 encoding. Resolved with converting from "linux" to "dos" line ending format.
Hi I want to create a video from list of images on ruby on rails. I have searched alot and all i found out was ffmeg, but i guess that's a command line tool. How do i create it using pure ruby on rails. Is there any gem or tutorial. Please Help.
Thanks to LordNeckbeard, i found this single command to convert images into video here ffmpeg
.
ffmpeg -framerate 1/3 -pattern_type glob -i '*.jpg' -c:v libx264 out.mp4
there are some gems that work as an interface between ruby and ffmpeg like https://github.com/streamio/streamio-ffmpeg.
There are some other few, try them out!
You can access command line through RoR.
result = %x[some command line call here]
What you would have to do is be sure you have the names path to your end result and confirm the return code from the command line call.
It seems like i will have to use commandline tool as i did'nt find any gem that does all this stuff for me.
install image magick
install ffmpeg
first convert all the jpg images into a gif file
convert -delay 250 -dispose Background *.jpg images.gif
then convert that gif file into mp4 format
ffmpeg -f gif -i images.gif outfile.mp4
I would love to have a better answer than this.
I have installed Bitnami Lamp Stack on AWS. Installation was very quick and smooth and I was able to quickly get the bitnami welcome page.
PHP Hello World was successful and uploading files with Filezilla on the folder /opt/bitnami/apache2/htdocs was OK.
However PHP couldn't write a file on this folder with the following php:
<?php
echo "Hello World<br>";
$data_table="this is a file write test";
$file = 'test.txt';
$handle = fopen($file, "w") or die("Unable to open file!");
echo "The file {$file} can be written";
fwrite($handle, $data_table);
fclose($handle);
?>
In fact I got the error message Unable to open file!
Apparently the web server cannot write to the folder while Filezilla can do it.
I spent several hours trying to understand what is wrong. I tried to add the complete path, I changed temporarily chmod to 777, chown the group/user but no success.
I tried also other PHP applications that need to create files and even them did not work. Now I am quite frustrated. Any help is highly appreciated.
Roberto
I just downloaded ImageMagick but am not sure if it's working. I typed in 'which convert' into my terminal and nothing happened. I also tried typing in 'convert logo: logo.gif' then 'identify logo.gif' and lastly 'display logo.gif' and nothing seemed to happen (these three commands were specified on Windows).
Then I tried following this video: http://www.youtube.com/watch?v=gEWAVlNCKhg
However, it still didn't work and on the last step of the video. I got the following error: ERROR: While executing gem ... (OptionParser::InvalidOption) invalid option: ----with-opt-include=C:/ImageMagick/SourceCode
Can anyone advise on how to correctly install imagemagick on windows or what these errors mean?
That video has a bunch of unnecessary stuff if all you want to do is get ImageMagick working as a standalone product on Windows. All you need to do is:
Download latest Windows binary from imagemagick.org. Right now, that file is located here.
Run the installer (leave all default values the way they are)
Open a command prompt (Start --> Run --> cmd.exe)
Navigate to the ImageMagick folder in the command prompt window. For the default install path, this is done as follows :
Change to the root directory of the C: drive (type cd\ followed by the enter key)
Change to the ImageMagick folder (type cd "Program Files\ImageMagick-6.8.6-Q16" followed by the enter key)
Test that it's working with the convert command: convert images\logo.jpg logo.gif
Look at the directory listing and check the for a logo.gif file with the current time/datestamp (dir logo.gif, followed by enter key).
Note: when you run the convert command, there will not be any output to the command prompt unless you turn on the verbose flag e.g. (convert -verbose images\logo.jpg logo.gif)
I noticed that in my installation that there was not a 'display.exe', but there was an 'imdisplay.exe". I tried using imdisplay in a folder that had images, and it did not how a window. I double clicked imdisplay.exe in the installation folder, and windows came up, including all of the ones I tried to open on the command line. When I closed all of those windows and tried the command line again, it worked.
I am not sure where you are getting 'which convert' (I did not watch the video). I can see all of the exe files that are available in the installation folder. convert.exe is one of them, so in a regular cmd window (I do not know anything about Powershell GitShell), you can just type:
convert logo.png logo.jpg
or something like that.