问题描述
我正在使用Laravel Image Intervention和jQuery Guillotine进行裁切功能,但是它裁切了图像的不同部分。请查看下面的代码和屏幕截图。
控制器
$data = explode('|',$image_details);
$data = [
'angle' => $data[0],'h' => $data[1],'scale' => $data[2],'w' => $data[3],'x' => $data[4],'y' => $data[5]
];
// Create image instance from source
$image = Image::make($request_file);
// we get the image width then multiply it by the scale factor,it will also scale the height automatically
$image->widen(intval(floatval($image->width()) * floatval($data['scale'])));
// File details
$extension = explode('/',mime_content_type($request_file))[1];
$name = md5(uniqid()) . time() . '.' . $extension; // as6d57a9sd7a5sd67856a9s.jpg
// Temp details
$key = md5(uniqid());
$tmp_file_name = "{$key}.{$extension}"; // et7e98r7t9e79rt9e098g9e0.jpg
$tmp_file_path = base_path() . "/" . $server_path . '/'. $tmp_file_name; // Server path
// Image Cropper
$image->crop(
$data['w'],$data['h'],$data['x'],$data['y']
);
// Upload image to filesystem
$image->save($tmp_file_path);
断头台
picture.on('guillotinechange',function(e,data,action){
showData(data)
$('#imageDetails').val(data.angle + '|' + data.h + '|' + data.scale + '|' + data.w + '|' + data.x + '|' + data.y);
})
屏幕截图
[上传前]
[上传后]
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)