Image manipulation |
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)
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 ) What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
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?
You could take a look at kraken.io. or if you want to do it by yourself at tools like jpegtrans, pngcrush etc.
07-30-2017, 05:01 PM
(This post was last modified: 07-30-2017, 05:03 PM by jarmen_kell. Edit Reason: CI Forum's auto formatting bb tags mess up my pasted code ) (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
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 What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
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 |
Welcome Guest, Not a member yet? Register Sign In |