PHP online picture cutting program code_PHP tutorial
php教程 在线切图程序代码
<script><br>var mode = 1;<br>var inout = toubai = 0;<br>var img, imgurl = '', imgdata = '';<br>var p = '';<br>var xydir = 15;<br>var startangle=0, endangle=(math.pi/180)*270;<br>var m;<br>var win, wsp, canvas, c, canvastemp, ctemp, shapes;<br>var w,h,f;<br>var isshift = 0;<br>var shape = 0;<br>var theobject = null; <br>var dx, dy, dw, dh;<br>var des = '';<br>var iface = { dragging:false, resizing:false, status:null, xy:null, txy:null }<br>var anyt = 1;</p> <p>var isie = /msie/i.test(navigator.useragent);<br>var isff = /firefox/i.test(navigator.useragent);</p> <p>window.onload = function() <br>{ <br> win = document.getelementbyid('window');<br> wsp = document.getelementbyid('workspace');</p> <p> img = document.getelementbyid('myimg');<br> canvas = document.getelementbyid('canvas');<br> canvastemp = document.getelementbyid("canvastemp");<br> shapes = document.getelementbyid('shapes');<br> rects = document.getelementbyid('rect');<br> <br> win.style.left = document.body.clientwidth/2-425+'px';<br> if (canvas.getcontext) <br> {<br> c = canvas.getcontext("2d"); <br> c.linewidth = 1;<br> c.strokestyle = '#f00'; <br> c.fillstyle = "rgba(255,255,255,0.3)";<br> c.strokefill = 1;</p> <p> ctemp = canvastemp.getcontext("2d");<br> ctemp.linewidth = 1;<br> ctemp.strokestyle = '#f00'; <br> ctemp.fillstyle = "rgba(255,255,255,0.3)";<br> ctemp.strokefill = 1; <br> <br> var gradientcanvas = document.getelementbyid('gradient');<br> if (gradientcanvas.getcontext) <br> {<br> var g = gradientcanvas.getcontext('2d');<br> var grad = g.createlineargradient(0, 0, 1200, 22); <br> grad.addcolorstop(0, '#036');<br> grad.addcolorstop(1, '#acf');<br> g.fillstyle = grad;<br> g.fillrect(0, 0, 1200, 22);<br> }<br> <br> iface.status = document.getelementbyid('status').firstchild;<br> iface.xy = document.getelementbyid('xy').firstchild;<br> iface.txy = document.getelementbyid('txy').firstchild;<br> <br> document.onmouseup = window.onmouseup = bodyup;<br> document.onmousemove = window.onmousemove = bodymove;<br> document.onkeydown = window.onkeydown = keydown;<br> document.onkeyup = window.onkeyup = keyup;<br> img.onmousedown = canvas.onmousedown = canvastemp.onmousedown = shapes.onmousedown = c_down;<br> img.onmousemove = canvas.onmousemove = canvastemp.onmousemove = shapes.onmousemove = c_move;<br> img.onmouseup = canvas.onmouseup = canvastemp.onmouseup = shapes.onmouseup = c_up;<br> img.onmouseo教程ut = canvas.onmouseout = canvastemp.onmouseout = c_out;<br> }<br> else //不支持canvas属性<br> { <br> alert('不支持canvas'); <br> }</p> <p>}</p> <p>function openimg() <br>{<br> var form = document.upimg;</p> <p> var file = form.ifile.value;<br> var pos = file.lastindexof('.');<br> var ext = file.substring(pos + 1).tolowercase();<br> if (ext != 'jpg' && ext != 'gif' && ext != 'bmp' && ext != 'png')<br> {<br> alert('错误:上传图片必须是 jpg/gif/bmp/png 格式!');<br> return;<br> }<br> form.submit.click();<br> document.getelementbyid('upimg').style.display = 'none';<br>}</p> <p>function upimg(url, size, ww, hh, ff) <br>{ <br> shape = 0;<br> des = '大小:'+size+' 字节 帧数:'+ff+' 帧 宽度:'+ww+' 像素 高度:'+hh+' 像素';<br> iface.status.innerhtml=des;<br> imgurl = url;<br> imgdata = 'imgurl='+imgurl+';';<br> if (ww>800) {w = 800; h = hh/(ww/800);}<br> else {w = ww; h= hh;} <br> f = ff;<br> //img.src = imgurl;<br> document.getelementbyid('myimg').style.display = 'block';<br> document.getelementbyid('myimg').src = imgurl;<br> canvas.style.display='block';<br> canvastemp.style.display='block';<br> canvas.width = canvastemp.width = w;<br> canvas.height = canvastemp.height = h;<br> canvas.style.width = canvastemp.style.width = w+'px';<br> canvas.style.height = canvastemp.style.height = h+'px';<br> c.clearrect(0, 0, canvas.width, canvas.height);<br> ctemp.clearrect(0, 0, canvastemp.width, canvastemp.height);<br> c.strokestyle = '#f00'; <br> c.fillstyle = "rgba(255,255,255,0.3)";<br> ctemp.strokestyle = '#f00'; <br> ctemp.fillstyle = "rgba(255,255,255,0.3)";<br>}</p> <p>function init(t)<br>{<br> if (imgurl == '') {alert('请先上传图片!');return;}<br> else alert("当前版本是演示版!");<br>}<br>function reset()<br>{<br> if (imgurl == '') {alert('请先上传图片!');return;}<br> else alert("当前版本是演示版!");<br>}<br>function clip() <br>{ <br> if (imgurl == '') {alert('请先上传图片!');return;}<br> else alert("当前版本是演示版!");<br>}</p> <p>function hover(o)<br>{<br> o.style.border = "1px solid";<br> o.style.bordercolor = "threedhighlight threeddarkshadow threeddarkshadow threedhighlight";<br>}<br>function hoverout(o)<br>{<br> o.style.border = "0px solid transparent";<br>}</p> <p>function help()<br>{<br> document.getelementbyid('help').style.display='block';<br>}<br>function about()<br>{<br> document.getelementbyid('about').style.display='block';<br>}<br>function wrong(str)<br>{<br> alert(str);<br>}<br></script>
操作说明
【鼠标操作说明】 [1] 鼠标拖动裁剪框可移动裁剪区域的位置,此操作适用于矩形裁剪,圆形裁剪,圆角矩形裁剪,圆弧裁剪。
[2] 鼠标拉拽裁剪框边框可调整裁剪区域的大小,此操作适用于矩形裁剪,圆形裁剪,圆角矩形裁剪,圆弧裁剪。
【键盘操作说明】 [3] 按←↑↓→键可精确移动裁剪区域的位置,此操作适用于矩形裁剪,圆形裁剪,圆角矩形裁剪,圆弧裁剪。
[4] 按jklm键可精确调整裁剪区域的大小,此操作适用于矩形裁剪,圆形裁剪,圆角矩形裁剪,圆弧裁剪。
[5] 按a键减小圆角矩形的圆角角度,按d键增大圆角矩形的圆角角度,此操作适用于圆角矩形裁剪。
[6] 按awsd键可调整圆弧的弧度,此操作适用于圆弧裁剪。
【shift操作说明】 [7] 拉拽鼠标的同时按shift键可按宽与高1:1的比例调整裁剪区域的大小,此操作适用于矩形裁剪,圆形裁剪,圆角矩形裁剪。
upload.php文件
if (stripos($_server[ "http_host"], 'caijian.cc') === false) exit(0);
if ((($_files["ifile"]["type"] == "image/gif")
|| ($_files["ifile"]["type"] == "image/jpeg")
|| ($_files["ifile"]["type"] == "image/pjpeg")
|| ($_files["ifile"]["type"] == "image/bmp")
|| ($_files["ifile"]["type"] == "image/png"))
&& ($_files["ifile"]["size"] < 3000000))
{
if ($_files["ifile"]["error"] > 0)
{
echo "";
}
else
{
$filename = "upload/".date("ymdhis",time()).rand(100,999).substr($_files["ifile"]["name"],strrpos($_files["ifile"]["name"],'.'));
move_uploaded_file($_files["ifile"]["tmp_name"], $filename);
$magick_wand = newmagickwand();
magickreadimage($magick_wand, $filename);
$w = magickgetimagewidth($magick_wand);
$h = magickgetimageheight($magick_wand);
$f = magickgetnumberimages($magick_wand);
echo "";
}
}
else
{
echo "";
}
?>
源码下载地址
http://down.php100.com/php/2011/0311/22879.html

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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

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

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

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

Hot Topics

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

React combines JSX and HTML to improve user experience. 1) JSX embeds HTML to make development more intuitive. 2) The virtual DOM mechanism optimizes performance and reduces DOM operations. 3) Component-based management UI to improve maintainability. 4) State management and event processing enhance interactivity.

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

In PHP8, match expressions are a new control structure that returns different results based on the value of the expression. 1) It is similar to a switch statement, but returns a value instead of an execution statement block. 2) The match expression is strictly compared (===), which improves security. 3) It avoids possible break omissions in switch statements and enhances the simplicity and readability of the code.

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

In PHP, you can effectively prevent CSRF attacks by using unpredictable tokens. Specific methods include: 1. Generate and embed CSRF tokens in the form; 2. Verify the validity of the token when processing the request.
