Jump to content

Saving image


Recommended Posts



I'm really new to php and could really do with some help.


I am using the following script




which basically allows me to position an image within a DIV area


My question is, how can I get PHP to save just the image within the DIV area, so it's almost acting like a crop tool


I've tried a few things but so far not managed to get anything working

Link to comment
Share on other sites

Moving an image around in javascript is vastly different than cropping an image in PHP.  I know it seems like it would be simple, but none of the code that does this viewing stuff is even PHP, it's all JavaScript.


You would have to figure out the top-left and bottom-right corners of the "view port" as they relate to the image itself (you may not even have these figures).  Then you'd have to post the image and the coordinates to a PHP script.  Load the image using the gdimage library (which you may have to compile into PHP), create a new blank image of the appropriate size, and then use one of the imagecopy functions (like imagecopyresize) to copy the portion of the larger image into the new smaller image.  Then save the new smaller image inside your web directory and serve it back using an <img /> tag.

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.