on a site, i have to upload images and manually crop them. is there a script so i can crop them without reloading the page (so i can integreate easily), and that will just pass the cropped image location as a $_POST value (via js form submission?)
edit - i meant use JS to sent the crop dimensions (via ajax), get the returned data (ie. the cropped filename) that can then be send (via post/get) in the开发者_如何学JAVA form
Yahoo!'s YUI javascript library has an image cropper widget:
http://developer.yahoo.com/yui/imagecropper/
You can't really do cropping in that sense without going crazy - you'd have to use a tag, crop, get the contents, base64 encode, and then submit.
It's way more effort than its worth if you're going to be sending to a PHP script anyway, which has great support for image manipulation via the GD library.
You won't be able to have JavaScript crop the images, no. They never actually have access to them. Not unless you upload them first and then send them from the server.
Your best bet would be to upload the images as usual, have PHP send it back to the page, use JavaScript to allow the user to select a portion of the image they want seen, send that data back to PHP and have PHP do the actual cropping.
That's at least how I would approach it.
You can of course use client side methods, like Flash and Java, to do the cropping client-side and send the images fully cropped to the server. But I won't pretend to know the details on how to do that.
I don't know if this is exactly what you are looking for, but you should take a look at phpThumb (And the demos.)
精彩评论