Hi,
I'm currently working on a image resizing and cropping tool that uses a flash interface to select the crop area, size of cropped image (pulled from a D and constraints etc.
I'm having a couple of issues when a user tries to resize and crop at the same time. So far the answer to my problems (in theory) is the following:
Original Image: 640 x 480
Desired Crop Size: 468 x 60
Given width and height: 589 x 76
Approx 20% bigger than it should be, scale to 0.8 or closer.
Here's an example of what it looks like (so you can get a nice picture in your mind).
First copy the portion of the image that I want to use, I'm doing this using the simple [FONT="Courier New"]imgcopy();[/FONT] command because no resizing is necessary and it retains the original image quality and lowers server usage.
Second, I'd then scale the duplicated image by the % change from the crop x,y. This is done using [FONT="Courier New"]imgcopyresampled();[/FONT].
Lastly I'd save the image and update the database.
This is my code for the particular area:
$height_woo = $_POST['imgBRX'] - $_POST['imgTLX'];
$width_woo = $_POST['imgBRY'] - $_POST['imgTLY'];
echo $height_woo."<br/>".$width_woo;
$image_mid = imagecreatetruecolor($width_woo, $height_woo);
$image_output = imagecreatetruecolor($_POST['imgW'], $_POST['imgH']);
imagecopyresampled($image_mid,$path_image,$this->output_cut_x,$this->output_cut_y,$this->input_cut_x,$this->input_cut_y,$out_width,$out_height,$width_orig,$height_orig);
imagecopyresampled($image_output,$image_mid,0,0,0,0,$_POST['imgH'],$_POST['imgW'],$width_woo,$height_woo);
But it outputs random stuff like this.
I want some advice and maybe some help with the code if you could... Thanks!