khtmld(aemon)

Announcments

  • Feb. 18, 2009
    I have merged the dev branch to master on my git repository. There is a change in the config parser, which allows you to use a special configuration option to indicate wich options should be passed to the KHTML engine.
    The current release with the tag v0.3.8 can be found by having a look at Gitweb, a .tar.gz listed under downloads or from the SourceForge project page. I have also updated the configuration example on this page.
  • Jul. 04, 2008
    Added downloads of the experimental branch sock_dev, with the latest version of the source.
  • Apr. 11, 2008
    I currently have pushed a development version of khtmld into my Git repository, the latest branch is sock_dev, but it has not been tested, and may contain syntax problems. If you are brave or impatient you can get this branch und run a test.
  • Apr. 10, 2008
    Here you can inform yourself about the current process on khtmld.
  • Oct. 09, 2007
    Released version 0.3.5 » Download
    After long time I finally managed to eliminate the latest problems of khtmld.

What is khtmld

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).

Credits

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.

How it works

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.)

Examples 1.1

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);
    }
    ?>

.khtmldrc for use with khtml2png 1.x.x

width=1280
height=1024
scaled-width=800
scaled-height=600
flash-delay=5
time=30
display=:0.0

KHTML=disable-js
KHTML=disable-java
Note: display needs to be set, check your X server config.
:0.0 should be your first screen,
:1.0 could be a second X server.

.khtmldrc for use with khtml2png 2.5.x or later

width=800
height=600
time=30
display=:0.0

KHTML=disable-js
KHTML=disable-java
Note: display needs to be set, check your X server config.
:0.0 should be your first screen,
:1.0 could be a second X

khtml2png2 doesn't have parameters like scaled-with do not put them into your .khtmldrc.

Compatibility

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

Project Information

Latest Version: 0.3.8
Project hosted at Sourceforge.net: http://www.sourceforge.net/projects/khtmld

Downloads via SourceForge

Local Downloads

Discussion

Eric Haskins, 2007/03/23 00:22

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

Julian Knauer, 2007/03/23 11:49

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

echo “http://www.example.com /tmp/example.png” >/tmp/khtmldspool

khtml then should read from that pipe and start processing...

I am sorry for the poor documentation. I’m working on it..

Jonathan Reichert, 2007/04/03 20:21

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?

Julian Knauer, 2007/04/09 22:53

It should look something like this:

width=1000
height=1000
scaled-width=80
scaled-height=100
flash-delay=10
time=30
display=:1
pid=./pidfile

I had no time to test this with the new config-parser, but it should work.

Albert, 2007/05/11 09:31

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

Julian Knauer, 2007/05/11 21:39

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.

Albert, 2007/05/12 13:27

I hope I use the right display. The problem could be also in khtml2png2, I don’t know...

Ubuntu 6.06 LTS
$vncserver -geometry 1280x1024 -depth 16   

New 'X' desktop is mars:1

Starting applications specified in /etc/X11/Xsession
Log file is /home/albert/.vnc/mars:1.log

$more /home/albert/.vnc/mars:1.log
Couldn't open RGB_DB '/usr/X11R6/lib/X11/rgb'
12/05/07 13:04:47 Xvnc version 3.3.7 - built Feb 20 2006 12:05:53
12/05/07 13:04:47 Copyright (C) 2002-2003 RealVNC Ltd.
12/05/07 13:04:47 Copyright (C) 1994-2000 AT&T Laboratories Cambridge.
12/05/07 13:04:47 All Rights Reserved.
12/05/07 13:04:47 See http://www.realvnc.com for information on VNC
12/05/07 13:04:47 Desktop name 'X' (mars:1)
12/05/07 13:04:47 Protocol version supported 3.3
12/05/07 13:04:47 Listening for VNC connections on TCP port 5901

$khtml2png2 -v
Qt: 3.3.6
KDE: 3.5.2
KHTML2PNG: 2.6.0

$khtml2png2 www.google.com google.png
khtml2png2: cannot connect to X server

