简体   繁体   中英

How to let users choose define their own thumbnail image?

Here is my current situation: I am able to show uploaded picture and make users draw crop area having a predefinded aspect ratio. And, on submit corner coordinates of it are sent to my server application that crops and saves the image.

However uploaded image dimensions are variable and I am restricting it to a max-width . The problem is JCrop (my jquery plugin that draws crop area and sets its coordinates to my hidden inputs) sets crop area coordinates with respect to image on the client side. If the image height is smaller than my max height it is ok, but, if it is not the image gets cropped wrong.

To solve this; I am planning to get img.clientWidth; and img.clientHeight; , pass them to my server side also. And then converting crop coordinates to true-coordinates by doing some extrapolation.

Is this aproach good? is there any better or more beautiful solution?

Solved

Jcrop has an option to set true size, so it does all of the math if true size is defined.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM