Don't resize when image smaller

See all posts Reply

Don't resize when image smaller new!
by Erwin, 16 years, 1 month ago
Hi,

I have build in the class to resize a images. But nog i have some images that don't have to be resized when they are smaller. What class variabel do i have to add to it the? I now have the following:
$foo->allowed = array('image/*');
$foo->file_new_name_body = $fotoid.'groot';	  
$foo->image_resize = true;
$foo->image_convert = jpg;
$foo->image_x = 800;
$foo->image_ratio_y = true;
$foo->Process('/home/site/website.nl/public_html/map/');

So what do i need to add to make sure that smaller images won't be resized to the image_x of 800?

ErwinReply
Re: Don't resize when image smaller new!
by colin, 16 years, 1 month ago
Either you use image_ratio_no_zoom_in, same as image_ratio, but won't resize if the source image is smaller than image_x x image_y (default: false)
$handle->image_ratio_no_zoom_in = true;

Or else, if you don't want to explicitely set image_y, you can read some variables before calling Process(), such as image_src_x, image_src_y and image_src_type and depending on the values, you do a resizing or not.Reply
Re: Don't resize when image smaller new!
by Farhan, 15 years, 9 months ago
I tried to use the class like your 1st suggestion,

$handle->image_ratio_no_zoom_in = true;
but the smaller size were also resized.

So, I use your 2nd suggestion,
if(($handle->image_src_x < 800) 
   || ($handle->image_src_y < 600)){
    $handle->image_resize          = false;
} else {
    $handle->image_resize          = true;
    $handle->image_x	          = 800;
    $handle->image_ratio_x        = true;
}

But the file were not resized, the bigger file also!
I echoed the value for $handle->image_src_x & $handle->image_src_y, both have 0 value. I remove assignment = 0 in the class, then the value is nothing.

Would you suggest anything I could do to solve this?Reply
Re: Don't resize when image smaller new!
by colin, 15 years, 9 months ago
Could you paste here the logs from the class? Would you have a open_basedir restriction in place by any chance?Reply