$khtml2png2 --display mars:1 www.google.com google.png
Xlib:  extension "XInputExtension" missing on display "mars:1.0".
Failed to get list of devices
Xlib:  extension "XInputExtension" missing on display "mars:1.0".
Failed to get list of devices
kbuildsycoca running...

and I have to end this (Ctrl+C) and no picture is created.

$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[27921]: khtmld started and listening.
Mounting fifo `/tmp/khtmldspool' and waiting for input... DONE
New jobs in spool, working...
All current spool jobs done.
Mounting fifo `/tmp/khtmldspool' and waiting for input... 

$echo “http://www.google..com /tmp/example.png” >/tmp/khtmldspool

Everything seems to be correct, but none /tmp/example.png is not created.

Thank you

Julian Knauer, 2007/05/13 22:45

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.

Albert, 2007/05/16 21:18
$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

Julian Knauer, 2007/05/19 20:32

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

/usr/local/bin/khtml2png /usr/local/bin/khtml2png <options...>

I hope I’ve fixed that now! And the parameters passed to execv() are correct.

I have changed your <pre> tags to <code>

Albert, 2007/05/23 21:39

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:

/usr/local/bin/khtml2png2
/usr/local/kde/bin/khtml2png

$more .khtmldrc
display mars:2

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

/* GLOBAL DEFAULTS + CONSTANTS */
#define KHTML "/usr/local/bin/khtml2png2"

but I am not able to use v2.x (as I wrote above, .....kbuildsycoca running... Ctrl+C) Thank you

Julian Knauer, 2007/05/24 00:50

The problem with white pictures shouldn’t be a problem caused by khtmld. What I think is more interessting, why you cannot use

khtmld -K /usr/local/bin/khtml2png2

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

Albert, 2007/05/31 21:24

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).

Julian Knauer, 2007/06/05 14:00
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!

Albert, 2007/06/06 18:30

FIY new version of khtml2png2 (v2.6.5) was released.

Ivan, 2007/08/30 17:58

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

jpk, 2007/08/30 18:29

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

cd /etc/rc2.d && ln -s ../init.d/khtmld S90khtmld

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

/etc/init.d/khtmld start

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!

Ivan, 2007/08/30 19:13

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??

jpk, 2007/08/30 19:29

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.

Ivan, 2007/08/30 19:53

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 ??

Ivan, 2007/08/30 20:08

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 ??

jpk, 2007/08/30 20:10

Okay, here a little checklist

  • khtml2png correctly installed?
  • Have you read the other comments?
  • X server / VNC server installed
  • user rights? (FIFO and output directory)
  • used correct fifo?
  • used correct input format (“URL OUTPUT”)?

Just ask if you have problems.

Ivan, 2007/08/30 20:18

I check …

I have no .khtmldrc

Where must i save this file ?

jpk, 2007/08/30 21:55

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

khtmld -c /etc/khtmldrc
Ivan, 2007/09/03 18:39

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.

jpk, 2007/09/13 15:43

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…

Julian Knauer, 2007/10/09 20:58

New version up and running, please test and report back!

galaxyboss, 2007/12/14 17:22

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

Julian Knauer, 2007/12/17 19:31

Check your file on the file. When you run through apache, it runs with different UID. There are following solutions:

Sol. 1 (unsecure)

chmod 666 /tmp/khtmldspool

Sol. 2

chown <user_of_httpd> /tmp/khtmldspool

Sol. 3

chgrp <group_where_httpd_is_in> /tmp/khtmldspool
chmod g+w /tmp/khtmldspool
Josh, 2007/12/30 08:36

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

Julian Knauer, 2007/12/30 18:51

The file khtmld tries to open is no FIFO (named pipe). By

rm /tmp/khtmldspool

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.

$ ls -l /tmp/khtmldspool
prw-r--r-- 1 jpk users 0 30. Dez 18:04 khtmldspool
^

As alternative you can

