php生成小图_php 生成缩略图代码
php生成小图_php 生成缩略图代码 这是一款经典实用的生成小图的php代码,有专业素语来讲就是php 生成缩略图代码哦。
php教程生成小图_php 生成缩略图代码
这是一款经典实用的生成小图的php代码,有专业素语来讲就是php 生成缩略图代码哦。
*/
# 显示图形及连接
function showdir ($adirectory, $i)
{
global $browsedir;$start = $i;
# 更改 $maxcols 及 $maximages 可改变每一页显示的小图的行数与列数。
$maxcols = 2;
$maximages = 6;
$maximages = $i + ($maximages - 3);# 更改 $imagemaxwidth 及 $imagemaxheight 可改变显示小图的宽度与高度。
$imagemaxwidth = 100;
$imagemaxheight = 100;
# 计算高度与宽度的比例。$imagemaxratio = $imagemaxwidth / $imagemaxheight;
$ndirectory = sizeof ($adirectory);
echo (table_start);
for ($i; $i {
echo (row_start);
for ($icols=1; $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 {
$imageoutputheight = $imagemaxheight;
$imageoutputwidth = ceil ($imagemaxheight/$imageheight*$imagewidth);
} else
{
$imageoutputwidth = $imagemaxwidth;
$imageoutputheight = $imagemaxheight;
}# 显示图形
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
if ($pg == $img_num) {
echo "# 建立其他页次的连接, 每页显示四张图, 故页数 $pg_num 每加 1 , $img_num 就加 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 {
$compare = stristr ($entry, $extensions[$i]);
if (strlen($compare) == strlen($extensions[$i]))
{
$adirectory[++$idirectory] = $entry;
break;
}
}
}
$directory->close();
return $adirectory;
}#主程序
#变量 $browsedir 为图形文件放置的位置。
$browsedir="./images";
# 允许浏览的图形文件扩展名, 放置於数组中, 可自行增加。
$extensions[1] = "jpeg";
$extensions[2] = "jpg";
$extensions[3] = "gif";
$extensions[4] = "png";
showdir (dirtoarray ($browsedir, $extensions), $start);define ("line_break", "
");
define ("table_start", "n");
n");
define ("table_end", "
define ("row_start", "n"); n");
define ("row_end", "
define ("col_start", "n "); n");
define ("col_end", "n
define ("img_start", "");
define ("img_width", " width=");
define ("img_height", " height=");
define ("a_start", '');
define ("a_end", "");
?>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Validator can be created by adding the following two lines in the controller.

Logging in CakePHP is a very easy task. You just have to use one function. You can log errors, exceptions, user activities, action taken by users, for any background process like cronjob. Logging data in CakePHP is easy. The log() function is provide

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

CakePHP is an open source MVC framework. It makes developing, deploying and maintaining applications much easier. CakePHP has a number of libraries to reduce the overload of most common tasks.
