image extension

hi! everybody!

I am newbie!

I prefer to use imageextension.

I have done:

[u]Installation ¶

* Extract image folder under protected/extensions


* Extract helpers folder under protected

Usage ¶

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

‘import’=>array(

...


'application.helpers.*',


...

),

‘components’=>array(

‘image’=>array(

      'class'=>'application.extensions.image.CImageComponent',


        // GD or ImageMagick


        'driver'=>'GD',


        // ImageMagick setup path


        'params'=>array('directory'=>'/opt/local/bin'),


    ),...

)[/u]

but I do not know where to put these code:

[b]$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’);

or

Yii::import(‘application.extensions.image.Image’);

$image = new Image(‘images/test.jpg’);

$image->resize(400, 100)->rotate(-45)->quality(75)->sharpen(20);

$image->render();[/b]

Anybody would help? where to put these code?

in your controller probably, but you should know better…

clearly, please…

I can not make it useful…

Thanks!

It really depends on your purpose,

If you want to resize the image as soon as it is uploaded , then as uploading is handled in controller , you would put that in controller.

You can just give it a try by creating an empty view and post something like this:


$realpath=realpath(Yii::app()->request->baseurl);

$url="/images/imagedatatype/";

$image = Yii::app()->image->load($realpath.$url.'1_New.gif');

$image->resize(100, 100)->rotate(-45)->quality(75)->sharpen(20);

//echo var_dump($image);

$image->save($realpath.$url.'1_New_thumb.gif');

Obviously take care of those $url and image names.

Btw, if you are using in windows -

change -


escapeshellcmd($this->dir.'convert'.$this->ext)

to


'"'.$this->dir.'convert'.$this->ext.'"'

Then it would work.

Thanks!