$ stat khtmldspool
  File: `khtmldspool'
  Size: 0               Blocks: 0          IO Block: 4096   fifo
                                                            ^^^^

You also can create it manually by executing

$ mkfifo /tmp/khtmldspool

Please check owner and file permission afterwards.

I wish a happy new year!

Leon Chevalier, 2008/03/08 10:00

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

Julian Knauer, 2008/03/12 23:05

Which version of khtmld are you using? The one from the subversion repository or the pre-packed .tar.(gz|bz2)?

Leon, 2008/03/17 21:44

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

Julian Knauer, 2008/03/20 12:51

Thank you for your post, I will re-check the latest prepacked tar and the SVN Version.

Julian Knauer, 2008/03/17 00:41

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… :(

Anh Pham, 2008/07/03 19:52

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).

Julian Knauer, 2008/07/03 23:47

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.

Anh Pham, 2008/07/06 20:30

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.

Anh Pham, 2008/07/06 20:45

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.

Julian Knauer, 2008/07/07 00:41

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:

chmod 666 <khtmldfifo>

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.

ANh pham, 2008/07/20 10:08

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) {

  echo "Writing: ".$buffer;
  fputs($fifo, $buffer);
  fflush($fifo);

fclose($fifo); }

volto, 2008/09/26 06:14

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!

volto, 2008/09/26 06:17

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.

Julian Knauer, 2008/09/26 08:41

Hi volto,

my main source file is called daemon.c, so I think it didn't compile correctly. Have you tried

./configure
make

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.

volto, 2008/09/26 17:11

Hey thanks for the reply, Yeah I tried ./configure, I get:

configure: error: cannot find install-sh or install.sh in "." "./.." "./../.."

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#

Julian Knauer, 2008/09/30 18:40

Looks like you are missing the basic header files, try installing libc6-dev, this sould solve the missing

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

also consider installing the package automake

after that it should work

volto, 2008/09/30 19:43

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!

volto, 2008/10/01 04:27

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.

$ ls -l /tmp/khtmld.spool
prw-r--r-- 1 webdev webdev 0 2008-09-30 21:02 /tmp/khtmld.spool

$ stat /tmp/khtmld.spool
  File: `/tmp/khtmld.spool'
  Size: 0               Blocks: 0          IO Block: 4096   fifo
Device: 801h/2049d      Inode: 4259864     Links: 1
Access: (0644/prw-r--r--)  Uid: ( 1001/  webdev)   Gid: ( 1001/  webdev)
Access: 2008-09-30 21:02:08.000000000 -0500
Modify: 2008-09-30 21:02:08.000000000 -0500
Change: 2008-09-30 21:05:29.000000000 -0500

$ sudo /etc/init.d/khtmld restart
khtmld will be put into background...
Using khtml2png at location `/usr/local/bin/khtml2png2'.
Using spool `/tmp/khtmld.spool' for input processing.
Using pidfile `/tmp/khtmld.pid'.
Fork timeout set to: `60'
$ echo "http://google.com ./google.com.png">/tmp/khtmld.spool
$ 
Nothing happens, can't find google.com.png anywhere on the system, but yet there is no error.

Julian Knauer, 2008/10/01 09:07

Have you checked if

