tags:

views:

35

answers:

2

Hi all,

I am creating a cakephp application in which im uploading a image. But on some functionality of my app i want to display the image in specific height n width, without compromissing in image quality. So please suggest me if ther is any way to do this.

+1  A: 

You can set only width or height attribute and to leave empty the other one. This way the image will be shown with proper resolution.

But, the performance really depends how big is the image.

Your code will be something like:

$this->Html->image('image1.jpg', array('width'=>'200px'));
Nik
+1  A: 

I suggest you to use a Plugin and its relatively simple..

http://www.milesj.me/resources/script/uploader-plugin

its very easy to implement. it takes care of validation and also attaching it to the model etc.

Organising the Images

  1. Store the user submitted original photos as it is in a folder called say original. so that incase u later change the theme or layout u can write a script to get various thumb nails :D
  2. store various sizes in their own folder say u have 200*200, 125*125, 50*50 you can store them in either folders with names with the sizes or like - large, medium, small.

  3. the reason why we are using different folders is. the file name will be the same for all sized versions only folder will change. so it relatively eaiser to be addressed than renaming the files while resizing and cropping.

There are many more plugins out there. here is a good list

http://josediazgonzalez.com/2010/08/16/cakephp-plugins-a-biblical-retelling/

here is a directory for cakephp related resources

http://cakepackages.com/

Hope this helps

Harsha M V