views:

34

answers:

1

how do i create thumbnail form original size ( any size) to 50 x 50 ( fixed size) link text

when add images to lightbox all images in any size will resize to 50 x 50 dimention how to implement that with codeigniter image class ;

imagine i have image with 600x320 dimensions when i re size it with maintain_ratio "on" it's gave me 50x27 dimensions when i re size it to 50x50 . anyway if i turn maintain_ration "off" it's resized nicely to 50x50 but output is deformed

tanks .

A: 

I'm not exactly sure what you are asking. Do you want to resize an image to 50x50 or do you want to create a lightbox effect. To resize simply follow the instructions in the user guide. They're very straightforward: http://codeigniter.com/user_guide/libraries/image_lib.html

If you want to create a lightbox then you will need to use JavaScript not codeigniter. There are loads out there to choose from for different js frameworks if you don't want to build your own.

Hope that helps.

musoNic80
i already read the documentation before ask question , and my question about image manipulation not about effect . so imagine i have image with 600x320 dimensions when i re size it with maintain_ratio "on" it's gave me 50x27 dimensions when i re size it to 50x50 . anyway if i turn maintain_ration "off" it's resized nicely to 50x50 but output is deformed .
mehdi
Ok, I'm with you now. I'm not sure that you can achieve what you want with ci or php. If you change the ratio of the image dimensions then I would think the image will always be distorted. Does the thumbnail have to be square? Could you keep the ratio and pad out the shorter dimension with an unobtrusive background colour? I'm assuming there's a reason why you have to manipulate an original rather than having a separate gallery of pre-made thumbnail images.
musoNic80
yes pre-made thumbnail is good idea but what happen when i deal with users i can't force them to pre-made their picutre then upload it's not user friendly in other hand i need to put the user avators for example in fixed size without image deformed .
mehdi
you mean the example i maintained using pre-made thumbnails ? or thumbnails are generate automatically ?
mehdi
If you're asking users to upload images then I think all you can do is request the user uploads a file with the correct dimensions (or ask them to make sure that the height and width values are the same which you can then manipulate) or accept that to keep the image ratio you will have to pad with a background. If there is a way to adjust image ratio and keep image undistorted, I don't know what it is but I certainly don't think you can achieve it with the ci image class.
musoNic80