Dear visitor who can read English
This page is a page translated automatically by Google AJAX Language API.
Please comment to this page if you could not understand. A PERSON will review this page .
I think that you will be able to understand this page later. Please give a little time to us.
Best regards,
This site is support & information site of WEB,and Software. This site might help you that create software or Web Site…perhaps?[:]
I have used software(CutyCapt) in previous post( "How to execute Qt's application ( CutyCapt ) on Windows."), and I will use same software in this post too.
So I will create thumbnail images of some websites by software(CutyCapt) and php programing.
CutyCapt might help you to create hard copy image of some websites, with very easy your operations.(See previous post ).
I will zoom or cut some images that created by CutyCapt in this post, so by PHP programing.
2nd step, Check on the packages needed by PHP for image file.
PHP will require GD package for handling the image file.
You will be able to check if it had installed in your system by the following operation.
Upload the file that include the following PHP code in directory of website.
<?phpecho phpinho();?>
Access to URL that uploaded PHP file.
You will see a similar image of above. It means that your system was installed GD package.
If you have not environment for web server, you will be able to also check by following command.
> php -r "echo phpinfo();"
:
:
:
gd
GD Support => enabled
GD Version => bundled (2.0.34 compatible)
FreeType Support => enabled
FreeType Linkage => with freetype
FreeType Version => 2.1.9
T1Lib Support => enabled
GIF Read Support => enabled
GIF Create Support => enabled
JPG Support => enabled
PNG Support => enabled
WBMP Support => enabled
XBM Support => enabled
* Above information is too many informations. You should print out to a text file, and you will be able to check "GD".
If your system was not installed "GD", you should install by following steps.
If you use Windows OS,
you should re-write 'php.ini'. Just only you will erase comment out code ";" like the following code.
extension=php_gd2.dll
If you use Linux(Red Hat) OS,
you should use 'yum' like following command.
> yum install php-gd
3rd step,Create thumbnail images by PHP.
You will edit programing by PHP for thumbnail images.
Previous step, you should think following function by PHP.
PHP's function will accept the following two parameters.
URL address for website page thumbnail
Output Image file name (the extension of gif, jpeg, png supported )
CutyCapt will create hard copy image of a website page from the inputted URL,
* This original hard copy image file name will be 2nd parameter's "file name" + .org.png .
This file is always PNG format.
Next, PHP function will create two thumbnail images from hard copy file that CutyCapt has created.
Larger image (400 x 400)
Small image (140 x 100)
The original hard copy image will be usually too big. So, "Larger image" will be used for expansion of small image thumbnail.
And 2nd parameter's "file name" of PHP function will be used as file name of "Larger image".
The file name of "Small image" will use 2nd parameter's "file name" + '.s' + expansion.
<?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 routineif(($argc>=2&&in_array($argv[1],array('--help','-help','-h','-?')))||($argc<3)){// show helpecho$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';}elseif($extfile==".png"){$extension_type=2;$extension_char='.png';}elseif($extfile==".gif"){$extension_type=3;$extension_char='.gif';}}switch($extension_type){case0:$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:// nonebreak;}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 filesif(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 attributelist($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 resamplingimagecopyresampled($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 saveswitch($extension_type){case2:// png$res=ImagePNG($new_image,$cached_filename_S);$res=ImagePNG($new_image_L,$cached_filename_L);break;case3:// 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";}}?>
I will give you the following simple description:
Line 3 - 4
Set width and height of Thumbnail image.
Line 6 - 7
Set width and height of Large Thumbnail image.
Line 9
Set quality of JPEG.
Line 45 - 59
Check the image format by the file name extension, and set it.
Line 83 - 85
Set image file names.
Line 88 - 96
If same image file name exist, it will delete it.
Line 99
CutyCapt will execute, and will create image file of the website page.
Line 112 - 121
Adjust height of the image file.
Line 128 - 142
Create a thumbnail image.
Line 145 - 158
Save thumbnail image to files.
You will use like the following.
You should replace URL and the output image file name on the following command.
By this command result, you will get three image files.
yahoo.jpg.org.png -- This original image file is that created by CutyCapt.
yahoo.jpg.s.jpg -- This image file is "Small Image" thumnail file.
yahoo.jpg -- This image file is "Large Image" thumnail file.
You will get easy way for creating thumbnail website page.
So, this thumbnail images might use like sample page view of Google search result pages.
( But you might not like its function of Google... , because the function given too much stress to web server. )
June 11th, 2011 @ 20:25:05
I want to know that is CutyCapt capable create thumbnails in Linux based server or not?
June 12th, 2011 @ 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.
June 20th, 2011 @ 10:35:00
The English on this page is very hard to understand.
June 23rd, 2011 @ 16:54:45
I edited this English page.
still hard ?
August 12th, 2011 @ 04:59:48
the english is fine! thanks for the effort and details!
August 12th, 2011 @ 09:47:47
This is Admin.
Thanks.
April 9th, 2012 @ 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!!
August 16th, 2012 @ 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!!!!