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.
JavaScript function:
$('#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:
$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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.