Thump. php :? Phpinclude_once (extra. php); $ pathassets; $ new_E: webrootblogtestassets \; define (END, n); define (TUD, $ dir); functionthumb ($ source, $ new_height) {list ($ im_width, $ im_height, $ type) getimage
Thump. php :? Php shortde_once ('extra. php '); $ path = 'Assets/'; $ new_height = 800; $ dir = 'e: \ webroot \ blog \ test \ assets \\'; define ("END", "\ n"); define ("TUD", $ dir); function thumb ($ source, $ new_height) {list ($ im_width, $ im_height, $ type) = getimage
Thump. php:
Include_once ('extra. php ');
$ Path = 'Assets /';
$ New_height = 800;
$ Dir = 'e: \ webroot \ blog \ test \ assets \\';
Define ("END", "\ n ");
Define ("TUD", $ dir );
Function thumb ($ source, $ new_height)
{
List ($ im_width, $ im_height, $ type) = getimagesize ($ source );
/* $ File = explode ('/', $ source );
$ File = array_pop ($ file );*/
$ File = basename ($ source );
Echo $ file;
If (! Is_writable ($ source )){
Trigger_error ('dir can \'t be write ');
// Touch ('thumb ');
}
$ New_width = $ im_width * $ new_height/$ im_height;
$ New_width = sprintf ('% d', round ($ new_width ));
Echo $ new_width;
$ Im = ImageCreatefromJpeg ($ source );
If (! $ Im)
Throw new Exception ('unable to read image file ');
$ Thumb = ImageCreateTrueColor ($ new_width, $ new_height );
ImageCopyResampled ($ thumb, $ im, 0, 0, 0, 0, $ new_width, $ new_height, $ im_width, $ im_height );
If (! Imagejpeg ($ thumb, 'thumb/'. $ file ))
Throw new Exception ('thumbnail failed ');
Imagedestroy ($ im );
Imagedestroy ($ thumb );
Unlink (TUD. $ file );
// Echo TUD. $ file. 'done ';
}
$ Data = enterDir (TUD );
// Print_r ($ data );
Foreach ($ data as $ v)
// Echo $ v;
Thumb (TUD. $ v, $ new_height );
/* $ Handle = opendir ('thumb /');
While (false! ==( $ File = readdir ($ handle ))){
$ Source = "thumb/". $ file;
Echo "$ file
";
}*/
?>
Extra. php:
Function enterDir ($ path)
{
If ($ handle = opendir ($ path )){
$ Data = array ();
While (false! ==( $ F = readdir ($ handle ))){
$ Ep = array ('.','..');
// $ Ext = substr ($ f,-3, 3 );
If (in_array ($ f, $ ep ))
Continue;
// If (filesize ($ path. $ f) <300)
// If (substr ($ f, 0, 3 )! = '000' | substr ($ f, 0, 3 )! = '000000 ')
// Continue;
$ Data [] = $ f;
}
/* $ Result = implode ("\ t \ n", $ data );
Echo $ result ;*/
Closedir ($ handle );
Return $ data;
}
}
$ Data = enterDir ('e: \ webroot \ blog \ test \ assets \\');
Print_r ($ data );
Foreach ($ data as $ k => $ v ){
$ Title = substr ($ v, 0,-4 );
$ Data [$ k] =' ';
// Echo $ v;
}
$ Data = implode ("\ r \ n", $ data );
Echo $ data;
/* Function ()
{
}
*/