当前位置:网站首页>PHP image upload
PHP image upload
2022-07-28 16:27:00 【Sun Fendou】
Picture upload class
<?php
/** Image compression operation class v1.0 */
class Image{
private $src;
private $imageinfo;
private $image;
public $percent = 0.1;
public function __construct($src=''){
$this->src = $src;
}
/** Open the picture */
public function openImage($src=''){
if (!empty($src)) {
$this->src = $src;
}
list($width, $height, $type, $attr) = getimagesize($this->src);
$this->imageinfo = array(
'width'=>$width,
'height'=>$height,
'type'=>image_type_to_extension($type,false),
'attr'=>$attr
);
$fun = "imagecreatefrom".$this->imageinfo['type'];
$this->image = $fun($this->src);
}
/** Operation picture */
public function thumpImage(){
$new_width = $this->imageinfo['width'] * $this->percent;
$new_height = $this->imageinfo['height'] * $this->percent;
$image_thump = imagecreatetruecolor($new_width,$new_height);
// Copy the original image onto the image carrier , And compressed in proportion , Great clarity
imagecopyresampled($image_thump,$this->image,0,0,0,0,$new_width,$new_height,$this->imageinfo['width'],$this->imageinfo['height']);
imagedestroy($this->image);
$this->image = $image_thump;
}
/** Output pictures */
public function showImage(){
header('Content-Type: image/'.$this->imageinfo['type']);
$funcs = "image".$this->imageinfo['type'];
$funcs($this->image);
}
/** Save pictures to hard disk */
public function saveImage($name){
$funcs = "image".$this->imageinfo['type'];
// $funcs($this->image,$name.'.'.$this->imageinfo['type']);
$funcs($this->image,$name);
}
/** Destroy picture */
public function __destruct(){
imagedestroy($this->image);
}
}
边栏推荐
- c语言编程当中两个!!的作用
- LwIP development | socket | DNS domain name resolution
- Roson的Qt之旅#101 Qt Quick中的模型和视图
- Let's learn the game of beating hamsters
- Record doc
- 视频号找到金钥匙,抖音模仿后来人
- 李宏毅《机器学习》丨4. Deep Learning(深度学习)
- Is MySQL query limit 1000,10 as fast as limit 10? If I want to page, what should I do?
- Automatically pack compressed backup download and delete bat script commands
- 软考 系统架构设计师 简明教程 | 软件调试
猜你喜欢

Why do most people who learn programming go to Shenzhen and Beijing?

Thoughts on solving the pop-up of malicious computer advertisements

Installation points and precautions of split angle probe

JS priority queue

视频号找到金钥匙,抖音模仿后来人

Wei Jianjun couldn't catch up with Li Shufu by riding a BMW

Instructions for mictr01 Tester development kit (vibrating wire acquisition reader)

Redis series 4: sentinel (sentinel mode) with high availability

LabVIEW Linx toolkit controls Arduino equipment (expansion-1)

flashfxp 530 User cannot log in. ftp
随机推荐
Qt学习之信号和槽机制
关于标准IO缓冲区的问题
QT QString详解
Summary of for loop in JS
LabVIEW LINX Toolkit控制Arduino设备(拓展篇—1)
Dynamic programming -- digital statistics DP
R语言使用GGally包的ggpairs函数可视化分组多变量的两两关系图、设置alpha参数改变图像透明度、对角线上连续变量密度图、离散变量条形图、两两关系图中包含散点图、直方图、箱图以及相关性数值
Qt学习第一天
Detailed explanation of QT qstring
STM32F103C8T6 + 0.96“ I2C OLED显示3D_Cube
R语言ggplot2可视化绘制线图(line plot)、使用gghighlight包突出高亮线图中满足组合判断条件的线图(satisfies both condition A and B)
R language uses file of FS package_ Delete function deletes the specified file under the specified folder, draw inferences from one instance, dir_ Delete function, link_ The delete function can be use
使用js直传oss阿里云存储文件,解决大文件上传服务器限制
Thoughts on solving the pop-up of malicious computer advertisements
leetcode 题目
Darknet training yolov4 record
SCI scientific paper writing Growth Camp (full version)
JS array (summary)
Food safety | these two kinds of melons and fruits should be improved, especially for pregnant women with constipation
JS linked list 02