tapmodo/Jcrop — Issue #24: Rounding issue causes blurry image in PHP
Author: mpiasta-ca
Created: 2012-01-17 15:29:26+00:00
State: open

I use jCrop to resize website screenshot down to a desired size. I need end result of 740x656.

So I set aspect ratio to 740/656 - the user isn't allowed to make a selection smaller than that.

If the user sets jCrop selection to 940 width, jCrop calculates a height of 833. But in actuality, the correct dimension should be 940 x 833.297297297297...

So when I pass these coordinates to PHP, the resized image at 740x656 comes back very blurry. Because PHP creates image that is 740x656 from the 940x833 selection.

I have spent some 6 hours or so investigation this issue so far. I'm under the impression the issue is with jCrop allowing the user to make selection that should not be allowed. The aspect ratio isn't correct on the user's selection:

740/656 = 1.1280 48780 48780 48780 48780...

940/833 = 1.1284513805522208883553421368547

940*656/740 = 833.297 297 297 297 297 297 297...

Any ideas how I can solve this problem?