PHP generate small figure _php generated thumbnail code This is a classic utility to generate a small map of the PHP code, there is a professional language is the PHP generated thumbnail code OH.
PHP tutorials Generate thumbnails _php generate thumbnail code
This is a classic and useful to generate a small map of the PHP code, there is a professional language in terms of PHP generated thumbnail code OH.
*/
# Display graphics and connections
function Showdir ($adirectory, $i)
{
Global $browsedir;
$start = $i;
# change $maxcols and $maximages to change the number of rows and columns of small graphs displayed on each page.
$maxcols = 2;
$maximages = 6;
$maximages = $i + ($maximages-3);
# change $imagemaxwidth and $imagemaxheight to change the width and height of the display thumbnail.
$imagemaxwidth = 100;
$imagemaxheight = 100;
# calculates the ratio of height to width.
$imagemaxratio = $imagemaxwidth/$imagemaxheight;
$ndirectory = sizeof ($adirectory);
Echo (Table_start);
for ($i; $i <= $maximages;)
{
Echo (Row_start);
for ($icols =1; $icols <= $maxcols; $icols + +)
{
Echo (Col_start);
$imagefilename = $adirectory [+ + $i];
if (strlen ($imagefilename) >0)
{
$imagepath = $browsedir. " /". $imagefilename;
$imagesize = getimagesize ($imagepath);
if ($imagesize)
{
$imagewidth = $imagesize [0];
$imageheight = $imagesize [1];
$imageratio = $imagewidth/$imageheight;
if ($imageratio > $imagemaxratio)
{
$imageoutputwidth = $imagemaxwidth;
$imageoutputheight = Ceil ($imagemaxwidth/$imagewidth * $imageheight);
}
else if ($imageratio < $imagemaxratio)
{
$imageoutputheight = $imagemaxheight;
$imageoutputwidth = Ceil ($imagemaxheight/$imageheight * $imagewidth);
} else
{
$imageoutputwidth = $imagemaxwidth;
$imageoutputheight = $imagemaxheight;
}
# Display Graphics
Echo (A_start. $imagepath. A_close);
Echo (Img_start. $imagepath. Img_width $imageoutputwidth. Img_height. $imageoutputheight. Img_end);
Echo (line_break. $adirectory [$i]);
Echo (A_end);
}
Echo (Col_end);
}
}
Echo (Row_end);
}
Echo (Table_end);
Pagemenu ($browsedir, $ndirectory, $start);
}
function Pagemenu ($browsedir, $ndirectory, $PG) {
echo "
Page: ";
$PG _num = 1;
for ($img _num = 0; $img _num <= $ndirectory;) {
if ($pg = = $img _num) {
echo " * $pg _num ";
} else {
echo " $pg _num ";
}
# set up other pages of the connection, each page shows four pictures, so the number of pages $pg _num per plus 1, $img _num add 4.
$PG _num = $pg _num + 1;
$img _num = $img _num + 4;
}
echo "n";
}
function Dirtoarray ($browsedir, $extensions)
{
$nextensions = sizeof ($extensions);
$idirectory = 0;
$directory = Dir ($browsedir);
while ($entry = $directory->read ())
{
for ($i =1; $i <= $nextensions; $i + +)
{
$compare = Stristr ($entry, $extensions [$i]);
if (strlen ($compare) = = strlen ($extensions [$i]))
{
$adirectory [+ + $idirectory] = $entry;
Break
}
}
}
$directory->close ();
return $adirectory;
}
#主程序
#变量 $browsedir Placement for the drawing file.
$browsedir = "./images";
# allowed to browse the graphics file extension, placed in the array, can be added by itself.
$extensions [1] = "JPEG";
$extensions [2] = "JPG";
$extensions [3] = "gif";
$extensions [4] = "PNG";
Showdir (Dirtoarray ($browsedir, $extensions), $start);
Define ("Line_break", "
");
Define ("Table_start", "
n "); Define ("Table_end", "
n ");
Define ("Row_start", "n ");
Define ("Row_end", "n ");
Define ("Col_start", "n ");
Define ("Col_end", "Nn ");
Define ("Img_start", "define" ("Img_end", ">");
Define ("Img_width", "width=");
Define ("Img_height", "height=");
Define ("A_start", "define" ("A_close", ">");
Define ("A_end", "" ");
?>
http://www.bkjia.com/PHPjc/633031.html www.bkjia.com true http://www.bkjia.com/PHPjc/633031.html techarticle php generate small figure _php generated thumbnail code This is a classic utility to generate a small map of the PHP code, there is a professional language is the PHP generated thumbnail code OH. PHP tutorial to generate a small figure _php ...