Image 如果源图像宽度/高度小于拇指宽度/高度,则不要创建拇指

Image 如果源图像宽度/高度小于拇指宽度/高度,则不要创建拇指,image,codeigniter,thumbnails,Image,Codeigniter,Thumbnails,我在想codeigniter图像类是内置的还是自动跳过创建thumb 如果源图像的宽度/高度小于您设置的拇指宽度/高度 若否,如何处理 我已经完成了缩略图生成,但是如果我上传了一张宽:200px高:200px的图片 我的拇指设置为宽度:400px高度:400px拇指仍将创建和制作拇指 看起来糟透了 编辑 $config['config_here']; $this->load->library('image_lib', $config); if($arr['image_width']

我在想codeigniter图像类是内置的还是自动跳过创建thumb 如果源图像的宽度/高度小于您设置的拇指宽度/高度

若否,如何处理

我已经完成了缩略图生成,但是如果我上传了一张宽:200px高:200px的图片 我的拇指设置为宽度:400px高度:400px拇指仍将创建和制作拇指 看起来糟透了

编辑

$config['config_here'];
$this->load->library('image_lib', $config);

if($arr['image_width'] <= $config['width'] && $arr['image_height'] <= $config['height'])     {
//I don't want to resize the image BUT I want it to copy to a filename with thumb_marker
//How to do it because I already have the $config['create_thumb'] = TRUE; at above.
}else{
   $this->image_lib->resize();
}
$config['config_here'];
$this->load->library('image_lib',$config);

如果($arr['image_width']您可以在调整大小之前检查大小:

// get image sizes
list($width, $height) = getimagesize($config['source_image']);

// is wide enough?
if ( intval($width) < 400 ) {
    throw new Exception("Your image's height must be equal or greater than 400px");
}

// is high enough?
if ( intval($height) < 400 ) {
    throw new Exception("Your image's width must be equal or greater than 400px");
}

// now we can resize
$this->image_lib->resize();
//获取图像大小
列表($width,$height)=getimagesize($config['source_image']);
//够宽吗?
如果(内部值($width)<400){
抛出新异常(“您的图像高度必须等于或大于400px”);
}
//够高吗?
如果(内部值($height)<400){
抛出新异常(“图像的宽度必须等于或大于400px”);
}
//现在我们可以调整大小了
$this->image_lib->resize();

您可以在调整大小之前检查大小:

// get image sizes
list($width, $height) = getimagesize($config['source_image']);

// is wide enough?
if ( intval($width) < 400 ) {
    throw new Exception("Your image's height must be equal or greater than 400px");
}

// is high enough?
if ( intval($height) < 400 ) {
    throw new Exception("Your image's width must be equal or greater than 400px");
}

// now we can resize
$this->image_lib->resize();
//获取图像大小
列表($width,$height)=getimagesize($config['source_image']);
//够宽吗?
如果(内部值($width)<400){
抛出新异常(“您的图像高度必须等于或大于400px”);
}
//够高吗?
如果(内部值($height)<400){
抛出新异常(“图像的宽度必须等于或大于400px”);
}
//现在我们可以调整大小了
$this->image_lib->resize();

您可以在操作前检查图像尺寸 试试这个


您可以在操作前检查图像尺寸 试试这个


我认为您需要扩展库$this->orig_width>$this->width或height的图像库签入调整大小方法,然后您需要调整它的大小。它将work@umefarooq你能再次看到我编辑的问题吗?我想你需要扩展库$this->orig_width>$this->width或height的resize方法中的图像库检查,然后你需要调整大小是的,会的work@umefarooq你能再次看到我编辑的问题吗?