webpage as image
Moderator: General Moderators
webpage as image
hi,
is there anyway i can display a website as a thumbnail by pointing to it.
so for example
http://www.google.com
will show me a small thumbnail of there homepage as a gif or jpeg
is there anyway i can display a website as a thumbnail by pointing to it.
so for example
http://www.google.com
will show me a small thumbnail of there homepage as a gif or jpeg
- MrPotatoes
- Forum Regular
- Posts: 617
- Joined: Wed May 24, 2006 6:42 am
I'm afraid it isn't possible in php. Unless you exec a program on the server that would do it. ( http://www.php.net/exec )
Try this:
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Preview </TITLE>
<SCRIPT language="JavaScript" type="text/javascript">
function ShowPreview(id)
{
var divElement = document.all.item(id);
divElement.style.display = "block";
}
function HidePreview(id)
{
var divElement = document.all.item(id);
divElement.style.display = "none";
}
</SCRIPT>
</HEAD>
<BODY>
<a href="http://www.google.com" onmouseover="ShowPreview('wwwdotgoogledotcom');" onmouseout="HidePreview('wwwdotgoogledotcom');">www.google.com</a>
<div id="wwwdotgoogledotcom" style="display: none; font-size: 80%;">
<iframe src="http://www.google.com" width="200" height="200" scrolling="no"></iframe>
</div>
</BODY>
</HTML>- ambivalent
- Forum Contributor
- Posts: 173
- Joined: Thu Apr 14, 2005 8:58 pm
- Location: Toronto, ON
After a long long long long long .... research i found the necessary softwares for converting HTML to Image!!!!!!!
1. Download and copy to the server root: http://www.tufat.com/script19.htm.
2. Download and install: http://www.imagemagick.org/www/binary-r ... ml#windows (there is also unix release).
3. Check that you can use exec().
4. Use this code to convert HTML to Image:
Run this script and Enjoy!
P.S
Additional links:
1. Download and copy to the server root: http://www.tufat.com/script19.htm.
2. Download and install: http://www.imagemagick.org/www/binary-r ... ml#windows (there is also unix release).
3. Check that you can use exec().
4. Use this code to convert HTML to Image:
Code: Select all
<?php
$docroot = "C:\\Program_Files\\Apache Group\\Apache2\\htdocs\\";
$html2ps_dir = "html2ps";
$site = "http://www.google.com";
$handle = fopen("http://localhost/".$html2ps_dir."/html2ps.php?process_mode=single&URL=".$site."&pixels=640&scalepoints=1&renderimages=1
&renderlinks=1&renderfields=1&media=Letter&cssmedia=screen&leftmargin=30&rightmargin=15&topmargin=15&bottommargin=15
&encoding=&method=fpdf&pdfversion=1.3&output=2", "r");
while(!feof($handle))
{
$content .= fread($handle, 4096);
}
fclose($handle);
$pos = strrpos($content, "/");
if($pos === FALSE)
{
die("Problem");
}else{
$filename = substr($content, $pos+1, strlen($content)-1);
}
echo $filename;
exec('C:\Program_Files\ImageMagick-6.2.8-Q16\convert.exe "".$docroot.$html2ps_dir."\out\\'.$filename.'" "".$docroot."sample.jpeg"');
?>P.S
Additional links:
I ran this script and got errors. heres my script after installing and verifying imagemagick works properly
The error i get is
Code: Select all
<?php
$docroot = "C:\\myfolder\\";
$html2ps_dir = "html2ps_v194";
$site = "http://www.google.com";
$handle = fopen("http://localhost/".$html2ps_dir."/html2ps.php?process_mode=single&URL=".$site."&pixels=640&scalepoints=1&renderimages=1
&renderlinks=1&renderfields=1&media=Letter&cssmedia=screen&leftmargin=30&rightmargin=15&topmargin=15&bottommargin=15
&encoding=&method=fpdf&pdfversion=1.3&output=2", "r");
while(!feof($handle))
{
$content .= fread($handle, 4096);
}
fclose($handle);
$pos = strrpos($content, "/");
if($pos === FALSE)
{
die("Problem");
}else{
$filename = substr($content, $pos+1, strlen($content)-1);
}
echo $filename;
exec('C:\Program_Files\ImageMagick-6.2.8-Q16\convert.exe "".$docroot.$html2ps_dir."\out\\'.$filename.'" "".$docroot."sample.jpeg"');
?>Code: Select all
Warning: fopen(http://localhost/html2ps_v194/html2ps.php?process_mode=single&URL=http://www.google.com&pixels=640&scalepoints=1&renderimages=1 &renderlinks=1&renderfields=1&media=Letter&cssmedia=screen&leftmargin=30&rightmargin=15&topmargin=15&bottommargin=15 &encoding=&method=fpdf&pdfversion=1.3&output=2) [function.fopen]: failed to create stream: HTTP request failed! HTTP/1.1 400 Bad Request in c:\inetpub\wwwroot\imagemagic.php on line 15
Warning: feof(): supplied argument is not a valid stream resource in c:\inetpub\wwwroot\imagemagic.php on line 16
Warning: fread(): supplied argument is not a valid stream resource in c:\inetpub\wwwroot\imagemagic.php on line 18
Notice: Undefined variable: content in c:\inetpub\wwwroot\imagemagic.php on line 18
Warning: feof(): supplied argument is not a valid stream resource in c:\inetpub\wwwroot\imagemagic.php on line 16
Warning: fread(): supplied argument is not a valid stream resource in c:\inetpub\wwwroot\imagemagic.php on line 18
Warning: feof(): supplied argument is not a valid stream resource in c:\inetpub\wwwroot\imagemagic.php on line 16
Warning: fread(): supplied argument is not a valid stream resource in c:\inetpub\wwwroot\imagemagic.php on line 18
Warning: feof(): supplied argument is not a valid stream resource in c:\inetpub\wwwroot\imagemagic.php on line 16
Warning: fread(): supplied argument is not a valid stream resource in c:\inetpub\wwwroot\imagemagic.php on line 18
Warning: feof(): supplied argument is not a valid stream resource in c:\inetpub\wwwroot\imagemagic.php on line 16
Warning: fread(): supplied argument is not a valid stream resource in c:\inetpub\wwwroot\imagemagic.php on line 18