dweb Posted May 12, 2012 Share Posted May 12, 2012 Hi I'm really new to php and could really do with some help. I am using the following script http://test.dpetroff.ru/jquery.iviewer.test/test/ 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 Quote Link to comment https://forums.phpfreaks.com/topic/262450-saving-image/ Share on other sites More sharing options...
ManiacDan Posted May 12, 2012 Share Posted May 12, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/262450-saving-image/#findComment-1345005 Share on other sites More sharing options...
dweb Posted May 12, 2012 Author Share Posted May 12, 2012 ok, gulp, maybe not as easy as I thought any suggestions on a good php image crop tool like that example? Quote Link to comment https://forums.phpfreaks.com/topic/262450-saving-image/#findComment-1345008 Share on other sites More sharing options...
ManiacDan Posted May 12, 2012 Share Posted May 12, 2012 Not off the top of my head. Should I ever need something like this, I'd write it myself. Quote Link to comment https://forums.phpfreaks.com/topic/262450-saving-image/#findComment-1345019 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.