国内流行的内容管理系统(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.

181 lines
6.0KB

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