Using khtml2png at location `/usr/local/bin/khtml2png2'.

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.

volto, 2008/10/01 09:50

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:

webdev@dewaltbox:~/$ khtml2png2 --sw 200 --sh 160 --disable-window http://brokerlineup.com brokerlineup.com.png
kbuildsycoca running...
kio (KIOConnection): ERROR: Header read failed, errno=104
kio (KIOConnection): ERROR: Header has invalid size (-1)
webdev@dewaltbox:~/$ DCOP Cleaning up dead connections.

Despite the KDE errors, that actually produces a good image.

Julian Knauer, 2008/10/01 10:24

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

volto, 2008/10/01 21:54

Ok I restarted it like so:

sudo /etc/init.d/khtmld restart -K /usr/bin/khtml2png2 --user webdev

no errors, so i did:

echo "http://google.com example.png">/tmp/khtmldspool

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.

Julian Knauer, 2008/10/01 22:20

Hi,

sudo /etc/init.d/khtmld restart -K /usr/bin/khtml2png2 –user webdev

That'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

./khtmld -K /usr/bin/khtml2png2 --user webdev

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.

echo "http://google.com /tmp/example.png">/tmp/khtmld.spool

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.

volto, 2008/10/02 01:19

Ok I did that, now it is saying it cannot connect to X server. I created the .khtmldrc file with:

width=900
height=700
time=30
display=:2

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:

$ sudo khtmld -K /usr/bin/khtml2png2 --user webdev
Starting khtmld in forground...
Using khtml2png at location `/usr/bin/khtml2png2'.
Using spool `/tmp/khtmldspool' for input processing.
Using pidfile `/tmp/khtmld.pid'.
Use khtml2png with uid `1001'.
Fork timeout set to: `60'
khtml daemon[20105]: khtmld started and listening.
Mounting fifo `/tmp/khtmldspool' and waiting for input... DONE

Buffer filled, processing...
Generating screenshot...
--nocrashhandler: cannot connect to X server

Buffer is empty, buffering...
Buffer was empty. All jobs done.
So I have a feeling its not reading the settings in .khtmldrc, right?

Julian Knauer, 2008/10/02 08:56

To be sure, use the -c <config> flag, but this is documented when reading through

./khtmld -h

When this isn't working you might need to set proper permission on your X. There is a tool called

xauth

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

% xauth
Using authority file /home/jpk/.Xauthority
xauth> list
192.168.0.33:0  MIT-MAGIC-COOKIE-1  369e45fc82f09bf2b55d6ae219d9f0ce
[fe80::219:7dff:fe1d:9da]:0  MIT-MAGIC-COOKIE-1  369e45fc82f09bf2b55d6ae219d9f0ce
ninja/unix:0  MIT-MAGIC-COOKIE-1  369e45fc82f09bf2b55d6ae219d9f0ce
xauth> add ninja/unix:2  MIT-MAGIC-COOKIE-1  369e45fc82f09bf2b55d6ae219d9f0ce
xauth> exit
Writing authority file /home/jpk/.Xauthority

There I add a key for ninja/unix:2. But this is X related…

volto, 2008/10/03 18:03

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.

volto, 2008/10/03 19:33

Ok, well I found out how to get rid of the gray box, from the khtml2png website:

Edit ~/.kde/share/config/kcookiejarrc and add the lines:

[Cookie Dialog]
PreferredPolicy=2
ShowCookieDetails=false

[Cookie Policy]
CookieDomainAdvice=
CookieGlobalAdvice=Accept

Now add in ~/.kde/share/config/khtmlrc the following lines:

[Java/JavaScript Settings]
PopupBlockerPassivePopup=false
. so i made those edits but now it crashes like this and makes no screenshot:
Mounting fifo `/tmp/khtmldspool' and waiting for input... DONE

Buffer filled, processing...
Generating screenshot...
terminate called after throwing an instance of 'DOM::DOMException'
KCrash: Application '--nocrashhandler' crashing...
==> The daemon made a boo boo <==

Buffer is empty, buffering...
Buffer was empty. All jobs done.
. my .khtmldrc:
disable-js
disable-java
disable-plugins
disable-window
width=900
height=700
time=30
display=:2
sw=200
sh=160

Julian Knauer, 2008/10/03 23:35

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

disable-js
disable-java
disable-plugins
disable-window
So one idea would to test if adding a = to the options or exploiting it by
disable-js=--disable-java
disable-plugins=--disable-window
I am not sure what happens, haven't tested it. Or you hard code

iff --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…

Matt, 2008/11/18 09:47

Adding a = to the options indeed works : Using “disable-js=–get-body” in the .khtmldrc allows you to generate full lenght screenshots.

blackwaltz, 2009/06/21 17:51

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.

= If there was an output/error returned.

- 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

-rwxrwxr-x 1 root root 1703 Feb 18 14:43 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

