image-helper not working on mac


I downloaded

and while looping through the database, if a image does not exists, it bombs.

I tried file_exists, but it is not finding any images.

What can I do to get this working, or is there another image resize extension?


Have you done it directly with PHPThumb?

Here I explain how to use it!

How to use PHPThumb Library with Yii

Hope it helps you!

Thanks for posting this.

That was my next todo, uploading files.

I will try this tonight on my mac.


I followed your instructions, but the image is moved and not resized.


       ->save(Yii::getPathOfAlias('webroot.img3') .'/'.


Hi Frocco,

Can I see the whole code buddy? Then I will be able to help you

Also, image size is bigger than desired sizes?

** I am currently using this extension to resize in four different sizes and it works to perfection. I am also developing on Mac; noooo worries.

Here is my code, thanks


foreach ($results as $row)


		$picture_name = $row->imagePath;

		$tmpPicture =  Yii::getPathOfAlias('webroot.img') . "/" . $row->imagePath;

		if (!empty($picture_name) && file_exists($tmpPicture)) 


		$thumbFactory = PhpThumbFactory::create($tmpPicture);

		$thumbFactory->resize(125, 125)->save(Yii::getPathOfAlias('webroot.img2') .'/'. $picture_name);


What mac do you have?

macbook pro 17" running Leopard (Mac OS X 10.6.4 (10F569))

mmmm… your code seems ok. Pleae review your images sizes as remember, PHPThumb does resize from big to smaller sizes. Otherwise it does nothing!

Check my code and it works -see that i do resize from big to small but the picture is already bigger than the bigest size!

$thumbFactory = PhpThumbFactory::create($tmpPicture);


$thumbFactory->resize(569)->cropFromCenter(569,285)->save(Yii::getPathOfAlias('mypath') .'/'. $picture_name);

$thumbFactory->resize(572)->cropFromCenter(572,335)->save(Yii::getPathOfAlias('mypath') .'/'. $picture_name);

One thing that I do is that when is that if the width and height are the same I do:


>>Otherwise it does nothing!<<

Ok, I did not know that.

I need to resize images to 125, 125 for a consistent look in my listing.

Is there another yii extension?

But frocco,

If you don’t have your images bigger than the size you wish to resize then its quality will be poor. If they are smaller in ‘both sides’ then use just the HTML to do it, it will look horrible though.

If it is one side bigger than the other you can use the method adaptiveResize of PHPThumb then it will try to resample the image to the dimensions…

I don’t really understand, what are the actual image size you wish to resize?

The size can vary depending on what the user uploads.

Maybe I am going about this the wrong way.

I just want to allow the user to upload images, save them to a directory, save the picture name in a database and display the images in a list.


This is what I am actually doing!

I highly recommend you that you suggest your users to upload images bigger than 125x125 and less than xMB. I am sure you have a filter that checks whether the image is such and such, here is mine:

public static function validateUploadedPicture( CUploadedFile $file, $maxWidth, $maxHeight, $minWidth, $minHeight, $mimeTypes ){


$info = @getimagesize( $file->getTempName() );


// remove unnecessary values from $info and make it more readable

$info = array(

	'width' => $info[0],

	'height' => $info[1],

	'mime' => $info['mime'],



	if ($info['width'] < $minWidth) {

		return self::MIN_WIDTH_ERROR;


	if ($info['width'] > $maxWidth) {

		return self::MAX_WIDTH_ERROR;	


	if ($info['height'] < $minHeight) {

		return self::MIN_HEIGHT_ERROR;


	if ($info['height'] > $maxHeight) {

		return self::MAX_HEIGHT_ERROR;



        $mimeTypes = is_scalar($mimeTypes) ? array($mimeTypes) : $mimeTypes;

	if (!in_array($info['mime'], $mimeTypes)) {

		return self::MIME_TYPE_ERROR;


	return self::PICTURE_VALID;



I call this function (i have my own constants as you see) I know that the image is ready to upload (I tried to use EPhotoValidator but no luck with it). Then, when I know that the file is ok to continue I do the resizing…

Thanks for sharing, I understand what you are saying and will look at the previous images I need to convert.