ptolomea Posted September 23, 2007 Share Posted September 23, 2007 Hey, I'm looking to crop an image when its being loaded into the website, I'm not concerned with loading time as most likely it will be a forked script anyways. All the scripts and functions that I have researched and looked into require you to specify a destination image, I would like to use the source image and crop the output for just the loading page and would like to avoid having 2 images one full and one cropped since both images will be used, and space will be a big issue which is why I'm trying to avoid a 2nd image. Now since I don't have code to trouble-shoot I'm not looking for code to be placed here, what I would like is a point to the right direction that way should I need it I can reply with code to trouble-shoot. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/70309-loading-image-crop/ Share on other sites More sharing options...
cooldude832 Posted September 23, 2007 Share Posted September 23, 2007 GD library can do almost anything to an image (or make its own if you don't like the current one), however you can't exactly crop an upload file without sending it to a destination (it be pretty pointless), also it be better to use a temp storage if you want to have previewing of the cropped image. As for defining the image, it can be defined by the uploader, time, date, random, etc. Quote Link to comment https://forums.phpfreaks.com/topic/70309-loading-image-crop/#findComment-353185 Share on other sites More sharing options...
ptolomea Posted September 23, 2007 Author Share Posted September 23, 2007 any image that will be on the website will not be uploaded by a user it will all be put on the server by hand and then modified in any way a good way to think of what I would like to do is picture a book cover if you lay it flat you have the back cover the spine then the front cover. Now I'd like to only show the front cover on the main page and then the entire thing if it is clicked on. Quote Link to comment https://forums.phpfreaks.com/topic/70309-loading-image-crop/#findComment-353190 Share on other sites More sharing options...
cooldude832 Posted September 23, 2007 Share Posted September 23, 2007 well it can't really crop that easily based on what the image is (it can but its amazingly hard) but you could crop it to a certain amount of pixels. But basically I'd suggest looking into the glob function and after you upload all the images resize them using a <?php $files = glob($imgfolder); Foreach($files as $value); { //Resize here } ?> And then if you wanted to add some logic to it saying if its already resized dont' resize Quote Link to comment https://forums.phpfreaks.com/topic/70309-loading-image-crop/#findComment-353195 Share on other sites More sharing options...
ptolomea Posted September 23, 2007 Author Share Posted September 23, 2007 Thanks, I'll look into that function, all the images are going to be the same size so I hope it wont be to hard. Quote Link to comment https://forums.phpfreaks.com/topic/70309-loading-image-crop/#findComment-353200 Share on other sites More sharing options...
cooldude832 Posted September 23, 2007 Share Posted September 23, 2007 When you say crop that implies taking off part of an image, not resizing the whole image. Which isn't a strong point in gd for the reason that it can't read a whole image really well (For the user that is), if you wanted to crop at a specific point like on a line, it would have to find that line with a pixel by pixel anyalsis then crop along that line for example, however if all images are the same size and the crop point is at points (x1,y1 to x2,y2) then its no challenge at all. Quote Link to comment https://forums.phpfreaks.com/topic/70309-loading-image-crop/#findComment-353206 Share on other sites More sharing options...
ptolomea Posted September 23, 2007 Author Share Posted September 23, 2007 all the images will be the same size and the crop points will be the same, if they are not then I'll have to manually crop the image itself Quote Link to comment https://forums.phpfreaks.com/topic/70309-loading-image-crop/#findComment-353210 Share on other sites More sharing options...
cooldude832 Posted September 23, 2007 Share Posted September 23, 2007 http://us2.php.net/manual/en/function.imagecopyresized.php that should do it for you Quote Link to comment https://forums.phpfreaks.com/topic/70309-loading-image-crop/#findComment-353217 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.