上传后如何为图像进行裁剪? [英] How Do I Make A Croping For An Image After Uploading?

查看:113
本文介绍了上传后如何为图像进行裁剪?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里我已经上传了一张图片,但是我想做一个没有出现的裁剪效果。下面是我的指点。请给我一些建议。



Here i have uploaded an image but i want to do a croping effect which is not coming.below is my coading .please suggest me.

<script>
function onFileLoad(e) {
    $('#show_selected_image').html('<img id="recipeimge1" src="'+e.target.result +'"/>');
}

function displayPreview(files) {
    var reader = new FileReader();
    reader.onload = onFileLoad;
    reader.readAsDataURL(files[0]);
	 $('#recipeimge1').Jcrop({
            aspectRatio: 1,
            setSelect:  [ 50, 290, 350, 10 ],
            addClass: 'jcrop_custom',
            bgColor: 'black',
            bgOpacity: .5,
            sideHandles: false,
            onChange: updateCoordsf
            
        });
}
 function updateCoordsf(c)
    {
        $('#x').val(c.x);
        $('#y').val(c.y);
        $('#w').val(c.w);
        $('#h').val(c.h);


    };
</script>










<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script src="jquery.Jcrop.js"></script>







<link rel="stylesheet" href="jquery.Jcrop.css" type="text/css" />
<body style="text-align:center; margin-top:50px; width:50%;">

<form action="" method="post" enctype="multipart/form-data" onSubmit="myname()">

    <fieldset style="text-align:center; height:200px; color:#0000FF;">

        <legend style="border: #0000CC 1px solid;"> Upload Image</legend>

        <table width="200" border="0" align="center" cellpadding="6px">
            <tr>
                <td height="20px;">Image</td>
                <br/>
                <td>
                    <input type="file" name="image" id="image" onchange="displayPreview(this.files);"/>
                </td>
            </tr>
             
        </table>
        <br/>
        <input type="submit" value="submit" name="submit">
        <br/>
        <div id="show_selected_image"></div>
        <div class="next_btn_st">
 <form>
  <input type="text" name="x" id="x"  />
   <input type="text" name="y" id="y"  />
    <input type="text" name="w" id="w"  />
     <input type="text" name="h" id="h"  />
      <input type="submit" name="submit" id="image" />
             
       </form>

                    
    </fieldset>
</form>
</body>

推荐答案

' #show_selected_image')。html(' < img id =recipeimge1src =' + e.target.result + ' />');
}

function displayPreview(files){
var reader = new FileReader();
reader.onload = onFileLoad;
reader.readAsDataURL(files [ 0 ]);
('#show_selected_image').html('<img id="recipeimge1" src="'+e.target.result +'"/>'); } function displayPreview(files) { var reader = new FileReader(); reader.onload = onFileLoad; reader.readAsDataURL(files[0]);


' #recipeimge1')。Jcrop({
aspectRatio: 1
setSelect:[ 50 290 350 10 ],
addClass:' jcrop_custom'
bgColor:' black'
bgOpacity:。 5
sideHandles: false
onChange:updateCoordsf

});
}
function updateCoordsf(c)
{
('#recipeimge1').Jcrop({ aspectRatio: 1, setSelect: [ 50, 290, 350, 10 ], addClass: 'jcrop_custom', bgColor: 'black', bgOpacity: .5, sideHandles: false, onChange: updateCoordsf }); } function updateCoordsf(c) {


' #x')。val(cx);
('#x').val(c.x);


这篇关于上传后如何为图像进行裁剪?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