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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
| <?php
// global parameters
$thumb_small_width = 140; // small image width
$thumb_small_height = 100; // small image height
$thumb_big_width = 400; // large image width
$thumb_big_height = 400; // large image height
$jpeg_quality = 100; // image quality for jpeg
// main routine
if ( ( $argc >= 2 && in_array($argv[1], array('--help', '-help', '-h', '-?')))
|| ( $argc < 3 ) ) {
// show help
echo $argv[0];
echo
' --help
usage
php autothumb.php URL OUTPUT-FileName
parameters
URL : URL Name ex) http://www.yahoo.co.jp
OUTPUT-FileName : OUTPUT Image FileName ex) C:\temp\yahoo.jpg
';
} else {
// check parameters
$urlname = $argv[1]; // URL Name
$filename = $argv[2]; // Output Image File Name
$error_f = 0;
$prm_error = '';
if(!empty($urlname)){
if(stripos($urlname,'http')==0){
// ok
} else {
$prm_error = "You should set protocol-name('ex)http://') before URL address.\n";
$error_f++;
}
} else {
$prm_error = "You should set URL Name.\n";
$error_f++;
}
// check extension type
$extension_type = -1;
$extension_char = '';
if(strrpos($filename,'.')!==false){
$extfile = strtolower(substr($filename,strrpos($filename,'.')));
if( $extfile == ".jpeg" || $extfile == ".jpg" ){
$extension_type = 1;
$extension_char = '.jpg';
} else if( $extfile==".png" ){
$extension_type = 2;
$extension_char = '.png';
} else if( $extfile==".gif" ){
$extension_type = 3;
$extension_char = '.gif';
}
}
switch($extension_type){
case 0:
$prm_error = "*** Warning ***\n";
$prm_error = "You should set extension-name('ex) .jpg') after OUTPUT-FileName.\n";
$prm_error .= "But this program automated addition function will set extension-name (.jpg).\n";
$filename .= '.jpg';
$extension_type = 1;
$extension_char = '.jpg';
break;
case -1:
$prm_error = "You should set OUTPUT-FileName(Image File Name).\n";
$error_f++;
break;
default:
// none
break;
}
echo $prm_error;
if($error_f==0){
echo "[start]URL=$urlname FILE=$filename\n";
// set image file names.
$cached_filename = $filename . '.org.png';
$cached_filename_S = $filename . '.s' . $extension_char;
$cached_filename_L = $filename;
// remove image files
if(file_exists($cached_filename)){
unlink ($cached_filename);
}
if(file_exists($cached_filename_S)){
unlink ($cached_filename_S);
}
if(file_exists($cached_filename_L)){
unlink ($cached_filename_L);
}
// Get website image and save it on the server.
@exec('CutyCapt.exe ' . escapeshellarg('--url='.$urlname) . ' ' . escapeshellarg('--out='.$cached_filename));
if (!file_exists($cached_filename)) {
echo $filename." Web Page Image Hard Copy NG. The Image File was not created.\n";
} else {
if(!file_exists($cached_filename_S)){
// get original image file attribute
list($orig_x, $orig_y, $orig_img_type, $img_sizes) = GetImageSize($cached_filename);
// Create a new image from file or URL
$org_image = ImageCreateFromPng($cached_filename);
// org file height
$orig_y_S = ($orig_x/$thumb_small_width) * $thumb_small_height;
if($orig_y_S>$orig_y){
$thumb_small_height = $thumb_small_height * ($orig_y/$orig_y_S);
$orig_y_S = $orig_y;
}
$orig_y_L = ($orig_x/$thumb_big_width) * $thumb_big_height;
if($orig_y_S>$orig_y){
$thumb_big_height = $thumb_big_height * ($orig_y/$orig_y_L);
$orig_y_L = $orig_y;
}
// Create a new true color image
$new_image = ImageCreateTrueColor($thumb_small_width,$thumb_small_height);
$new_image_L = ImageCreateTrueColor($thumb_big_width, $thumb_big_height );
// Copy and resize part of an image with resampling
imagecopyresampled(
$new_image, // Destination image link resource.
$org_image, // Source image link resource.
0, 0, // destination point.(x,y)
0, 0, // source point.(x,y)
$thumb_small_width, $thumb_small_height, // Destination (width,height).
$orig_x, $orig_y_S); // Source (width,height)
imagecopyresampled(
$new_image_L, // Destination image link resource.
$org_image, // Source image link resource.
0, 0, // destination point.(x,y)
0, 0, // source point.(x,y)
$thumb_big_width, $thumb_big_height, // Destination (width,height).
$orig_x, $orig_y_L); // Source (width,height)
// image file save
switch($extension_type){
case 2: // png
$res = ImagePNG($new_image, $cached_filename_S);
$res = ImagePNG($new_image_L,$cached_filename_L);
break;
case 3: // gif
$res = ImageGIF($new_image, $cached_filename_S);
$res = ImageGIF($new_image_L,$cached_filename_L);
break;
default: // 1 or else jpeg
$res = ImageJPEG($new_image, $cached_filename_S,$jpeg_quality);
$res = ImageJPEG($new_image_L,$cached_filename_L,$jpeg_quality);
break;
}
}
}
echo "[end]URL=$urlname FILE=$filename\n";
}
}
?>
|
2011年06月11日 @ 20:25:05
I want to know that is CutyCapt capable create thumbnails in Linux based server or not?
2011年06月12日 @ 04:08:37
Yes , you can do it if you have environment of Desktop and Qt development on Linux.
This software might be used on Linux rather than Windows.
2011年06月20日 @ 10:35:00
The English on this page is very hard to understand.
2011年06月23日 @ 16:54:45
I edited this English page.
still hard ?
2011年08月12日 @ 04:59:48
the english is fine! thanks for the effort and details!
2011年08月12日 @ 09:47:47
This is Admin.
Thanks.
2012年04月09日 @ 19:12:44
I have configured CutyCapt.exe on my server and this is working for all http:// request url;
But when i try to capture any https://url to capture image this gives me a blank image after long time processing.
Please can you help me.
Thanks!!
2012年08月16日 @ 03:05:53
I realize this post is over a year old, but I wanted to leave a note for the creator saying ‘THANK YOU’! This has helped me tremendously!!!!