A lot Information

There are everything from everywhere

Website Thumbnail Generator PHP Script

 

 Requirements:
Windows hosting
PHP GD library (installed on most hostings)
Permissions to execute third-party applications (i.e. exe files)
Permissions to execute Internet Explorer

How it works:
Website Thumbnail Generator checks if it already has website image in the cache, and shows it in the browser.
If no cached image then IECapt would be run from the script.
IECapt would run Internet Explorer, grab full sized website screenshot from it, and save image into the folder you specified in script settings.
Then Website Thumbnail Generator would resize image, and show it in the browser.

Download script here: webthumb

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
###############################################################
# Website Thumbnail Image Generator 1.1
###############################################################
# Visit http://www.zubrag.com/scripts/ for updates
###############################################################
#
# REQUIREMENTS:
# PHP 4.0.6 and GD 2.0.1 or later
# May not work with GIFs if GD2 library installed on your server
# does not support GIF functions in full
#
# Parameters that can be passed via url (if not passed will be used values which are set below):
# url - url of the target website
# x - max width
# y - max height
# q - quality (applicable only to JPG, 1 to 100, 100 - best)
#
# Sample usage:
# 1. webthumb.php?url=http://www.microsoft.com
# 2. Set maximum thumbnail size to 150
#    webthumb.php?url=http://www.thumbnails.com&x=150&y=150
###############################################################
 
// Folder to save all thumbnails.
// Must end with slash!!!
$thumbnails_folder = 'Z:/home/localhost/www/thumb/cache/';
 
// thumbnails expiration time in minutes
$cache_expire_time = 60;
 
// quality (for jpeg only)
$image_quality = 100;
 
// resulting image type (1 = GIF, 2 = JPG, 3 = PNG)
$image_type = 3;
 
// maximum thumb side size
$max_x = 100;
$max_y = 100;
 
// If not equal 0 then cut original image size before resizing (in pixels).
// Long page will have bad thumbnail, its better to cut page length first.
$cut_x = 0;
$cut_y = 1024;
 
###############################################################################
# END OF SETTINGS. DO NOT EDIT BELOW
###############################################################################
 
if (isset($_REQUEST['url'])) {
  $website_url = $_REQUEST['url'];
}
else {
  die("Site URL must be specified.");
}
 
if ($image_type == 1) $output_format = 'gif';
if ($image_type == 2) $output_format = 'jpg';
if ($image_type == 3) $output_format = 'png';
 
$website_url_md5 = md5($website_url);
 
$cached_filename = $thumbnails_folder . $website_url_md5 . '.' . $output_format;
 
// See if we have cached website screenshot image (to minimize server load)
if (!file_exists($cached_filename)
|| filemtime ($cached_filename) + $cache_expire_time * 60 < time() ) {
 
  // Get website image and save it on the server.
  @exec('IECapt.exe ' . escapeshellarg($website_url) . ' ' . escapeshellarg($cached_filename));
 
} // if (!file_exists
 
if (!file_exists($cached_filename)) {
  die("Thumbnail Generation Error. Thumbnail not created.");
}
 
// create class instance
include("image.class.php");
$img = new Zubrag_image;
 
// get parameters
$img->image_type   = $image_type;
$img->quality      = isset($_REQUEST['q']) ? intval($_REQUEST['q']) : $image_quality;
$img->max_x        = isset($_REQUEST['x']) ? intval($_REQUEST['x']) : $max_x;
$img->max_y        = isset($_REQUEST['y']) ? intval($_REQUEST['y']) : $max_y;
$img->save_to_file = false;
$img->cut_x        = $cut_x;
$img->cut_y        = $cut_y;
 
// generate thumbnail and show it
$img->GenerateThumbFile($cached_filename, '');
 
?>
<?php
###############################################################
# Website Thumbnail Image Generator 1.1
###############################################################
# Visit http://www.zubrag.com/scripts/ for updates
###############################################################
#
# REQUIREMENTS:
# PHP 4.0.6 and GD 2.0.1 or later
# May not work with GIFs if GD2 library installed on your server
# does not support GIF functions in full
#
# Parameters that can be passed via url (if not passed will be used values which are set below):
# url - url of the target website
# x - max width
# y - max height
# q - quality (applicable only to JPG, 1 to 100, 100 - best)
#
# Sample usage:
# 1. webthumb.php?url=http://www.microsoft.com
# 2. Set maximum thumbnail size to 150
#    webthumb.php?url=http://www.thumbnails.com&x=150&y=150
###############################################################

// Folder to save all thumbnails.
// Must end with slash!!!
$thumbnails_folder = 'Z:/home/localhost/www/thumb/cache/';

// thumbnails expiration time in minutes
$cache_expire_time = 60;

// quality (for jpeg only)
$image_quality = 100;

// resulting image type (1 = GIF, 2 = JPG, 3 = PNG)
$image_type = 3;

// maximum thumb side size
$max_x = 100;
$max_y = 100;

// If not equal 0 then cut original image size before resizing (in pixels).
// Long page will have bad thumbnail, its better to cut page length first.
$cut_x = 0;
$cut_y = 1024;

###############################################################################
# END OF SETTINGS. DO NOT EDIT BELOW
###############################################################################

if (isset($_REQUEST['url'])) {
  $website_url = $_REQUEST['url'];
}
else {
  die("Site URL must be specified.");
}

if ($image_type == 1) $output_format = 'gif';
if ($image_type == 2) $output_format = 'jpg';
if ($image_type == 3) $output_format = 'png';

$website_url_md5 = md5($website_url);

$cached_filename = $thumbnails_folder . $website_url_md5 . '.' . $output_format;

// See if we have cached website screenshot image (to minimize server load)
if (!file_exists($cached_filename)
|| filemtime ($cached_filename) + $cache_expire_time * 60 < time() ) {

  // Get website image and save it on the server.
  @exec('IECapt.exe ' . escapeshellarg($website_url) . ' ' . escapeshellarg($cached_filename));

} // if (!file_exists

if (!file_exists($cached_filename)) {
  die("Thumbnail Generation Error. Thumbnail not created.");
}

// create class instance
include("image.class.php");
$img = new Zubrag_image;

// get parameters
$img->image_type   = $image_type;
$img->quality      = isset($_REQUEST['q']) ? intval($_REQUEST['q']) : $image_quality;
$img->max_x        = isset($_REQUEST['x']) ? intval($_REQUEST['x']) : $max_x;
$img->max_y        = isset($_REQUEST['y']) ? intval($_REQUEST['y']) : $max_y;
$img->save_to_file = false;
$img->cut_x        = $cut_x;
$img->cut_y        = $cut_y;

// generate thumbnail and show it
$img->GenerateThumbFile($cached_filename, '');

?>

Info from: http://www.zubrag.com

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code lang=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" extra="">