<?php //功能:生成縮略圖 class CreatMiniature { //公共變量 var $srcFile = ""; //原圖 var $echoType; //輸出圖片類(lèi)型,link--不保存為文件;file--保存為文件 var $im = ""; //臨時(shí)變量 var $srcW = ""; //原圖寬 var $srcH = ""; //原圖高 //設(shè)置變量及初始化 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庫(kù)不能使用GIF格式的圖片,請(qǐng)使用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: admin@php.cn
Related Article

07 Nov 2024
Creating a Thumbnail from an Uploaded ImageGenerating thumbnails for uploaded images ensures they don't appear distorted while preserving the...

12 Jul 2016
Use the powerful imagick under PHP to easily generate combined thumbnails and imagick thumbnails. Use the powerful imagick to easily generate composite thumbnails under PHP, imagick thumbnails project: blogtarget: use-imagick-to-composite-images-thumbnail.mddate: 2016-02-19status: publishtags: - p

10 Mar 2025
This article explores generating dynamic XML content using PHP and Python. It details methods using string manipulation and XML libraries (DOMDocument/ElementTree), emphasizing best practices for security (input validation, XXE prevention, XSS prote

12 Jul 2016
Analysis and solutions to the reasons why php resizeimage failed to generate thumbnails for some jpg files. php resizeimage partial jpg file analysis and solutions to the reasons for failure to generate thumbnails. Today, when I encountered GD's resizeimage function to process the thumbnail of a jpg suffix file, it prompted that the image is not

13 Dec 2024
Linking Static Libraries to Other Static Libraries: A Comprehensive ApproachStatic libraries provide a convenient mechanism to package reusable...

12 Jul 2016
Summary of the method of generating QR code with logo in php, summary of phplogo. Summary of the method of generating QR code with logo in php, summary of phplogo 1. Class libraries used 1. phpqrcode (php library) 2. qrcode.js (javascript library) 2. Use of phpqrcode Only use php class library, also


Hot Tools

PHP library for dependency injection containers
PHP library for dependency injection containers

A collection of 50 excellent classic PHP algorithms
Classic PHP algorithm, learn excellent ideas and expand your thinking

Small PHP library for optimizing images
Small PHP library for optimizing images
