需要裁剪未使用任何裁剪插件上传的图像
答案 0 :(得分:0)
你可以使用canvas:
in html
<canvas id="corpImg" width="578" height="300"></canvas>
在js
<script>
var canvas = document.getElementById('corpImg');
var context = canvas.getContext('2d');
var imageObj = new Image();
imageObj.onload = function() {
// draw cropped image
var sourceX = 150;
var sourceY = 0;
var sourceWidth = 150;
var sourceHeight = 150;
var destWidth = sourceWidth;
var destHeight = sourceHeight;
var destX = canvas.width / 2 - destWidth / 2;
var destY = canvas.height / 2 - destHeight / 2;
context.drawImage(imageObj, sourceX, sourceY, sourceWidth, sourceHeight, destX, destY, destWidth, destHeight);
};
imageObj.src = 'image url';
</script>