<?php
//功能:生成缩略图
class CreatMiniature
{
//公共变量
var $srcFile = ""; //原图
var $echoType; //输出图片类型,link--不保存为文件;file--保存为文件
var $im = ""; //临时变量
var $srcW = ""; //原图宽
var $srcH = ""; //原图高
//设置变量及初始化
function SetVar($srcFile, $echoType)
{
if (!file_exists($srcFile)) {
echo '源图片文件不存在!';
exit();
}
$this->srcFile = $srcFile;
$this->echoType = $echoType;
$info = "";
$data = GetImageSize($this->srcFile, $info);
switch ($data[2]) {
case 1:
if (!function_exists("imagecreatefromgif")) {
echo "你的GD库不能使用GIF格式的图片,请使用Jpeg或PNG格式!返回";
exit();
}Generate thumbnail function (supports image formats: gif, jpeg, png and bmp)
* @author ruxing.li
* @param string $src Source image path
* @param int $width Thumbnail width (conformal scaling is performed when only the height is specified)
* @param int $width Thumbnail height (conformal scaling is performed when only the width is specified)
* @param string $filename Save path (directly output to the browser if not specified)
* @return bool
All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: [email protected]
PHP uploads images to generate thumbnails (GD library), _PHP tutorial
12 Jul 2016
PHP uploads images to generate thumbnails (GD library). PHP uploads images to generate thumbnails (GD library). First, let’s share a simple detailed code of PHP uploading images to generate thumbnails for your reference. The specific content is as follows phpfunction
How to use timthumb to generate thumbnails in php, timthumb thumbnails_PHP tutorial
12 Jul 2016
PHP uses timthumb to generate thumbnails, timthumb thumbnails. How to use timthumb to generate thumbnails in PHP, timthumb thumbnails This article describes how to use timthumb to generate thumbnails in PHP. Share it with everyone for your reference, the details are as follows: Generate
php resizeimage failed to generate thumbnails for some jpg files, _PHP Tutorial
12 Jul 2016
php resizeimage failed to generate thumbnails for some jpg files. php resizeimage failed to generate thumbnails for some jpg files. Today, when I encountered GD's resizeimage function to process the thumbnails of jpg suffix files, it prompted that the image was not a legal jpg image and reported an error.
PHP implements image uploading and uses ImageMagick to generate thumbnails, _PHP tutorial
12 Jul 2016
PHP implements image uploading and uses ImageMagick to generate thumbnails. PHP implements image uploading and uses ImageMagick to generate thumbnails. Using ImageMagick, you can create thumbnails easily and faster, much easier than using PHP. php// Location to upload
How to define database table structure through class attributes and dynamically generate SQL tables in PHP
12 Feb 2026
This article introduces a safe and maintainable PHP database table creation solution: abandon the unreliable way of extracting fields from internal variables of methods, and instead use explicitly declared class attributes ($table and $columns) in conjunction with base class inheritance to implement framework-level table structure definition and automated table creation logic.
How to enable Pico.css on demand in a project without polluting styles globally
09 Feb 2026
Pico.css has provided the pico.conditional.min.css version since v2, which only takes effect on elements with class="pico" added, completely solving the problem of style conflicts with other UI libraries.
Popular tool
A collection of 50 excellent classic PHP algorithms
Classic PHP algorithm, learn excellent ideas and expand your thinking
PHP library for dependency injection containers
PHP library for dependency injection containers
Small PHP library for optimizing images
Small PHP library for optimizing images




