亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Home PHP Libraries Other libraries PHP class to generate thumbnails
PHP class to generate thumbnails
<?php
//功能:生成縮略圖
class CreatMiniature
{
//公共變量
  var $srcFile = ""; //原圖
  var $echoType; //輸出圖片類型,link--不保存為文件;file--保存為文件
  var $im = ""; //臨時變量
  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庫不能使用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


Disclaimer

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

How to Efficiently Generate Thumbnails from Uploaded Images in PHP? How to Efficiently Generate Thumbnails from Uploaded Images in PHP?

07 Nov 2024

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

How to Generate Dynamic XML Content with PHP/Python/etc.? How to Generate Dynamic XML Content with PHP/Python/etc.?

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

How Do I Link Static Libraries That Depend on Other Static Libraries? How Do I Link Static Libraries That Depend on Other Static Libraries?

13 Dec 2024

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

How to Create Proportional Thumbnails in PHP for Large Images? How to Create Proportional Thumbnails in PHP for Large Images?

05 Nov 2024

Creating Scaled Thumbnails in PHPThe provided code snippet successfully crops an image within a given dimension. However, for larger images, it...

How to Get YouTube Video Thumbnails Using PHP and cURL? How to Get YouTube Video Thumbnails Using PHP and cURL?

18 Dec 2024

How to Retrieve YouTube Video Thumbnails using PHP and cURLQuestion:How to retrieve YouTube Video Thumbnails from YouTube API using PHP and cURLQuestion...

How to dynamically generate a C# class at runtime using System.Reflection.Emit? How to dynamically generate a C# class at runtime using System.Reflection.Emit?

30 Jan 2025

How to Dynamically Generate a Class at Runtime?Consider the following scenario: you have a class that represents a set of fields and their...

See all articles