Reputation: 411
I am using jQuery ImgAreaSelect 0.9.10 plugin to crop image uploaded by user.
I am taking input in "multipart/form-data". When I crop image using plugin it gives me coordinates in pixels, but I am looking for coordinates in percentage(%), because I fixed my image in div (size varies from original image size).
Is this possible to get coordinates in % or any alternate way to achieve this?
Upvotes: 1
Views: 246
Reputation: 16090
Use 'imageHeight' and 'imageWidth' to find a % ratio.
var xRatio1 = 100*x1/imageWidth,
yRatio1 = 100*y1/imageHeight,
xRatio2 = 100*x2/imageWidth,
yRatio2 = 100*y2/imageHeight
From docs:
imageHeight True height of the image (if scaled with the CSS width and height properties)
imageWidth True width of the image (if scaled with the CSS width and height properties)
Upvotes: 1