sh: ./configure: No such file or directory

# ./configure.in

./configure.in: line 1: syntax error near unexpected token `daemon.c'
./configure.in: line 1: `AC_INIT(daemon.c)'

Any help would be highly appreciated! ty.

Julian Knauer, 2009/06/21 19:36

Hi blackwaltz,

you need to run the command 'autogen.sh' first.

# sh ./autogen.sh

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:

# sh ./autogen.sh --prefix=/usr/local

to have khmtld installed in /usr/local/bin with “make install”

blackwaltz, 2009/06/22 13:50

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.

Julian Knauer, 2009/06/23 11:59

Hi blackwaltz, congratulation for getting it running :-D

Your log output shows, khtmld is expecting khtml2png at the following location:

/usr/local/bin/khtml2png

You can get a list of all commandline parameters by adding –help to the command

khtmld --help

To solve your above problem, try adding -K <path to your commandline

# kthmld -K `which khtmld2png2`

Also 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

blackwaltz, 2009/06/24 12:56

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.


[root]# khtmld -K /usr/local/bin/khtml2png2
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/khtml2png2'.
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... 

— 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.

kbuildsycoca running...
Opening fifo `/tmp/khtmldspool' and waiting for input... DONE
*** glibc detected *** khtmld: free(): invalid pointer: 0x0804d308 ***
======= Backtrace: =========
/lib/libc.so.6[0x4be0a0f1]
/lib/libc.so.6(cfree+0x90)[0x4be0dbc0]
khtmld[0x80491f9]
khtmld[0x804944b]
khtmld[0x8049a4c]
/lib/libc.so.6(__libc_start_main+0xdc)[0x4bdb6e8c]
khtmld[0x8048fb1]
======= Memory map: ========
08048000-0804c000 r-xp 00000000 08:01 721015     /usr/local/bin/khtmld
0804c000-0804d000 rw-p 00004000 08:01 721015     /usr/local/bin/khtmld
0804d000-0806e000 rw-p 0804d000 00:00 0          [heap]
4bd7e000-4bd98000 r-xp 00000000 08:01 3211329    /lib/ld-2.5.so
4bd98000-4bd99000 r--p 00019000 08:01 3211329    /lib/ld-2.5.so
4bd99000-4bd9a000 rw-p 0001a000 08:01 3211329    /lib/ld-2.5.so
4bda1000-4bedf000 r-xp 00000000 08:01 3212056    /lib/libc-2.5.so
4bedf000-4bee1000 r--p 0013e000 08:01 3212056    /lib/libc-2.5.so
4bee1000-4bee2000 rw-p 00140000 08:01 3212056    /lib/libc-2.5.so
4bee2000-4bee5000 rw-p 4bee2000 00:00 0
4bf06000-4bf0d000 r-xp 00000000 08:01 3212204    /lib/libwrap.so.0.7.6
4bf0d000-4bf0e000 rw-p 00007000 08:01 3212204    /lib/libwrap.so.0.7.6
4bfe5000-4bff8000 r-xp 00000000 08:01 3212172    /lib/libnsl-2.5.so
4bff8000-4bff9000 r--p 00012000 08:01 3212172    /lib/libnsl-2.5.so
4bff9000-4bffa000 rw-p 00013000 08:01 3212172    /lib/libnsl-2.5.so
4bffa000-4bffc000 rw-p 4bffa000 00:00 0
4bffe000-4c009000 r-xp 00000000 08:01 3212206    /lib/libgcc_s-4.1.2-20080825.so.1
4c009000-4c00a000 rw-p 0000a000 08:01 3212206    /lib/libgcc_s-4.1.2-20080825.so.1
b7e00000-b7e21000 rw-p b7e00000 00:00 0
b7e21000-b7f00000 ---p b7e21000 00:00 0
b7f9b000-b7f9d000 rw-p b7f9b000 00:00 0
b7fa0000-b7fa1000 rw-p b7fa0000 00:00 0
b7fa1000-b7faa000 r-xp 00000000 08:01 3212087    /lib/libnss_files-2.5.so
b7faa000-b7fab000 r--p 00008000 08:01 3212087    /lib/libnss_files-2.5.so
b7fab000-b7fac000 rw-p 00009000 08:01 3212087    /lib/libnss_files-2.5.so
b7fac000-b7fad000 rw-p b7fac000 00:00 0
bfd98000-bfdad000 rw-p bffeb000 00:00 0          [stack]
ffffe000-fffff000 r-xp 00000000 00:00 0          [vdso]
Aborted
[root]#

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?

ASSERT: "sb" in statusbarextension.cpp (155)

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!!

Julian Knauer, 2009/06/24 21:14

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

ASSERT: "sb" in statusbarextension.cpp (155)

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:

# http://goatpr0n.de /var/www/some/web/application/goatpr0n.png
jazzik, 2009/08/12 21:48

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

blackwaltz, 2009/08/13 20:34

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..

Julian Knauer, 2010/02/02 18:01

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:

khtmld -K /usr/local/bin/khtml2png2 -c /etc/khtmld.conf
Gary Illyes, 2010/02/09 21:50

Hats off for putting together this!

Julian, a question: is it possible to generate screen caps of the full page rather than a fixed height? This can be accomplished with khtml2png2 with the following command (assuming the virtual display is set to 2):

DISPLAY=localhost:2.0 khtml2png2 –disable-window –disable-redirect –width 1024 –get-body http://docs.python.org/extending/extending.html pydocs.png

However having the following configuration file seems to change nothing (there are line breaks after each argument; just in case the commenting system strips them):

width=1024 time=30 display=:2.0 KHTML=disable-window KHTML=disable-redirect KHTML=get-body KHTML=disable-popupkiller

The screenshots are generated correctly, but they're cut at about 780-800 px (didn't check it exactly)

Any idea or hint?

Yogesh Salvi, 2010/05/06 13:07

Hello Sir,

We are using khtml lib to generate web page thumbnail.

We are using 64bit server with linux

KDE version is 3.5.4.

When we are trying to generate it we are getting following errors:

DCOP aborting while waiting for answer from 'kded' DCOPServer::DCOPReplyDelayed for unknown connection. Sir, if you have any idea abt it please help us.

Waiting for positive reply.

Thanks and Regards, Yogesh Salvi

Julian Knauer, 2010/05/28 16:32

Sorry, but I cannot help you with this problem. It is a KDE specific problem, I only can give support for khtmld!

Havearticles, 2010/06/12 10:07

Buffer filled, processing… Generating screenshot… terminate called after throwing an instance of 'DOM::DOMException' KCrash: Application '–nocrashhandler' crashing…

> The daemon made a boo boo <

Buffer is empty, buffering… Buffer was empty. All jobs done. Mounting fifo `/tmp/khtmldspool' and waiting for input…

How to fix it?

Julian Knauer, 2010/06/12 11:30

This happens when a timeout is reached, when waiting for khtml2png, but the 'DOM::DOMException' looks like something from khtml2png. If you are using khtml2png instead of khtml2png2. Could you please try the same website with khtml2png2? Also plase check if you accept all cookies from websites and enabled javascript? When khtmld cannot control khtml2png to accept these!

Tom, 2010/09/04 15:20

Hi there, I have the same problem with some websites using khtml2png2 getting an DOM::DOMException

Example: khtml2png2 -t 20 -w 1024 -h 768 -sw 200 -sh 150 http://www.targobank.de /tmp/test.png terminate called after throwing an instance of 'DOM::DOMException' KCrash: Application 'khtml2png2' crashing…

But most of the websites are working, any ideas?

Julian Knauer, 2010/09/05 16:12

Hi Tom,

I am sorry but this is a khtml2png2 problem and I don't know this project so well. My knowledge is only limited on letting in run using my programm. Maybe there is broken Javascript, Java or Flash involved.

Tom, 2010/09/05 17:51

Thanks Julian, do you know where I can post problems regarding khtml2png2 ?

Julian Knauer, 2010/09/05 18:00

I would try the developers support forum. All information you need can be found here http://khtml2png.sourceforge.net/index.php?page=support

