EPhpThumb is a lightweight extension for the well known phpThumb library (PhpThumb). There are a lot of extensions out there providing more functionality but they can be total overkill for just creating some thumbnails and saving them to disk. I had this problem so I simply created this extension and want to share it with the Yii community.

If you experience any difficulties, bugs or have some questions post them in here.

Is there any caching functionality in this library and how can I turn it on?

PhpThumb doesn’t provide caching out of the box. You’ll have to implement your own mechanisms. Take a look at this issue on Github

do not understand where should I put this setting in the main.

right into the main array configuration or some sub array as import, modules or components?

when using the configuration in the main, when trying to use the controller

$ thumb = Yii :: app () -> phpThumb-> create (… / images / site / news / sample.jpg ');

I get the message:

[b]The property "CWebApplication.phpThumb" is not defined.


and if I use the import

Yii :: import ("ext.EPhpThumb.EPhpThumb");

$ thumb = new EPhpThumb ();

$ thumb-> init () / / this is needed

/ / chain functions

$ thumb-> create (’… / images / big.jpg’);

$ thumb-> resize (200,200);

$ thumb-> save (’… / images / small.jpg’);

the message is

EPhpThumb and Its behaviors of the method or not have a closure named "resize".

Hi and sorry for the late reply,

Did you put the phpThumb config within the "components" config part in your main?


    ...components like user, logRoutes etc.....






I am using the EPhpThumb extension, and it was working well on both localhost and my test server, but literally over night it stopped working on localhost (WAMP set up) and I got the following error message:

include_once([my yii app path]\protected\extensions\EPhpThumb\lib\phpThumb\src\thumb_plugins\_notes) [<a href='function.include-once'>function.include-once</a>]: failed to open stream: Permission denied

On my dev server (identical LAMP set up as the test server where it works) I get the following error:

include_once([my yii app path]/protected/extensions/EPhpThumb/lib/phpThumb/src/thumb_plugins/_notes) [<a href='function.include-once'>function.include-once</a>]: failed to open stream: Invalid cross-device link

Any suggestions?

Thanks :)

I guess the problem is a link between two different partitions which isn’t possible. Do you use any symbolic links like that?

Thanks for replying Haensel.

My localhost has no partitions, and both the dev and test servers are shared linux hosted servers. I just find it strange that the code works on test, not on dev, and did work for a while on localhost. The code is of course identical. I am including EPhpThumb in the controller, not in the config file.


Do you see a dwsync.xml in the "_notes" directory mentioned in the error message? I am not sure what it is, it is not distributed with my extension so I guess it is either created by phpThumb or something else (it seems like Dreamweaver is creating it too): https://www.google.at/search?q=dwsync.xml&aq=f&sugexp=chrome,mod=9&sourceid=chrome&ie=UTF-8

That was it! I removed the "_notes" directories which as you said probably were put in by dreamweaver and were hidden by several of the tools I used for viewing the file hierarchy. EPhpThumb is now working perfectly again on all three servers.

Thank you Haensel :)

Hi I have question.

I need resize big image like this:


My image change width to 610px and height to 610px

This extension resize only quadrat images?

That would be able to change the rectangle?

That’s usually only the case when using $thumb->adaptiveResize(x,y) so I don’t understand why the above example isn’t working. Maybe you could post all your code you are using in here?

My code:

$thumb=Yii::app()->phpThumb->create($images_path . '/'. $model->name);


$thumb->save($images_path . '/'. $model->name);

If use


it’s good size but image it’s cropped :(

The cropping is intended if you’re using adaptiveResize() but if you are only using resize() this should not happen. The only thing I can imagine now is that this has to do with the size of the image itself so what’s the size of your original image in terms of width and height?

I tested on to many sizes images, and effect is the same(Sample sizes: 3264x2448, 1746x1181).

Strange, I guess it has to do with the way phpThumb auto-calculates the ratio of an image when using resize(). The original docs may be helpful: https://github.com/masterexploder/PHPThumb/wiki/Basic-Usage

Hi Haensel

I am not sure what I am doing wrong; I have placed the phpThumb within components in main.php; I can now choose the ePHPThumb widget and specify the folder where images should be stored (tried the default location and other folders with permission 755).Users can choose and upload images to their profile (images ARE stored on server), but no one can actually see the images. I am not even getting any error even when uploading images.

What could have missed, since images are not visible? Thanks!

Could you please post your code (the part where you are using phpThumb to save the images) because I am not sure what you mean. You don’t see the image files or the image files don’t render in browsers?

Btw.: 755 will only make sense if the owner of the folder is the webserver process (e.g.: www-data)


I’m trying to use ephpthumb extension.

After editing the config/main.php file and put the code below in my controller - create action like this:

$thumb = Yii::app()->phpThumb->create(Yii::app()->baseUrl.'/images/articoli/'.$model->image);



I get this CException:

I think (of course) I have to put EPhpThumb in /extension but which files?

Thaank you

EDIT: resolved just copying the EPhpThumb folder in /extension :) Oh holy ignorance!

How can i make resize imahe thumb without saving, from remote url like: http:// example.com/avatar.png