CodeIgniter Forums
Image resize by width only - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Image resize by width only (/thread-27060.html)



Image resize by width only - El Forum - 01-30-2010

[eluser]Random dude[/eluser]
I want my users to be able to choose from 3 sizes of images:
small (200px width), med(500px width), large(800px width).

I'm trying to use the image_lib to re-size images by setting width only,
for example, if a user selects 'small', and uploads an image that's 1000px/900px,
the image will be re-sized to 200px / (height adjusted automatically). In the 1000px/900px example, that would 200px / 180px.

Right now if I set width to 200px, the height of the image stays the same. For example, 200px/900px. I'm not able to set height because users will be uploading many images of completely different sizes.

What should I do?


Image resize by width only - El Forum - 01-30-2010

[eluser]umefarooq[/eluser]
Hi in config keep
Code:
$config['maintain_ratio'] = TRUE;
if it is false then you will get the problem which you are facing right now check user guide also

http://ellislab.com/codeigniter/user-guide/libraries/image_lib.html


Image resize by width only - El Forum - 02-01-2010

[eluser]Random dude[/eluser]
Still not adjusting height automatically, here are my settings.

Code:
$config['image_library'] = 'GD2';
        $config['source_image'] = './uploads/' . $swf_folder . '/' . $swf_file_name;
        $config['create_thumb'] = FALSE;
        $config['maintain_ratio'] = TRUE;
        $config['quality'] = "85%";
        $config['new_image'] = './uploads/' . $swf_folder . '/' . $swf_small_file_name;
        $config['width'] = 250;

I think what I need is something like $config['height'] = "AUTO";


Image resize by width only - El Forum - 02-01-2010

[eluser]helmutbjorg[/eluser]
Are you trying to resize a SWF file?


Image resize by width only - El Forum - 02-01-2010

[eluser]Random dude[/eluser]
No I'm not, I just happened to name everything with swf_ because the files are coming from swfuploader.


Image resize by width only - El Forum - 02-07-2010

[eluser]fRkSsK[/eluser]
any idea? i have same problem.


Image resize by width only - El Forum - 02-07-2010

[eluser]fRkSsK[/eluser]
hmm. i think it works.

if code is:

$config['maintain_ratio'] = TRUE;
$config['width'] = 230;
$config['height'] = 175;

and if your photo w:1944 h:2592, it resize w:132 h:<b>175</b>.
or your photo w:1200 h:623, it resize w:<b>230</b> h:120.


Image resize by width only - El Forum - 02-07-2010

[eluser]fRkSsK[/eluser]
but i can not find <b>image_ratio_crop</b>.

verot.net has image_ratio_crop. but i want to use CI upload class. i found someting http://ellislab.com/forums/viewthread/109434/.

i think CI uploader class has not image ratio crop. has?


Image resize by width only - El Forum - 02-07-2010

[eluser]fRkSsK[/eluser]
solution is http://ellislab.com/forums/viewthread/115336/. but CI default preferences isn't support image ratio crop.


Image resize by width only - El Forum - 02-07-2010

[eluser]Udi[/eluser]
Lesson I learned lately while working with several Flash Uploaders:
echo/print something back in the end of the uploading method - Mac users may have problems if you're not doing it.