Yii 1.1: image

Convert Kohana Image Library to Yii

Provides methods for the dynamic manipulation of images. Various image formats such as JPEG, PNG, and GIF can be resized, cropped, rotated and sharpened.

All image manipulations are applied to a temporary image. Only the save() method is permanent, the temporary image being written to a specified image file.

Image manipulation methods can be chained efficiently. Recommended order: resize, crop, sharpen, quality and rotate or flip

此库提供方法动态的处理图片。支持对 JPEG,PNG 和 GIF 格式的图片进行调整大小,剪裁,旋转和锐化。

所有对图片的处理都会应用到一个临时图像上面,但只有 save() 方法是永久的,它会把临时图像写入指定的图像文件中。





  • Yii 1.0 or above


  • Extract image folder under protected/extensions
  • Extract helpers folder under protected


The following code is the component registration in the config file:

            // GD or ImageMagick
            // ImageMagick setup path

See the following code example:

$image = Yii::app()->image->load('images/test.jpg');
$image->resize(400, 100)->rotate(-45)->quality(75)->sharpen(20);
$image->save(); // or $image->save('images/small.jpg');


$image = new Image('images/test.jpg');
$image->resize(400, 100)->rotate(-45)->quality(75)->sharpen(20);


Change Log

February 1, 2009

  • The use of Yii::import instead of require to load image driver
  • Change image driver filename

January 22, 2009

  • Initial release.

Total 20 comments

#19829 report it
oma378501 at 2016/04/11 08:57am
resize three dimension

Hi guys

current I just re size one image upload in filesystem, Can re size three dimension when upload one file?


#19672 report it
usman iqbal at 2015/11/21 06:06am
why not working for high dimesnion.Is it a bug?

Not working for high dimension why why. 7000*4000

#18891 report it
Dhara at 2015/01/31 01:56am
image contains errors.

i use following action to display image

public function actionImageResize()
            $image = new Image('images/banner4.jpg');
            $image->resize(400, 100);

but it gives me

The image "http://localhost:83/mysite/site/ImageResize" cannot be displayed because it contains errors

i applied all configuration as per document. Anything Wrong?

#18805 report it
Hipogea at 2015/01/12 11:16am
Function is_file(), inside extension does'nt work

I have tried many times, with this:

$picture = Yii::app()->image->load( 'http://www.neologys.com/recurso/logos/Koala.jpg'); but always trhow the follow error in ImageClass.php File:

// Check to make sure the image exists //if (!is_file($image)) //throw new CException('image file not found' );

I reviewed the path file, all is right, i tried with absolute routes also, the access at parent folder, the access at file... But it doesn't work. I would be very grateful , some help

#18522 report it
KoJI6ac9H at 2014/11/09 01:21pm

Replace 'require' to 'require_once', in line 123 (Image.php) This will allow you to use the class multiple times. (rediclare class error) Useful for multiUpload

Sorry for my English

#18373 report it
ahmed.ismail at 2014/10/22 04:47am
Where's the documentation?

Documentation is no longer available, can you help me?

#13752 report it
yashu at 2013/06/22 12:54pm
For those using ImageWick under Windows

Downloading Scripts (.exe) -

1.download your windows versions at http://imagemagick.org/script/binary-releases.php#windows and install them

Setting up extension in PHP-

1.download http://valokuva.org/~mikko/imagick-php54-php53.tgz

2.Extract php_*.dll to your ext folder


Do something like this

'params'=>array('directory'=>'C:/Program Files/ImageMagick-6.8.6-Q16/'),

Tweak in Extension to make it work

Can this be called a bug?

1.Move to extensions/image/drivers/Image_ImageMagic_Driver.php





Now everything works great!

Thanks for the extension!

Namasthe :)

#13234 report it
Artur Zhdanov at 2013/05/16 01:54pm
Kohana Image

schmunk, this extension based on latest Kohana Image library http://www.yiiframework.com/extension/easyimage/

#12984 report it
Bjorn at 2013/04/25 04:54am

It works great, but does anyone has an example for a watermark function? Would be very nice.

On the forum i read that it has been added? http://www.yiiframework.com/forum/index.php/topic/36242-new-version-of-image-extension-supported-watermark/page__p__174486__hl__watermark#entry174486

#12348 report it
schmunk at 2013/03/15 07:00am
Kohana Image

Haven't tried it yet, but the underlying library is available on github in version 3.2.1.

#12346 report it
globaleyeglasses at 2013/03/15 12:31am
It will save time for other people using this extension

I agree with Parcouss too. Please, replace line 80 in Image_GD_Driver.php

Took a while to figure out the error and fix this $quality = CArray::remove('quality', $actions);


if (array_key_exists('quality', $actions)) { $quality = $actions['quality']; unset($actions['quality']);
} else { $quality = null; }

Thank You

#12151 report it
Jose H. Milán at 2013/03/01 12:44pm
#4199 Thanks


Thank you, Nayjest

#11997 report it
Amr Bedair at 2013/02/19 07:20pm
Re: "Transparent GIF bug (black background)"

I added these two lines at the end of imagecreatetransparent() function to solve the problem ... just before the return

$transparent = imagecolorallocatealpha($img, 255, 255, 255, 127);
imagefilledrectangle($img, 0, 0, $width, $height, $transparent);
#11935 report it
playdog at 2013/02/13 02:49pm

Para las personas que usen esta extension en las nuevas versiones de yii framework. Les va a salir error. para esto deben hacer lo siguiente.

Gracias al usuario del post: #4199

$quality = CArray::remove('quality', $actions);


if (array_key_exists('quality', $actions)) {
    $quality = $actions['quality'];
} else {
    $quality = null;
#11602 report it
schmunk at 2013/01/22 12:32pm
500 Internal Server Error

Please have a look at your log file, usually something like /var/log/apache2/error.log

#11601 report it
Jai Sundar at 2013/01/22 12:12pm
Not working for 7000X4000 image

NetworkError: 500 Internal Server Error.

#11600 report it
schmunk at 2013/01/22 11:58am
@Jai Sundar

Please show us your PHP error - maybe a memory limit issue?

#11599 report it
Jai Sundar at 2013/01/22 11:52am
Not working for 7000X4000 image

Its working perfectly for lower dimension images.Not working for high dimension mages.Please help me to fix this issue.

#11171 report it
v_bogdan at 2012/12/22 07:36am
addition the image class

ram0973, thank you for the addition

Leave a comment

Please to leave your comment.

Create extension