Search code examples
phpyiiyii-extensions

how to find the width and height of an image in image extention in yii


I have used used image extension to resize the image. Its working fine. Here is the Code

 $image = Yii::app()->image->load(Yii::getPathOfAlias('webroot').'/files/galaryimages/'.$fileName);
 $image->resize(900, 600)->quality(75)->sharpen(20);
 $image->save();


but I need to resize only if the image size is greater than a fixed width and height How can I do this?
http://www.yiiframework.com/extension/image/#hh5


Solution

  • Used the below code

    list($width1, $height1, $type1, $attr1) = getimagesize(Yii::getPathOfAlias('webroot').'/files/images/'.$fileName);
     if(($width1>$width) || ($height1>$height))
     { 
         //code to resize 
      }