khtmld provides an interface to control khtml2png, which creates screenshots of websites and runs on headless-server systems with a virtual X server, or a VNC server. The only requirement are some KDE libraries, providing the khtml class. With khtmld you are able to activate khtml2png through php-scripts (e.g. Generating previews of your links).
If you have also something to contribute to khtmld(aemon), please do not hesitate to inform me. Simply write an email or submit your patch/source via sourceforge.net tracker.
khtmld passes commands to khtml2png, to generate your screenshot. The daemon listens on a named pipe (FIFO) to read the information for the next job. There is a simple syntax rule for adding jobs. At first you define the target url and than the target image file on your system, seperated by a BLANK (SPACE). You can add multiple jobs at once. Just add them line by line.
Notice: May be you need to append a '\n' (NEWLINE) to each job. Depending on your scripting/programming language and functions you use.)
Command spool syntax:
[TARGET_URL] [DESTINATION_IMAGE]
Example:
BASH:
$ echo "http://www.example.com /tmp/example.png" >/tmp/khtmldspool
PHP:
<?php
$data = "http://www.example.com /tmp/example.png\n";
$fp = fopen("/tmp/khtmldspool", "w");
if ($fp) {
fwrite($fp, $data, strlen($data));
fclose($fp);
}
?>
width=1280 height=1024 scaled-width=800 scaled-height=600 flash-delay=5 time=30 display=:0.0 KHTML=disable-js KHTML=disable-javaNote: display needs to be set, check your X server config.
width=800 height=600 time=30 display=:0.0 KHTML=disable-js KHTML=disable-javaNote: display needs to be set, check your X server config.
kthmld has been tested with following khtml2png versions
| 1.0.3 | successful |
|---|---|
| 2.5.0 | successful |
| 2.6.0 | successful |
| Static_2.5.0 | not testet |
Latest Version: 0.3.8
Project hosted at Sourceforge.net: http://www.sourceforge.net/projects/khtmld
Discussion
Hello I have khtmld running successfully
Mar 22 15:53:19 www sshd(pam_unix)[7926]: session opened for user root by root(uid=0) Mar 22 16:04:40 www khtml daemon[9530]: khtmld started and listening.
But when I run echo “http://www.example.com /tmp/example.png” >command_spool.fifo
it just creates a file called command_spool.fifo with http://www.example.com /tmp/example.png in the /tmp dir???
What am I doing wrong?? I see a file called khtmldspool| in the /tmp if I try to vi it appears blank.
Any help would be great
Eric
The FIFO will always appear empty, because it is a kind of named pipe. When you start khtmld it will create by default a file /tmp/khtmldspool. khtmld then listens on that file for input. The problem is the echo command, the redirect is directed into a file called command_spool.fifo in your example, but you need to redirect it to /tmp/khtmldspool. Please try something like
khtml then should read from that pipe and start processing...
I am sorry for the poor documentation. I’m working on it..
I’m starting the daemon with a khtml2png config file containing the following:
–display :0 –width 800 –height 600
However, these arn’t getting transfered properly.. How should I structure the file containing the parameters?
It should look something like this:
I had no time to test this with the new config-parser, but it should work.
I have a headless server, but I am not able to use khtmld. I would like to use it with vnc: e.g. vncserver -geometry 1280×1024 -depth 16 khtmld -K /home/albert/khtml2pngStatic-2.6.0 echo “http://www.google.com example.png” >/tmp/khtmldspool
I tried to set parameters (width, height, display,...) into ~/.khtmldrc, but it doesn’t work - it seems to be ignored by khtml2png (scaled-width=80 parameter is not accepted in the file, but time=30, display :1,... are ingored). Command line usage of khtml2png works fine.
$ khtmld -K /home/albert/khtml2pngStatic-2.6.0 Starting khtmld in forground... Using khtml2png at location `/home/albert/khtml2pngStatic-2.6.0’. Using spool `/tmp/khtmldspool’ for input processing. Using pidfile `/tmp/khtmld.pid’. Fork timeout set to: `60’ khtml daemon[19017]: khtmld started and listening. Mounting fifo `/tmp/khtmldspool’ and waiting for input... DONE New jobs in spool, working... khtml2pngStatic-2.6.0: cannot connect to X server All current spool jobs done. Mounting fifo `/tmp/khtmldspool’ and waiting for input...
Any help would be great Thank you
Have you checked if your VNC Server is providing a display on :1.0, may be it spawned one on :0.0 or :0.1, could you look if it is on a different DISPLAY? Of course I will have a look at the fact that the config file isn’t parsed correctly. Please check back later, I will do this as soon as possible.
I hope I use the right display. The problem could be also in khtml2png2, I don’t know...
Thank you
I am sorry it was definitely the fault of khtmld. You were right with your conjecture, khtmld was not reading the configuration. During the changes to the daemon I have not checked this function properly. I have released v0.3.1 at sourceforge.net. Please try this and report back if it is working correctly.
$more .khtmldrc display= mars:0 $khtmld Starting khtmld in forground... Using khtml2png at location `/usr/local/bin/khtml2png'. Using spool `/tmp/khtmldspool' for input processing. Using pidfile `/tmp/khtmld.pid'. Fork timeout set to: `60' khtml daemon[21871]: khtmld started and listening. Mounting fifo `/tmp/khtmldspool' and waiting for input... DONE $echo “http://www.google.com ./example.png” >/tmp/khtmldspool But screenshot is not created. I guess there is a problem with connection of khtml2png(2) to X server (neither X:Kubuntu nor vncserver works if -display is used)? I am not familiar with X server things... And it tries to use /usr/local/bin/khtml2png instead of installed khtml2png2 (?) There is also a problem with -K option - it always do this and no screenshot: $khtmld -K ./khtml2pngStatic-2.6.0 Starting khtmld in forground... Using khtml2png at location `./khtml2pngStatic-2.6.0'. Using spool `/tmp/khtmldspool' for input processing. Using pidfile `/tmp/khtmld.pid'. Fork timeout set to: `60' khtml daemon[21935]: khtmld started and listening. Mounting fifo `/tmp/khtmldspool' and waiting for input... DONE New jobs in spool, working... Usage: khtml2pngStatic-2.6.0 [Qt-options] [KDE-options] [options] url outfile Render HTML to a PNG from the command line Example: khtml2png2 --width 800 --height 1000 http://www.kde.org/ kde-org.png or khtml2png --auto ID_border http://www.kde.org/ kde-org.png Generic options: --help Show help about options --help-qt Show Qt specific options --help-kde Show KDE specific options --help-all Show all options --author Show author information -v, --version Show version information --license Show license information -- End of options Options: --width Width of canvas on which to render html [800] --height Height of canvas on which to render html [1000] --time Maximum time in seconds to spend loading page [30] --auto Use this option if you to autodetect the bottom/right border [] Arguments: url URL of page to render outfile Output file All current spool jobs done. Mounting fifo `/tmp/khtmldspool' and waiting for input...Thank you
Thanks for keep trying! I have uploaded khtmld v0.3.2 to sf.net and provide a above the comments. The reason why khtmld calls khtml2png by default is very simple. The first version of khtmld was desinged to run with khtml2png 1.0.3. I forgot about this project and didn’t recognize, that the creator of khtml2png have released a khtml2png2 version. And so you have to use the -K option. The previous releases tried to run something like
I hope I’ve fixed that now! And the parameters passed to execv() are correct.
I have changed your <pre> tags to <code>
I was able to use khtmld v0.3.2 with khtml2png v1.0.3 (with vncserver or KDE via ssh), but it produced only white picture with blurred error message.
My Kubuntu uses these paths:
The parameter -K doesn`t work with v2.x binaries, but with with v1.x it works.
If I want to use khtml2png2 (v2.x), I have to change
but I am not able to use v2.x (as I wrote above, .....kbuildsycoca running... Ctrl+C) Thank you
The problem with white pictures shouldn’t be a problem caused by khtmld. What I think is more interessting, why you cannot use
I was able to use any other tool as command. Using -K will make the daemon to ignore the macro KHTML and uses the one defined by the command line. I will take a look at the problems during the weekend at the 2 holidays, I will find some time then to check it and run more tests and run full tests with khtml2png2
You were right, I had a problem with DNS so khtml2png was unable to resolve www address.
I guess the problem with khtmld -K option is that there is executed command with “” (quoted www address and picture name).
Thanks for that hint, I will check this later!
FIY new version of khtml2png2 (v2.6.5) was released.
Hey !
I would like to use your deamon.
I'am on gentoo (ovh release 2).
I type “make install”
Man is installed but :
cd /etc/rc2.d && ln -s ../init.d/khtmld S90khtmld /bin/sh: line 0: cd: /etc/rc2.d: Aucun fichier ou répertoire de ce type
I don't know what is rc2.d and how i could correct it.
Could you help me ??
Thank you
Hi,
There are differences in some linux distribution, how they handle startup scripts. Debian places all init scripts in /etc/init.d. The /etc/rc[0-6s].d are the runlevels on Debian, when you make a symbolic link like
Then it should start the script during runlevel 2, while booting your system. This link isn't needed it only starts khtmld during boot process, you should be able to start khtmld by typing
If you want to know more about Gentoos initscripts, I can give you this link 4. Initscripts from the Gentoo documenation.
You should be able to run khtmld without this link.
Hope I could help!
Ok thanks, i understand.
But i think khtmld isn't fully installed because when i type
<pre class=“code”>/etc/init.d/khtmld start</pre>
i have this message :
<pre class=“code”>No process found<br> /etc/init.d/khtmld: line 15: /usr/local/sbin/khtmld: Aucun fichier ou répertoire de ce type</pre>
Effectively i have nothing in this directory …
but /khtmld.sh have been copied on /etc/init.d/khtmld
You know whats append??
go to the download directory of khtmld-<version> and manually copy khtmld as root to /usr/local/sbin.
It seems that everything got a bit mixed up during the last changes.
Thats what i tried . Thanks !
Now if i start khtmld manually (ssh), and i run my webscript, the line is added into file.fifo but no image is generated.
Have you got a last advice ??
In SSH
if i start khtml :
“khtmld started and listening.”
Then i give the screenshot :
echo “http://www.google.com ./google.png” > /tmp/khtmldspool
“Mounting … All current spool jobs done. Mounting fifo `/tmp/khtmldspool' and waiting for input…”
But i have not the png file…
Do i forgot something ??
Okay, here a little checklist
Just ask if you have problems.
I check …
I have no .khtmldrc
Where must i save this file ?
This shouldn't be a create problem, I think but just save it in your home directory or where ever you want. When stored as ~/.khtmldrc than it's loaded by default. If it is stored in a different location you have to use the -c option. For example
I'm lost…
Could you explain me the proccess from installing VNC / Xvnc to the generated screenshot?
I need to call html2png via web php script.
Installing an a xvncserver should be done with the emerge command, but I am not into gentoo. But I'm writing a little howto. Just give me some time…
New version up and running, please test and report back!
did any one try the php
I could not run it
form bash its working
php error:
Warning: fopen(/tmp/khtmldspool) [function.fopen]: failed to open stream: Permission denied
Check your file on the file. When you run through apache, it runs with different UID. There are following solutions:
Sol. 1 (unsecure)
Sol. 2
Sol. 3
Hi, I'm getting these errors. They might be related.
ERROR: File `/tmp/khtmldspool' already exists, but is no fifo! khtml daemon[20959]: Error reading from pipe!
./khtmldspool: line 1: http://www.google.com: No such file or directory
thanks, please advise
The file khtmld tries to open is no FIFO (named pipe). By
and restart khtmld it should be recreated correctly as named pipe. You can check it by looking at the file attributes. Check for the p-flag.
As alternative you can
$ stat khtmldspool File: `khtmldspool' Size: 0 Blocks: 0 IO Block: 4096 fifo ^^^^You also can create it manually by executing
Please check owner and file permission afterwards.
I wish a happy new year!
I am doing eveything as root.
installed khtml2png2 (version 2.6.0) - this is working fine.
I run the command “vncserver” (this creates a vnc server on :1, Xvnc :1 -desktop host.example.com:1 (root) etc)
I created a .khtmldrc file in /root which contains the following: width=800 height=600 time=30 display=:1
I then logged into the VNC server and opened two terminals. In the first:
[root@host ~]# khtmld Starting khtmld in forground… Using khtml2png at location `/usr/local/bin/khtml2png'. Using spool `/tmp/khtmldspool' for input processing. Using pidfile `/tmp/khtmld.pid'. Fork timeout set to: `60' khtml daemon[5874]: khtmld started and listening. Mounting fifo `/tmp/khtmldspool' and waiting for input…
In the second:
echo “http://www.google.com /root/goog.png” > /tmp/khtmldspool
When I do that, this appears in the first terminal:
Buffer filled, processing… Generating screenshot…
Buffer is empty, buffering… Buffer was empty. All jobs done. Mounting fifo `/tmp/khtmldspool' and waiting for input…
However, no screenshot is generated in /root.
I am on a fresh install of Centos 4.6, and as I say khtml2png2 works fine on its own.
Any ideas? Thanks for all the work you have done on this.
Leon
Which version of khtmld are you using? The one from the subversion repository or the pre-packed .tar.(gz|bz2)?
I was using the pre-packaged tar. I have just tried with the version in svn.
I did: ./bootstrap.sh ./configure make make install
to install. Now when I do: echo “http://www.google.com /root/goog.png” > /tmp/khtmldspool in one terminal, the other terminal displays:
Buffer filled, processing… Mounting fifo `/tmp/khtmldspool' and waiting for input…
i.e It no longer says the bit about “Generating Screenshot”. No screenshot is generated.
Any ideas? Is there a log I could be looking in to see what might be going wrong?
Thanks again,
Leon
Thank you for your post, I will re-check the latest prepacked tar and the SVN Version.
After I made some major changes to the part where I read the FIFO. it sometime misses the end of line. I hope I've get some time to fix that. Lot of work atm… :(
Hi, I've tried to run it on Web Script PHP. It's successful when I exec khtml2png2 in terminal and an image is created. Just let me know how I use your PHP script in web (just use the script above or something else).
Hi, I've updated the php script sample and have tested it through console only. I am still short of time, so maybe this helps:
It reads a file called “urllist.txt” and writes each line into the fifo.
<? header("Content-Type: text/plain"); function printnl($str) { print($str."\n"); } $fp = fopen("urllist.txt", "r"); if ($fp) { while (!feof($fp)) { $buffer = fgets($fp, 4096); printnl("Read: ".$buffer); $fifo = fopen("../khtmld.fifo", "w"); if ($fifo) { printnl("Writing: ".$buffer); fputs($fifo, $buffer); fflush($fifo); } fclose($fifo); } fclose($fp); } $buffer = "http://www.somehost.com/ /tmp/somehost.com.png"; $fifo = fopen("../khtmld.fifo", "w"); if ($fifo) { printnl("Writing: ".$buffer); fputs($fifo, $buffer); fflush($fifo); } fclose($fifo); ?>I don't know which version of khtmld you run, I'll upload a newer version this week. I started working on a version implementing libwrap and socket communication with khtmld, the code is still experimental, but the default FIFO mode is working.
Hi, sorry for my late reply. I tested your script and I got that warning. I cannot file the file urllist.txt and khtmld.fifo, so I cannot edit the permission of them. <b>Warning</b>: fopen(urllist.txt) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: No such file or directory in <b>/home/fantomas/www/phpinfo/index.php</b> on line <b>8</b><br /> <b>Warning</b>: fopen(../khtmld.fifo) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: Permission denied in <b>/home/fantomas/www/phpinfo/index.php</b> on line <b>26</b><br />
Current Ubuntu is 7.10, khtml2png2 -v return values Qt: 3.3.7 KDE: 3.5.8 KHTML2PNG: 2.7.5
I can get image by using command khtml2png2 but not with khtmld.
hi Julian, I've changed the fifo file by change this line $fifo = fopen(”/tmp/khtmldspool”, “w”); But nothing happens (there's no images created in /tmp). And I found that I don't have khtml2png file. By the way, version of khtmld is 0.3.5. Sorry for my bad English.
At first, be sure khtmld has write access to the destination directory, as next you should check if your webserver has permission to access the khtmld FIFO. Change them if needed, when unsure with UID or GID for the fifo, you can check if it, when setting it:
You also should have a look at the output of khtmld. Running it without deamonizing it.
The sample above with the urllist.txt, was just for testing. you only need this part of the code:
$fifo_path = "./khtmldspool"; // locate FIFO file $buffer = "http://www.somehost.com/ /tmp/somehost.com.png"; // Normally you get your buffer content from elsewhere, value just for testing purpose. $fifo = fopen($fifo_path, "w"); if ($fifo) { printnl("Writing: ".$buffer); fputs($fifo, $buffer); fflush($fifo); } fclose($fifo);I have also uploaded a newer version.
Sorry for my late reply. I had a short vacation with my family. At last, I am successful in testing khtmld on local with php script. Thanks for your help. I changed access right of khtmldspool fifo to 777, and it works OK now. And my sample PHP script is: $fifo_path = ”/tmp/khtmldspool”; locate FIFO file $buffer = “http://www.hotmail.com/ /tmp/somehost.png”; Normally you get your buffer content from elsewhere, value just for testing purpose.
$fifo = fopen($fifo_path, “w”); if ($fifo) {
fclose($fifo); }
Hi Julian, I am sort of a linux newb. I tried to compile your program but it says:
Unable to display file "": It may not exist, or permission may be denied.
Makefile:236: .deps/daemon.Po: No such file or directory make: *** No rule to make target `.deps/daemon.Po'. Stop. </source> I am running Ubuntu Hardy. Any ideas? I tried install the “daemon” package (apt-get install daemon) that completed successfully but still gives the same error when i try to “make install” Thanks!
well i screwed that one up… how do you do those code boxes? lol anyway what it said was:
/var/www/khtmld# make install Makefile:236: .deps/daemon.Po: No such file or directory make: *** No rule to make target `.deps/daemon.Po'. Stop.
Hi volto,
my main source file is called daemon.c, so I think it didn't compile correctly. Have you tried
Just try to compile it again after configure and report back!
A code box can be made by indenting with two spaces or using the <code>foobar</code>
My wiki theme is a little fscked-up, but I've got no time to fix it.
Hey thanks for the reply, Yeah I tried ./configure, I get:
Ok, using “ls -a” I found the .deps directory that I left behind in the place where i unpacked it first. I guess “mv *” doesn't move hidden directories =S
Now with that directory in place, ”./configure” returns the same error as above, but “make” now does a bunch of stuff:
root@dewaltbox:/var/www/khtmld# ./configure configure: error: cannot find install-sh or install.sh in "." "./.." "./../.." root@dewaltbox:/var/www/khtmld# make Making all in doc make[1]: Entering directory `/var/www/khtmld/doc' make[1]: Nothing to be done for `all'. make[1]: Leaving directory `/var/www/khtmld/doc' Making all in scripts make[1]: Entering directory `/var/www/khtmld/scripts' make[1]: Nothing to be done for `all'. make[1]: Leaving directory `/var/www/khtmld/scripts' make[1]: Entering directory `/var/www/khtmld' if gcc -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"khtmld\" -DVERSION=\"0.3.5\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_STRING_H=1 -DHAVE_GETOPT_H=1 -DHAVE_FCNTL_H=1 -I. -I. -g -O2 -MT daemon.o -MD -MP -MF ".deps/daemon.Tpo" -c -o daemon.o daemon.c; \ then mv -f ".deps/daemon.Tpo" ".deps/daemon.Po"; else rm -f ".deps/daemon.Tpo"; exit 1; fi daemon.c:30:20: error: signal.h: No such file or directory daemon.c:31:19: error: stdio.h: No such file or directory daemon.c:32:20: error: stdlib.h: No such file or directory daemon.c:33:20: error: unistd.h: No such file or directory daemon.c:34:19: error: fcntl.h: No such file or directory daemon.c:35:20: error: syslog.h: No such file or directory daemon.c:36:20: error: getopt.h: No such file or directory daemon.c:37:20: error: string.h: No such file or directory daemon.c:38:19: error: ctype.h: No such file or directory daemon.c:39:22: error: sys/stat.h: No such file or directory daemon.c:40:23: error: sys/types.h: No such file or directory daemon.c:41:22: error: sys/wait.h: No such file or directory daemon.c:42:22: error: sys/time.h: No such file or directory daemon.c:43:19: error: errno.h: No such file or directory daemon.c:44:17: error: pwd.h: No such file or directory daemon.c:84: error: âNULLâ undeclared here (not in a function) daemon.c:86: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before âgroupâ daemon.c: In function âexit_daemonâ: daemon.c:101: error: âSIGINTâ undeclared (first use in this function) daemon.c:101: error: (Each undeclared identifier is reported only once daemon.c:101: error: for each function it appears in.) daemon.c:104: warning: incompatible implicit declaration of built-in function âfprintfâ daemon.c:104: error: âstderrâ undeclared (first use in this function) daemon.c:110: warning: incompatible implicit declaration of built-in function âexitâ daemon.c: In function âalarm_daemonâ: daemon.c:120: warning: incompatible implicit declaration of built-in function âfprintfâ daemon.c:120: error: âstderrâ undeclared (first use in this function) daemon.c: In function âreadConfigâ: daemon.c:131: error: âFILEâ undeclared (first use in this function) daemon.c:131: error: âfpâ undeclared (first use in this function) daemon.c:140: warning: incompatible implicit declaration of built-in function âstrlenâ daemon.c:144: warning: assignment makes pointer from integer without a cast daemon.c:144: warning: assignment makes pointer from integer without a cast daemon.c:145: warning: incompatible implicit declaration of built-in function âmallocâ daemon.c:146: warning: incompatible implicit declaration of built-in function âsprintfâ daemon.c:148: warning: incompatible implicit declaration of built-in function âstrcpyâ daemon.c: In function âmount_fifoâ: daemon.c:161: error: storage size of âattrâ isnât known daemon.c:167: warning: incompatible implicit declaration of built-in function âfprintfâ daemon.c:167: error: âstderrâ undeclared (first use in this function) daemon.c:168: error: âO_RDWRâ undeclared (first use in this function) daemon.c:169: error: âerrnoâ undeclared (first use in this function) daemon.c:170: error: âEACCESâ undeclared (first use in this function) daemon.c:170: error: âENAMETOOLONGâ undeclared (first use in this function) daemon.c:170: error: âENOENTâ undeclared (first use in this function) daemon.c:170: error: âENOSPCâ undeclared (first use in this function) daemon.c:170: error: âENOTDIRâ undeclared (first use in this function) daemon.c:170: error: âEROFSâ undeclared (first use in this function) daemon.c:175: error: âEEXISTâ undeclared (first use in this function) daemon.c:178: error: âO_RDONLYâ undeclared (first use in this function) daemon.c: In function âread_fifoâ: daemon.c:205: error: âsize_tâ undeclared (first use in this function) daemon.c:205: error: expected â;â before ânreadâ daemon.c:207: error: âpid_tâ undeclared (first use in this function) daemon.c:207: error: expected â;â before âpidâ daemon.c:209: warning: incompatible implicit declaration of built-in function âbzeroâ daemon.c:213: error: âLOG_CRITâ undeclared (first use in this function) daemon.c:214: warning: incompatible implicit declaration of built-in function âexitâ daemon.c:218: warning: incompatible implicit declaration of built-in function âmallocâ daemon.c:221: error: ânreadâ undeclared (first use in this function) daemon.c:223: warning: incompatible implicit declaration of built-in function âfprintfâ daemon.c:223: error: âstderrâ undeclared (first use in this function) daemon.c:250: warning: incompatible implicit declaration of built-in function âstrchrâ daemon.c:251: warning: incompatible implicit declaration of built-in function âstrncpyâ daemon.c:252: warning: incompatible implicit declaration of built-in function âstrlenâ daemon.c:260: error: âpidâ undeclared (first use in this function) daemon.c:265: error: dereferencing pointer to incomplete type daemon.c:265: error: dereferencing pointer to incomplete type daemon.c:265: error: dereferencing pointer to incomplete type daemon.c:267: error: dereferencing pointer to incomplete type daemon.c:268: error: dereferencing pointer to incomplete type daemon.c:273: error: dereferencing pointer to incomplete type daemon.c:275: warning: incompatible implicit declaration of built-in function â_exitâ daemon.c:275: error: âEXIT_FAILUREâ undeclared (first use in this function) daemon.c:285: warning: incompatible implicit declaration of built-in function âfprintfâ daemon.c: In function âprintHelpâ: daemon.c:294: warning: incompatible implicit declaration of built-in function âfprintfâ daemon.c:294: error: âstderrâ undeclared (first use in this function) daemon.c: In function âprintVersionâ: daemon.c:299: warning: incompatible implicit declaration of built-in function âfprintfâ daemon.c:299: error: âstderrâ undeclared (first use in this function) daemon.c: In function âmainâ: daemon.c:307: error: âFILEâ undeclared (first use in this function) daemon.c:307: error: âfpâ undeclared (first use in this function) daemon.c:310: error: âSIGINTâ undeclared (first use in this function) daemon.c:311: error: âSIGALRMâ undeclared (first use in this function) daemon.c:316: error: array type has incomplete element type daemon.c:317: error: ârequired_argumentâ undeclared (first use in this function) daemon.c:319: error: âno_argumentâ undeclared (first use in this function) daemon.c:336: warning: incompatible implicit declaration of built-in function âfprintfâ daemon.c:336: error: âstderrâ undeclared (first use in this function) daemon.c:337: error: âoptargâ undeclared (first use in this function) daemon.c:349: error: âEXIT_SUCCESSâ undeclared (first use in this function) daemon.c:363: warning: assignment makes pointer from integer without a cast daemon.c:373: error: âoptoptâ undeclared (first use in this function) daemon.c:379: warning: incompatible implicit declaration of built-in function âabortâ daemon.c:384: warning: incompatible implicit declaration of built-in function âfprintfâ daemon.c:384: error: âstdoutâ undeclared (first use in this function) daemon.c:391: error: dereferencing pointer to incomplete type daemon.c:394: error: âLOG_PIDâ undeclared (first use in this function) daemon.c:394: error: âLOG_PERRORâ undeclared (first use in this function) daemon.c:394: error: âLOG_DAEMONâ undeclared (first use in this function) daemon.c:399: error: âEXIT_FAILUREâ undeclared (first use in this function) daemon.c:412: warning: incompatible implicit declaration of built-in function âabortâ daemon.c:416: warning: incompatible implicit declaration of built-in function âmallocâ daemon.c:416: warning: incompatible implicit declaration of built-in function âstrlenâ daemon.c:416: warning: passing argument 1 of âstrlenâ makes pointer from integer without a cast daemon.c:417: warning: incompatible implicit declaration of built-in function âsprintfâ daemon.c:421: warning: incompatible implicit declaration of built-in function âmallocâ daemon.c:426: error: âLOG_NOTICEâ undeclared (first use in this function) make[1]: *** [daemon.o] Error 1 make[1]: Leaving directory `/var/www/khtmld' make: *** [all-recursive] Error 1 root@dewaltbox:/var/www/khtmld#Looks like you are missing the basic header files, try installing libc6-dev, this sould solve the missing
also consider installing the package automake
after that it should work
Thanks, that seemed to have worked, it installed, but I can't get it to do anything, I ran the example script and it didn't give any error, but also didn't provide any output. I will have to try some more stuff later today (or this week) when i have more time and there is less on my mind. Thanks for the reply!
Ok, two things that I don't understand in order of importance. 1) Where do i store the .khtmldrc file or where does it exist by default? 2) Where can I dynamically specify parameters like capture resolution or image resolution like you can with khtml2png2?
I believe I have khtmld running properly now except it may be referencing the wrong X display because it outputs nothing. Here is where I am.
Nothing happens, can't find google.com.png anywhere on the system, but yet there is no error.Have you checked if
is correct, khtml2png2 is not my project, but this is the part which makes the screenshot. You could see if there is a package for your distribution, otherwise you should download the source and compile it on your own.
The khtmld.spool looks good so far.
Oh, actually it is located at /usr/bin/khtml2png2 How do I fix it? Also how do I specify the display (i have Xvfb running at 1024×768:24 on :2)
Btw, khtml2png2 works, I tested in SSH:
Despite the KDE errors, that actually produces a good image.
There should be a command line switch -K <khtml2png_binary_location>
Just try the -h or –help to see what other options you have.
You also should check this one: khtmldrc.for.use.with.khtml2png.2.5.x.or.later
Ok I restarted it like so:
no errors, so i did:
but it just freezes there, i left it for like an hour, and still doesn't give me the command line back. Lol this is getting very complicated for just a screenshot generator. Tried as webdev and as root. Any idea what im doing wrong? Thanks for all the help.
Hi,
sudo /etc/init.d/khtmld restart -K /usr/bin/khtml2png2 –user webdevThat's not working. Try it with out an init script at first, just go to the build directory of khtmld and test it with following command
this should start khtmld in forground. Only use the init script after khmld works. You might need to edit the init script as well. It's not well maintained.
Use a other terminal to write into the fifo.
Please use an absolute path for the destination of the image. It's important when you run it as daemon, it changes to '/' and drops it privilidges (common way for daemons).
All right I think this could be helpful.
Ok I did that, now it is saying it cannot connect to X server. I created the .khtmldrc file with:
and I put it in /var/www/ because that is the home dir for user webdev. I know that is the correct display, it works when i just use khtml2png2. In the other terminal where khtmld is running, it says:
So I have a feeling its not reading the settings in .khtmldrc, right?To be sure, use the -c <config> flag, but this is documented when reading through
When this isn't working you might need to set proper permission on your X. There is a tool called
this configures the authority list of your X server. easiest way to try this, start xauth. Here's a a copy&paste from a console
There I add a key for ninja/unix:2. But this is X related…
Hey thanks! using -c <config> flag worked, I dont know why I didn't notice that bit in the help file before.
Is there a way to send custom values to temporarily replace values in the .khtmldrc? Like if in a script I wanted to change the output resolution of a screenshot, could I do that?
Also A problem I am running into, which I know it's not your program, but maybe you will have an idea, I am getting a gray square in my screenshots. Here is an example. <img src=“http://volto.us/img/screenshots/experiment1.png”> I tried –disable-window and –disable-js and –disable-plugins but it still results in that stupid gray box apearing in the middle. I think its because it's asking if i want to accept a cookie, but many searches on google, and even the konqueror website return no results on how to disable all cookies, or just not prompt for cookies at all.
Ok, well I found out how to get rid of the gray box, from the khtml2png website:
. so i made those edits but now it crashes like this and makes no screenshot: . my .khtmldrc:I am not sure (haven't looked at the code for a while now), but iirc I haven't finished the config parser, so params without values aren't supported
So one idea would to test if adding a = to the options or exploiting it by I am not sure what happens, haven't tested it. Or you hard codeiff --git a/cfg_khtml.c b/cfg_khtml.c index b275752..8c5c83f 100644 --- a/cfg_khtml.c +++ b/cfg_khtml.c @@ -33,9 +33,13 @@ void readConfig(const char *cfg) char s[128]; char *t1, *t2; // temporary vars for string manipulation FILE *fp; - confsize = 1; + confsize = 5; k2pconfig[0] = (char *)"--nocrashhandler"; // Disable KDE crash handler + k2pconfig[1] = (char *)"--disable-js"; + k2pconfig[2] = (char *)"--disable-java"; + k2pconfig[3] = (char *)"--disable-jplugins"; + k2pconfig[4] = (char *)"--disable-window"; fp = fopen(cfg, "r"); if (fp) { while (confsize < CMDLINEOPTS - 4 && fgets(s, 128, fp)) {Just replace the line with the - in cfg_khtml.c and add those lines marked by + and recompile…
Adding a = to the options indeed works : Using “disable-js=–get-body” in the .khtmldrc allows you to generate full lenght screenshots.
Hi can anyone help me with this? Trying to get khtmld working doesn't seem to be working and have followed the INSTALL guide/documentation.
# = What I typed at command line prompt.
- BTW I am running CENTOS 5.3 i686 & have khtml2png/khtml2png2 installed and
working fine.
First - Download the latest version of khtmld from: http://sourceforge.net/project/showfiles.php?group_id=147327
This will download, extract and change dir inside that khtmld folder: # wget http://kent.dl.sourceforge.net/sourceforge/khtmld/khtmld-0.3.8.tar.gz &&
tar xzf khtmld-0.3.8.tar.gz && cd khtmld-0.3.8
Now we are inside the khtmld-0.3.8 folder. Run the chmod to set the file
permissions to executable on the configure file: # chmod +x configure.in
Check if the permissions are correct: # ls -l configure.in
As the install documentation states (vi INSTALL) either run the ”./configure” or
you're using `csh' on an old version of System V, you might need to type `sh
./configure' instead to prevent `csh' from trying to execute `configure' itself.
So I tired and got this?
# ./configure -bash: ./configure: No such file or directory
# sh ./configure
# ./configure.in
Any help would be highly appreciated! ty.
Hi blackwaltz,
you need to run the command 'autogen.sh' first.
the command is a simple script which runs the automake commands for you. So you need to check if automake is installed. After the automake tools run through it will execute ”./configure $@”. The $@ means that all parameters from ./autogen.sh are passed to ./configure. You can invoke autogen.sh like:
to have khmtld installed in /usr/local/bin with “make install”
Hi Julian - Thank you so much for your response really appreciate it! So what I did was to install now is.
<pre> # sh ./autogen.sh # make # make check # make install # khtmld </pre>
Outputs.. khtmld(aemon) version: 0.3.8 (build date: Jun 22 2009 - 13:19:02) Starting khtmld in forground… Using khtml2png at location `/usr/local/bin/khtml2png'. Using spool `/tmp/khtmldspool' for input processing. Using pidfile `/tmp/khtmld.pid'. Use khtml2png with uid `0'. Fork timeout set to: `60' Opening fifo `/tmp/khtmldspool' and waiting for input…
Great seems like everything is running now?! :)
Now i tried the above bash example (in a new shell window): <pre> # echo “http://www.google.com /tmp/example.png” >/tmp/khtmldspool </pre>
Then original shell window outputs: Opening fifo `/tmp/khtmldspool' and waiting for input… DONE
I checked the ”/tmp/” folder for the “example.png” couldn't find anything.
Just as a test to check if khtml2png2 is still running/functioning; <pre> # khtml2png2 –display :0 http://google.com/ /tmp/example2.png </pre>
khtml2png2 generated the image fine. what am I doing wrong?!… I am so confused - sorry for the hassle.
Cheers & thank you.
Hi blackwaltz, congratulation for getting it running
Your log output shows, khtmld is expecting khtml2png at the following location:
You can get a list of all commandline parameters by adding
–helpto the commandTo solve your above problem, try adding
-K <path to your commandlineAlso take a look at the configuration file which can be placed in your home directory or submitted via commandline khtmldrc.for.use.with.khtml2png.2.5.x.or.later
Hi J :)
Everything working fine now -well sort of haha :) thank you again for your help highly appreciate this man cheers… Having a-bit of an issue with khtmld crashing? here's what's going on…
Start the khtmld service/daemon.
— Now I call the PHP code, I am passing a variable into the script via a query string everything seems to be working ok except when trying to call URLs on websites like youtube as it seems to need the whole path (for example):
Crashes = http://youtube.com Works fine = http://www.youtube.com
Here is the output.
The above isn't the only thing that's cashing it if I call a URL like twice first time it works then second time around it just crashes same output as before but it says something like this first?
Do you know what maybe be causing this?
Another thing I wanted to ask is if there is a script I could run if the khtmld -Daemon dies/to restart it automatically? And is it possible to initiate a script/shell/command line call after the khtmld has finished generating the screen shot? (can I modify anything like hard code something into it) as I want to move the generated image to another folder as I can only get it to work if the PHP tells it to output the image into the /tmp/ folder?.
Thanks!!
Hi, the seg. fault seems to be a greater problem. For security reason you shouldn't run it as root. You supply a different user id with the
-u' or–user'', for example the one your webserver uses.The error
Doesn't belong to khtmld. May be some kde-lib inclusion from khtml2png, but haven't checked it.
To store a picture on a different location you could simply say:
Hi blackwaltz, I had same problem when I installed khtmld-0.3.8. Several pages were processed correctly, others (randomly) not. I decided to install khtmld-0.3.5 and got no problem. Every page is processed correctly. So maybe you should try it too.
TO Julian Knauer: I really want to thank you for your work on this one. It helps me a lot! Thanks!
jazzik
Thanks - Jazzik I'll be sure to try that one out next.
I've actually stopped using khtmld/khtml2png all together for now (linux renders pages differently to like say if I was a Windows user which 90% of internet users are so when trying to mimic a web webpage capture using linux doesn't give accurate results - but i guess for making small thumbnails its fine).
And yes thanks Julian! amazing man..
Hi,
I accidently deleted the previous message. So here is what I remember. There was a mistake in your parameters. You need to place the path to khtml2png2 after the -K.
Please try something like this: