2

Possible Duplicate:
rendering html to png (server-side)

I have a DIV element with some images positioned within the DIV element. I want to make a JPG or a PNG file out of that, so people can save it for their Facebook timeline cover image. I found a LOT of scripts and tutorials, but nothing really fills my needs. This can't really be a very hard thing to do?

I already got my host to install iMagick.

Community
  • 1
  • 1

3 Answers3

1

You should get the positions via JavaScript (I guess you are using js to set the positions of the images in the div) and send them to a PHP-Script. With help of the PHP GD manual you can easily generate a png oder jpeg image.

ᴘᴀɴᴀʏɪᴏᴛɪs
  • 5,854
  • 7
  • 43
  • 71
dislick
  • 627
  • 1
  • 6
  • 23
0

You can try

WKHTMLTOIMAGE

Jürgen Paul
  • 12,371
  • 24
  • 87
  • 129
0

I had to achieve the same thing, only for something else than Facebook and I used webkit2png

I save the HTML code on a temporary HTML file, then I run the python webkit2png command on that temporary HTML file which converts it to PNG. It requires xvfb (apt-get install xvfb)

I then use the following command in PHP:

exec('xvfb-run --server-args="-screen 0, 1024x768x24" python webkit2png.py --log=/tmp/webkit2pnglog.log --output=' .$fullUploadPath . ' ' . $fullPath);

Where $fullUploadPath is the location of the target file and $fullPath is the location of the temporary HTML file.

Kenny
  • 5,232
  • 7
  • 26
  • 42