当前位置:网站首页>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);
}
}
边栏推荐
- 2021 Yahong pen test questions
- 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
- Mlx90640 infrared thermal imager temperature sensor module development notes (VIII)
- 微信公众号获取素材列表
- PHP获取小程序码,小程序带参数跳转
- KubeEdge发布云原生边缘计算威胁模型及安全防护技术白皮书
- ANSA二次开发 - 抽中面的两种方法
- QT打包
- Huada chip hc32f4a0 realizes RS485 communication DMA transceiver
- A good start
猜你喜欢

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

c语言编程当中两个!!的作用

flashfxp 530 User cannot log in. ftp

Mlx90640 infrared thermal imager temperature sensor module development notes (VIII)

js中的for循环总结

Zhengda cup hacker marathon data analysis competition

Two of C language programming!! Role of

解决电脑恶意广告弹窗的思路

mysql查询 limit 1000,10 和limit 10 速度一样快吗?如果我要分页,我该怎么办?

Advantages of optical rain gauge over tipping bucket rain gauge
随机推荐
头条文章_signature
2021-10-21 notes
软件问题修复跟踪系统实战开发教程(上篇)
Vm501 development kit development version single vibrating wire sensor acquisition module geotechnical engineering monitoring
QML signal and handler event system
后台弹出layer提示
带你来浅聊一下!单商户功能模块汇总
Practical development tutorial of software problem repair tracking system (Part 1)
Qt学习之安装
LwIP development | socket | TCP | client
解决电脑恶意广告弹窗的思路
兆骑科创创新创业大赛人才引进平台,双创赛事高层次人才引进
500million users, four years earlier than wechat... This app, which has been in operation for 15 years, will be permanently discontinued
The deep displacement monitoring system wk813 is used to measure the deep displacement of slopes, dams, embankments, railways and building foundation pit excavation
curl无输出返回空白或者null问题解决
5 亿用户,比微信还早四年……这个运营了 15 年的 APP 即将永久停服
A good start
I came across Digital Phoenix coordinate Xuhui Meiluo city in Shanghai
mysql 查看事件状态语句和修改办法
Automatically pack compressed backup download and delete bat script commands