国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

198 lines
6.4KB

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $cfg_soft_lang; ?>">
  5. <title>图片裁剪 Image Cropper</title>
  6. <script>var targetname = '<?php echo $f;?>';</script>
  7. <script type="text/javascript" src="../static/js/jquery.min.js"></script>
  8. <script src="../static/js/ui.core.js"></script>
  9. <script src="../static/js/ui.draggable.js"></script>
  10. <script src="../static/js/ui.resizable.js"></script>
  11. <style type="text/css">
  12. body {padding:10px 0;margin:0;background:#333;font-size:12px;line-height:14px;}
  13. form,ul,ol,h1,h2,h3,h4,h5,h6,p {margin:0;padding:0;}
  14. input,textarea,select,button {font-size:12px;}
  15. img {border:none;}
  16. em {font-style:normal;}
  17. cite,small,address {font-size:12px;font-style:normal;color:#999;}
  18. a {color:#00f;text-decoration:underline;}
  19. #box { padding:10px;margin:10px 20px 10px 20px;background:#999;font-size:14px; }
  20. /*演示内容*/
  21. #imgBox {
  22. float:left;
  23. border:#333 3px solid;
  24. }
  25. #imgCut {
  26. border:#fff 2px dashed;
  27. position:absolute;
  28. top:30px;
  29. left:30px;
  30. background: url(../static/transparent.gif) repeat-x;
  31. cursor:move;
  32. }
  33. #faceImg {
  34. width:400px;
  35. }
  36. #imgBox_pre {
  37. float:left;
  38. width:250px;
  39. margin-left:30px;
  40. }
  41. #imgBox_pre strong{
  42. display:block;font-size:12px;text-align:center;
  43. }
  44. #imgBox_pre button{
  45. width:80px;
  46. margin:0 auto;
  47. }
  48. #imgBox_pre div {
  49. width:150px;
  50. margin:5px auto 20px;
  51. border:#666 5px solid;
  52. overflow:hidden;
  53. }
  54. #data {
  55. clear:both;padding-top:20px;
  56. }
  57. #dobutton {
  58. clear:both; margin-top:8px;
  59. }
  60. </style>
  61. <script language="javascript">
  62. var scale2, scale3, imgH, imgW, imgsrc, scale, temp_top, temp_left;
  63. var sysW = <?php echo $cfg_ddimg_width; ?>;
  64. var sysH = <?php echo $cfg_ddimg_height; ?>;
  65. <?php
  66. $info = '';
  67. $sizes = getimagesize($cfg_basedir.$file, $info);
  68. $imgw = $sizes[0];
  69. $imgh = $sizes[1];
  70. echo " trueImgW = $imgw;\r\n trueImgH = $imgh;\r\n";
  71. ?>
  72. var $ = jQuery;
  73. $(function () {
  74. $("#imgCut").width(sysW).height(sysH);
  75. scale3 = sysW / sysH;
  76. scale2 = $("#imgBox_pre div").width() / $("#imgCut").width();
  77. $("#faceImg_pre").width($("#faceImg").width() * scale2).height($("#faceImg").height() * scale2);
  78. $("#imgBox_pre div").height($("#imgBox_pre div").width() / scale3);
  79. $("#width").val(sysW);
  80. $("#height").val(sysH);
  81. $("#imgCut").draggable({
  82. containment : $("#faceImg"),
  83. drag : function () {
  84. scale3 = $("#imgCut").width() / $("#imgCut").height();
  85. scale2 = $("#imgBox_pre div").width() / $("#imgCut").width();
  86. $("#faceImg_pre").width($("#faceImg").width() * scale2).height($("#faceImg").height() * scale2);
  87. $("#imgBox_pre div").height($("#imgBox_pre div").width() / scale3);
  88. $("#width").val($("#imgCut").width());
  89. $("#height").val($("#imgCut").height());
  90. temp_top = $(this).offset().top - $("#faceImg").offset().top;
  91. temp_left = $(this).offset().left - $("#faceImg").offset().left;
  92. $("#imgBox_pre div").scrollTop(temp_top * scale2);
  93. $("#imgBox_pre div").scrollLeft(temp_left * scale2);
  94. $("#left").val(temp_left);
  95. $("#top").val(temp_top);
  96. },
  97. stop : function () {
  98. }
  99. });
  100. });
  101. function changeRang()
  102. {
  103. $("#imgCut").resizable({
  104. containment : $("#faceImg"),
  105. handles : "all",
  106. knobHandles : true,
  107. aspectRatio : false,
  108. minWidth : 90,
  109. minHeight : 60,
  110. resize : function () {
  111. scale3 = $("#imgCut").width() / $("#imgCut").height();
  112. scale2 = $("#imgBox_pre div").width() / $("#imgCut").width();
  113. $("#faceImg_pre").width($("#faceImg").width() * scale2).height($("#faceImg").height() * scale2);
  114. $("#imgBox_pre div").height($("#imgBox_pre div").width() / scale3);
  115. $("#width").val($("#imgCut").width());
  116. $("#height").val($("#imgCut").height());
  117. temp_top = $(this).offset().top - $("#faceImg").offset().top;
  118. temp_left = $(this).offset().left - $("#faceImg").offset().left;
  119. $("#imgBox_pre div").scrollTop(temp_top * scale2);
  120. $("#imgBox_pre div").scrollLeft(temp_left * scale2);
  121. $("#left").val(temp_left);
  122. $("#top").val(temp_top);
  123. },
  124. stop : function (e, ui) {
  125. }
  126. });
  127. }
  128. function ReturnImg(reimg)
  129. {
  130. <?php
  131. if( empty($isupload) )
  132. {
  133. $reObjJs = " var backObj = window.opener.document.form1.picname;
  134. var prvObj = window.opener.document.getElementById('divpicview');\r\n";
  135. }
  136. else
  137. {
  138. $reObjJs = " var backObj = window.opener.parent.document.form1.picname;
  139. var prvObj = window.opener.parent.document.getElementById('divpicview');\r\n";
  140. }
  141. echo $reObjJs;
  142. ?>
  143. backObj.value = reimg;
  144. if(prvObj)
  145. {
  146. prvObj.style.width = '150px';
  147. prvObj.innerHTML = "<img src='"+reimg+"?n' width='150' />";
  148. }
  149. if(document.all) {
  150. window.opener=true;
  151. }
  152. window.close();
  153. }
  154. </script>
  155. </head>
  156. <body>
  157. <div id="box">
  158. <form id="setFace" name="setFace" method="post" action="imagecut.php">
  159. <input type="hidden" name="action" value="cut" />
  160. <input type="hidden" name="f" value="<?php echo $f;?>" />
  161. <input type="hidden" name="file" value="<?php echo $file;?>" />
  162. <input type="hidden" name="isupload" value="<?php echo (empty($isupload) ? '' : $isupload); ?>" />
  163. <div id="imgBox">
  164. <img id="faceImg" src="<?php echo $file;?>" />
  165. <div id="imgCut"></div>
  166. </div>
  167. <div>
  168. <div id="imgBox_pre">
  169. <strong>预览</strong>
  170. <div class='boximg'><img id="faceImg_pre" src="<?php echo $file;?>" /></div>
  171. <p align="center">
  172. <button type="submit" name="sb1" id="sb1">裁剪</button> &nbsp;
  173. <button type="button" name="useold" onClick="ReturnImg('<?php echo $file; ?>')">使用原图</button>
  174. </p>
  175. </div>
  176. <div id="data" style='color:#ffffff'>
  177. left<input name="left" type="text" id="left" size="3" readonly="readonly" />
  178. top<input name="top" type="text" id="top" size="3" readonly="readonly" />
  179. 宽<input name="width" type="text" id="width" size="3" readonly="readonly" />
  180. 高<input name="height" type="text" id="height" size="3" readonly="readonly" />
  181. <a href='javascript:changeRang();' id='changeRang'>改变比例</a>
  182. </div>
  183. </form>
  184. </div>
  185. </body>
  186. </html>