PHP generate thumbnails _php generate thumbnail code _php tutorial

Source: Internet
Author: User
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 ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.