当前位置:网站首页>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);
}
}
边栏推荐
- Implementation of skip table
- Instructions for mictr01 Tester development kit (vibrating wire acquisition reader)
- Fifth uncle's thinking
- 带你来浅聊一下!单商户功能模块汇总
- R language ggplot2 visually draws line plots, and uses gghighlight package to highlight the lines that meet the combination judgment conditions in the line graphs (satisfies both condition a and b)
- Leetcode topic
- Ffmpeg get the first frame
- 头条文章_signature
- curl无输出返回空白或者null问题解决
- Numpy ndarray learning < I > Foundation
猜你喜欢

500million users, four years earlier than wechat... This app, which has been in operation for 15 years, will be permanently discontinued

Practical development tutorial of software problem repair tracking system (Part 1)

mysql 查看事件状态语句和修改办法

Thoughts on solving the pop-up of malicious computer advertisements

High precision absolute angle sensor application high speed angle monitoring

Installation points and precautions of split angle probe

laravel

IT远程运维是什么意思?远程运维软件哪个好?

小程序中的分页查询

Two special functions (arrow function and method)
随机推荐
R language uses ggpairs function of ggally package to visualize pairwise relationship graph of grouping multivariable, set alpha parameter to change image transparency, diagonal continuous variable de
SCI scientific paper writing Growth Camp (full version)
Connection and application of portable borehole inclinometer data acquisition instrument and inclinometer probe
2021 Kent interview question 1
PHP图片合成技术
关于web对接针式打印机问题,Lodop使用
SDL2 简明教程(四):用 SDL_IMAGE 库导入图片
JS linked list 01
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
8051 series MCU firmware upgrade IAP
Ethernet to RS485 serial port counter WiFi module LED light controller ibf165
Mlx90640 infrared thermal imager temperature sensor module development notes (VIII)
Qt学习之信号和槽机制
百度编辑器ueditor,编辑内容过多时,工具栏不可见,不方便编辑或上传问题
视频号找到金钥匙,抖音模仿后来人
一大早支付宝来短信说你中“奖”了?处理服务器挖矿病毒 - kthreaddi
QT packaging
为什么学编程的人大多数都去了深圳和北京?
Brief tutorial for soft exam system architecture designer | software debugging
资本「断供」两年,我只能把公司卖了