Php 如何在yii图像扩展中找到图像的宽度和高度
我已经使用图像扩展来调整图像的大小。工作正常。这是代码Php 如何在yii图像扩展中找到图像的宽度和高度,php,yii,yii-extensions,Php,Yii,Yii Extensions,我已经使用图像扩展来调整图像的大小。工作正常。这是代码 $image = Yii::app()->image->load(Yii::getPathOfAlias('webroot').'/files/galaryimages/'.$fileName); $image->resize(900, 600)->quality(75)->sharpen(20); $image->save(); 但我需要调整大小,只有当图像大小大于一个固定的宽度和高度我怎么能
$image = Yii::app()->image->load(Yii::getPathOfAlias('webroot').'/files/galaryimages/'.$fileName);
$image->resize(900, 600)->quality(75)->sharpen(20);
$image->save();
但我需要调整大小,只有当图像大小大于一个固定的宽度和高度我怎么能做到这一点?
使用了以下代码
list($width1, $height1, $type1, $attr1) = getimagesize(Yii::getPathOfAlias('webroot').'/files/images/'.$fileName);
if(($width1>$width) || ($height1>$height))
{
//code to resize
}
您可以通过
宽度
和高度
属性访问它们:
echo $image->width . 'x' . $image->height;
您可能可以获得宽度和高度,如
$image->width()代码>和$image->height()代码>分别为@ThinkDifferent获取致命错误:调用未定义的方法Image::width()