javascript - browse image and crop it immediately -
first can't find anywhere solution.
i need cropping image before saving it.
when client browse , select u few image, script image automatically show in div. problem want crop image :
example.
image width: 1230px
image height: 670px
i want crop width 670px , show (to 670px 670px)
i have width , height of browse image, want crop , show cropped image.
script :
<script> function readurl(input) { for($i = 0;$i < input.files.length;$i++) { if (input.files && input.files[$i]) { var reader = new filereader(); reader.onload = function (e) { var img = new image; img.onload = function() { var width = img.width; // image loaded; sizes available var height = img.height; }; img.src = reader.result; // data url because called readasdataurl div = $(".image-upload"); $(".image-upload").append("<img id='image-upload' src='"+e.target.result+"' />"); $("#image-upload").css({ "width" : "300px", "height" : "300px" }); } reader.readasdataurl(input.files[$i]); } } } $("#files").change(function(){ $(".image-upload").empty(); readurl(this); }); </script>
Comments
Post a Comment