如何使用断头台(JS)和干预在服务器上转换图像

I am using Guillotine to let the user transform images. No instructions or examples are provided for how to actually apply the transformations on the server side. Using Intervention, how do you do this properly?

The image is sent to the server with the following instructions:

{ scale: 1.4, angle: 270, x: 10, y: 20, w: 900, h: 675 }

So how to we take that info and apply it to the photo?

Here is what I have so far:

// Gets the true initial orientation
$img->orientate();

// Mirrors the image to what the user sees
$img->flip('v')->flip('h'); 

if(isset($fileData['angle']) && $fileData['angle'] > 0 && $fileData['angle'] < 360){
    $img->rotate($fileData['angle']);
}

Have you considered using the GD library directly in PHP? That is what powers Intervention and for a simple task like this, it may be best to go straight to the source.

You can use the PHP GD library to resize, reshape, crop, etc. images http://php.net/manual/en/ref.image.php

This script excerpt from an email signature creator will create a landscape image and position the user's profile picture on the left.

// Create image canvas (width, height)
$canvas = imagecreatetruecolor(450, 74);

// Load image
$img = imagecreatefromjpeg($img_path);

// Resize image and add to canvas
imagecopy($canvas, $img, 5, 5, 0, 0, 64, 64);

// Create image
imagejpeg($im);
imagedestroy($im);