How do I resize an image in yii?


I want to list a table with a leading image that must be resized.

The images are stored in a folder called img.

The image name is stored in the database.

I want to resize it to 75/75


I tried CHtml::image, but the image is distorted when I change the size.

It’s better to store 2 versions of your images, big and small (or even more, e.g. medium).

Yii doesn’t have functions to resize images, so you should use one of extensions or any library you like. I can recommend PHP Thumb.

Thank you.

I found an extension Yii image helper


Yii image helper is giving the error

include(ImageHelper.php) [<a href=‘function.include’>function.include</a>]: failed to open stream: No such file or directory

Any ideas?


Well that error is solved but i m getting the following error

getimagesize(C:/xampp/htdocs/profile) [<a href=‘function.getimagesize’>function.getimagesize</a>]: failed to open stream: Permission denied


1058 *

1059 * This function will throw exceptions for invalid images / mime-types

1060 *

1061 */

1062 protected function determineFormat ()

1063 {

1064 if ($this->isDataStream === true)

1065 {

1066 $this->format = ‘STRING’;

1067 return;

1068 }


1070 $formatInfo = getimagesize($this->fileName);


1072 // non-image files will return false

1073 if ($formatInfo === false)

1074 {

1075 if ($this->remoteImage)

1076 {

1077 $this->triggerError('Could not determine format of remote image: ’ . $this->fileName);

1078 }

1079 else

1080 {

1081 $this->triggerError('File is not a valid image: ’ . $this->fileName);

1082 }

I have given write permission to the images folder under protected.

Any ideas?