1.图片上传后立刻判断图片的宽和高是否超过预设的最大高度与宽度,超过了则生成缩略图,
2.图片裁剪使用的是jquery的裁剪插件Jcrop,可以实现裁剪的即时预览,
代码没有优化,会生成很多垃圾图片,欢迎大家一起改进,完善好的请分享!
1. [文件] mytest.zip
2. [图片] QQ截图20130416094207.jpg
3. [代码][PHP]代码
<?php error_reporting(7); date_default_timezone_set("Asia/Shanghai"); header("Content-type:text/html; Charset=utf-8"); require_once("./image.class.php"); $images = new Images("file"); if(isset($_GET['act']) && $_GET['act'] == "upload" ){ $path = $images->move_uploaded(); $images->thumb($path,false,0); //文件比规定的尺寸大则生成缩略图,小则保持原样 if($path == false){ $images->get_errMsg(); }else{ $image = $path; //$res = $images->thumb($image,false,1); if($res == false){ }elseif(is_array($res)){ echo '<img src="'.$res['big'].'" style="margin:10px;">'; echo '<img src="'.$res['small'].'" style="margin:10px;">'; }elseif(is_string($res)){ echo '<img src="'.$res.'">'; } } } if ($_GET['act'] == 'cut'){ $image = $_POST["imgsrc"]; $res = $images->thumb($image,false,1); if($res == false){ echo "裁剪失败"; }elseif(is_array($res)){ echo '<img src="'.$res['big'].'" style="margin:10px;">'; echo '<img src="'.$res['small'].'" style="margin:10px;">'; }elseif(is_string($res)){ echo '<img src="'.$res.'">'; } } ?>
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Assassin's Creed Shadows: Seashell Riddle Solution
3 weeks agoByDDD
What's New in Windows 11 KB5054979 & How to Fix Update Issues
2 weeks agoByDDD
Will R.E.P.O. Have Crossplay?
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Atom editor mac version download
The most popular open source editor

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use