2012-12-07 87 views
1

我嘗試使用Snappyhttp://www.codediesel.com/downloads/snappy SRC)的URL獲取網站形象的Windows 7上獲得來自URL每次我

error: The image cannot be display as it contains errors

代碼時間的圖像,但:

<?php 
require_once('Snappy/Media.php'); 
require_once('Snappy/Image.php'); 

/* 'wkhtmltoimage' executable is located in the current directory */ 
$snap = new Image('C://"Program Files"/wkhtmltopdf/wkhtmltopdf.exe'); 

/* Displays the bbc.com website index page screen-shot in the browser */ 
header("Content-Type: image/jpeg"); 
$snap->output('http://www.bbc.com bbc.jpg'); 
?> 
+0

運行,無需將影像/ JPEG頭的代碼(「內容類型:..」)設置,看看你得到任何合理的錯誤消息在您的輸出中。 – MatsLindh

回答

0

我不知道你使用的是什麼,但http://www.artviper.net/website-tools/website-thumbnails.php有一個不錯的網站。你甚至可以簡單地定製他們的鏈接來顯示任何網站。加載雖然需要一段時間。所以我建議將它們保存在本地

您甚至可以自定義輸出寬度和瀏覽器寬度/高度。

簡單的示例代碼,保存到本地,並顯示圖像:

<?php 
$site = $_POST['site']; 
if (strlen($site)==0) 
    $site = "www.stackoverflow.com"; 

$url = "http://85.25.9.83/artviper.php?w=360&sdx=1024&q=90&userID=AV_47845683_352324_2FC&url=".urlencode($site); 
$content = implode('', file($url)); 
file_put_contents("myimage.jpg", $content); 
?> 

<form method="POST"> 
<input type="text" name='site' value='<?php echo $site; ?>'/> 
<input type="submit" value="Show image" /> 
</form> 

<img src='myimage.jpg' />