Image manipulation - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Image manipulation (/showthread.php?tid=68575) |
Image manipulation - theedo - 07-29-2017 Hi people! How's going? Today I'm here to ask you something about the image manipulation. I studied it a lot, but I need help with something. I'm making a "Change profile picture" like facebook/instagram/twitter/......and more. I want the image that user upload becomes smaller, not in size(width and height I mean) but in dimension. Instead: I've an image of 4mb -> it must be smaller than 4mb when the user upload on my website. And do you have some suggestion about display the image in profile user? Instead the image has 800 as width 400 as height and my profile-box is 215w x 215h, how can I crop the image without lose anything? I post here my actual upload function, maybe you can help me! Thank you PHP Code: public function changeProfilePicture(){ (Yes, actually I resize the image to 215h 215w, but I don't want do this because if the user click on the image, obviously, he'll see that 215x215 and not with the real dimensions) RE: Image manipulation - InsiteFX - 07-30-2017 For the size of the uploaded file: PHP Net - Get File Size As for the profile image you would need to create a thumbnail image for it. Do a Google search on ( CodeIgniter Thumbnail Image ) RE: Image manipulation - theedo - 07-30-2017 Thank you for the suggestion about thumbnail, I'll use this. But, I don't need the get file size function.. I want that when an user upload an image the real image pass through a "compression" to reduce the size, some idea? RE: Image manipulation - Diederik - 07-30-2017 You could take a look at kraken.io. or if you want to do it by yourself at tools like jpegtrans, pngcrush etc. RE: Image manipulation - jarmen_kell - 07-30-2017 (07-30-2017, 12:20 PM)theedo Wrote: Thank you for the suggestion about thumbnail, I'll use this. there're lot's of other image manipulation lib from composers' Packagist of you feel like want to try exploring it. but if you insist on using CI's own library. you might wanted to make it a little bit more creative. when you'r user upload an image using CI's own File Uploading lib, it'll return all of the information on the uploaded file image, and few of it are your uploaded image's Width and Height: PHP Code: <?php now you've got your file's original "width" and "height", lets parse it into CI's Image Manipulation lib config init with additional options, that is the "quality" option: PHP Code: <?php please CMIIW RE: Image manipulation - InsiteFX - 07-30-2017 These three can effect the timing of file uploads if the file is large Check these and change if you start to get timing errors. session.gc_maxlifetime max_input_time max_execution_time These effect the upload size. upload_max_filesize 20M post_max_size 20M RE: Image manipulation - Martin7483 - 07-31-2017 Tinypng.com for JPG and PNG lossless compression. Even supports animated PNG Service is free up to 500 compressions per month. Really easy to use with CodeIgniter |