I'm using Jcrop in a project I'm building. The site allows users to upload a profile photo and crop it with an aspect ratio that fits where I'm displaying the photo, fx. forum posts, tagwall posts etc.
However, since Jcrop is sending the crop coordinates as POST variables, I'm thinking that one might be able to mess with the cropping size using something like Tamper Data to modify the request sent to the server after selecting the part of the photo that they want.
How would you go about this and ensure that the photos are showing up correctly?
Okay, I got this sorted out now.. Now I'm just checking if the height and width sent by Jcrop fits the aspect ratio I want!
In case anyone else needs this:
function GCD($a, $b) {
while ($b != 0) {
$remainder = $a % $b;
$a = $b;
$b = $remainder;
}
$a = abs($a);
return $a;
}
$a = $_POST['w']; // width
$b = $_POST['h']; // height
$gcd = GCD($a, $b);
$a = $a / $gcd;
$b = $b / $gcd;
$ratio = $a . ":" . $b;