Honestly do not use this intervention. Do yourself a favor and use gumplet.com it is the same as Cloudinary but much much cheaper with free levels also. These services will manipulate the image for you to server the best images size for what ever the device a user is using. depanding on the amount of images you server cloudinary is also a really nice option.
Sep 13, 2020
7
Level 12
How to add scale in Laravel Image Intervention package?
I'm doing a crop functionality using Laravel Image Intervention and jQuery Guillotine but it crops the different part of the image. Please see the code and screenshot below.
Controller
$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);
Guillotine
picture.on('guillotinechange', function(e, data, action){
showData(data)
$('#imageDetails').val(data.angle + '|' + data.h + '|' + data.scale + '|' + data.w + '|' + data.x + '|' + data.y);
})
Screenshot
Please or to participate in this conversation.

