[英]fill extra area with custom color while cropping with Cropper.js
I am using Cropper.js library to get crop coordinates and width and height an image at client side and Intervention in laravel 4 to actually corp it in server side with the corp data. 我正在使用Cropper.js库来获取作物坐标和宽度和高度在客户端的图像和干预4在实际上在服务器端使用公司数据进行干预。
JavaScript function: JavaScript函数:
$('#image').cropper({
aspectRatio: 16 / 9,
crop: function (e) {
// To send cop data to server
x = e.x;
y = e.y;
width = e.width;
height = e.height;
rotate = e.rotate;
scaleX = e.scaleX;
scaleY = e.scaleY;
$('#x').val(x);
$('#y').val(y);
$('#width').val(width);
$('#height').val(height);
$('#rotate').val(rotate);
$('#scaleX').val(scaleX);
$('#scaleY').val(scaleY);
}
});
PHP/Laravel Function: PHP / Laravel功能:
$img->crop($width, $height, $x, $y);
When cropped area out of image, this extra area is auto filled with black color. 当裁剪区域超出图像时,此额外区域将自动填充黑色。 I want it to be filled with white color instead.
我希望它用白色填充。
This generates this image 这会生成此图像
I want to change the black color to white. 我想将黑色改为白色。
You'll need a combination of commands in intervention: 您需要干预中的命令组合:
So you'd something like this (not tested) 所以你有这样的事情(未经测试)
$destination = Image::canvas($width, $height);
$destination->fill('#ffffff');
$destination->insert($img, $x, $y);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.