Good luck!

link of london, 2010/10/14 05:41

Thanks for your great plugin which nicely complements my Blog and Discussion plugins. May I invite you as a project member for my plugins?

Stephen, 2010/12/21 00:25

OK I have installed and corrected permissions to the best of my lacking ability… I can simply not get it to create a file, it throws no errors that I can find it just simply does not create a file…

-bash-3.2$ khtmld -K /usr/local/bin/khtml2png2 -c /etc/khtmldrc khtmld(aemon) version: 0.3.8 (build date: Dec 20 2010 - 10:41:04) Starting khtmld in forground… Using khtml2png at location `/usr/local/bin/khtml2png2'. Using spool `/tmp/khtmldspool' for input processing. Using pidfile `/tmp/khtmld.pid'. Use khtml2png with uid `48'. Fork timeout set to: `60' Opening fifo `/tmp/khtmldspool' and waiting for input… DONE Opening fifo `/tmp/khtmldspool' and waiting for input… DONE Opening fifo `/tmp/khtmldspool' and waiting for input… DONE Opening fifo `/tmp/khtmldspool' and waiting for input… DONE Opening fifo `/tmp/khtmldspool' and waiting for input…

In another session:

[root@sj1 screenshots]# echo 'http://www.google.com ./google2.png' >/tmp/khtmldspool [root@sj1 screenshots]# ls cmake3.png cmake.php google.png khtmld-0.3.8 khtmld-0.3.8.tar.gz test.php yahoo.png

Nothing displayed at all, where do I go from here? What am I missing? khtml2png2 works just fine: [root@sj1 screenshots]# ls cmake3.png cmake.php google.png khtmld-0.3.8 khtmld-0.3.8.tar.gz test.php yahoo.png [root@sj1 screenshots]# khtml2png2 http://www.google.com ./goog3.png [root@sj1 screenshots]# ls cmake3.png goog3.png khtmld-0.3.8 test.php cmake.php google.png khtmld-0.3.8.tar.gz yahoo.png [root@sj1 screenshots]#

Any help at all would be much appreciated.

glenn, 2010/12/22 18:28

need help does any know whats wrong? I ran khtmld it says bash: khtmld: command not found

[glenns@localhost khtmld-0.3.8]$ sudo sh ./autogen.sh –prefix=/usr/local Cleaning old khtmld build configuration… Done. Bootstrapping… checking for a BSD-compatible install… /usr/bin/install -c checking whether build environment is sane… yes /bin/sh: /mnt/hgfs/DEV/freepostsite.com/admin/test/khtmld-0.3.8/missing: No such file or directory configure: WARNING: `missing' script is too old or missing checking for gawk… gawk checking whether make sets $(MAKE)… yes checking for gcc… gcc checking for C compiler default output file name… a.out checking whether the C compiler works… yes checking whether we are cross compiling… no checking for suffix of executables… checking for suffix of object files… o checking whether we are using the GNU C compiler… yes checking whether gcc accepts -g… yes checking for gcc option to accept ANSI C… none needed checking for style of include used by make… GNU checking dependency style of gcc… none checking whether ln -s works… no, using cp -p checking for a BSD-compatible install… /usr/bin/install -c checking for an ANSI C-conforming const… yes checking for daemon… yes checking for fork… yes checking for strncpy… yes checking for va_start… no checking for mkfifo… yes checking for kill… yes checking for perror… yes checking for stat… yes checking for getopt_long… yes checking for setsid… yes checking for setreuid… yes checking for getservbyname… yes checking how to run the C preprocessor… gcc -E checking for egrep… grep -E checking for ANSI C header files… yes checking for sys/types.h… yes checking for sys/stat.h… yes checking for stdlib.h… yes checking for string.h… yes checking for memory.h… yes checking for strings.h… yes checking for inttypes.h… yes checking for stdint.h… yes checking for unistd.h… yes checking for string.h… (cached) yes checking getopt.h usability… yes checking getopt.h presence… yes checking for getopt.h… yes checking fcntl.h usability… yes checking fcntl.h presence… yes checking for fcntl.h… yes checking for accept in -lc… yes checking for gethostbyname in -lc… yes checking for accept in -lsocket… no checking for gethostbyname in -lnsl… yes checking for hosts_ctl in -lwrap… yes

  • Debug macros : No.
  • LIBWRAP security: No.

