I'm having trouble with php function imgcropauto.
I am trying to write a web app that will allow documents to be uploaded from various sites to a central server.
My aim is to autocrop the sides of the document out so that the image received from the users mobile device is similar quality to a scan. (similar to apps like office lens etc).
My php is below, but all it seems to be doing is rotating the image 90 degrees counter-clockwise and slightly dulls the colour.
(I have pulled out come unnecessary bits of the code and just included what is important).
if(!empty($_FILES['uploaded_file'])){
$stamp = date("Ymdhis");
$path = "../uploads/";
$file = $_FILES["uploaded_file"];
$temp = explode(".", $file["name"]);
$newfilename = $stamp . '.' . end($temp);
if(move_uploaded_file($file["tmp_name"], $path . $newfilename)) {
}else{
echo "There was an error uploading the file, please try again!";
}
$img = imagecreatefromjpeg($path . $newfilename);
$cropped = imagecropauto($img, IMG_CROP_SIDES);
if ($cropped !== false) {
imagejpeg($cropped, $path . $newfilename);
}
}
else {echo "<h1>no file to upload</h1>";
}