configure: creating ./config.status config.status: creating Makefile config.status: error: cannot find input file: Makefile.in Done.

glenn, 2010/12/22 19:09

solved my own problem login as root and placed khtmld-0.3.8 in usr/share

sudo sh ./autogen.sh –prefix=/usr/local

i still need help

[root@localhost khtmld-0.3.8]# khtmld

bash: khtmld: command not found

Julian Knauer, 2010/12/26 13:08

after autogen you should run

make && make install

And also be sure that /usr/local/bin is in your PATH environment variable

StephenO, 2010/12/28 23:00

Have worked through most of the problems however khmld is now crashing if I use long filenames…

it also seems to take down kde, ( dcopserver –nosid –suicide )

If I restart khtmld it still won't work and fails to * glibc detected * /usr/local/bin/khtmld

Right now my only optin is to restart the server when this happens…

2 Questions for anyone who has encountered the problems. 1. how can I use longer filenames? 2. Once it crashes to this level how can I bring it back up without restarting the server?

Any and all help is appreciated.

StephenO, 2010/12/29 00:37

It's worth noting that the above post is failing when using echo with long filenames:

$cmd = “echo '”.$webpage_url.” screenshots/1234567890.png”' >/tmp/khtmldspool”;

(the above works OK)

$cmd = “echo '”.$webpage_url.” screenshots/123456789012345.png”' >/tmp/khtmldspool”;

(the above crashes)

I'm using PHP to exec the echo. tried the other php solution but could not make it work.

Julian Knauer, 2010/12/29 17:51

How long are the URLs you want to enter? The problem is the buffer size, I also need to add additional length checks!

StephenO, 2010/12/29 19:50

Well the urls themselves could be 50-70 characters, the file names probably no more than 30-40 characters but would be nice to to have a limitation.

The page capture size itself is relatively small (i'm only grabbing 800×600)

StephenO, 2010/12/30 05:26

btw: I used longer urls to capture and it seemed ok, it only fails when I use longer filenames.

Julian Knauer, 2011/01/04 10:21

Looks like a serious flaw in the code! I need to fix that!

Daniel Iser, 2011/01/20 09:36

I was having similar crashing issues most of the time as well as if i did the same url twice. After trying everything i tried downgrading to 0.3.5 and its working like a charm now. not sure whats causeing it.

Julian Knauer, 2011/01/20 14:29

Thanks for the hint with the version. I will compare the changes. I started to implement TCP sockets to communicate with khtmld, I think with this the error sneaked in.

Daniel Iser, 2011/01/20 21:42

I was wondering if it would be possible to add in variable width, height and maybe disables? the FIFO could just be

http://website.com /tmp/website.png 1600 1200 js java

Kinjal, 2011/02/21 07:41

Hello I have requirement of taking screenshot automatically from url. So I have tried khtml2png. It works fine from command line. But in php script I cant able to get the image. Do you know how this happens?

I have read the wikis and found that khtmld is for implementing khtml2png using php script. I have installed khtml2png and khtmld on my server. Can you please guide me how to get image by using these two?I read above mentioned things. But can not getting the clear idea.I have tried all the above things and suggestions but nothing worked for me. Can you please provide me the whole command list as well as script

Enter your comment. Wiki syntax is allowed:
If you can't read the letters on the image, download this .wav file to get them read to you.
 
projects/khtmld.txt · Last modified: 2010/02/09 20:41 by jpk
CC Attribution-Noncommercial-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0