Part of the EllisLab Network

Bug Report

Bug with imglib

Date: 07/19/2008 Severity: Minor
Status: Resolved Reporter: Bramme
Version: 1.6.3
Keywords: Libraries, Image Manipulation Class

Description

I’m using the imglib for a portfolio backend. Images have to be 450px wide, they get resized if they’re too big or enlarged when too small. When the resize is made, a thumbnail is copied from it and the first one is watermarked.

When uploading a new batch pictures that I had resized before uploading, the whole process failed because the first resize threw an error. I suppose the error was caused because the image had the same size as the “resize to” size.

Is this intentional, because I would think it’d be more logical to just make a copy then and pretend there’s nothing wrong.

Expected Result

Actual Result

Comment on Bug Report

Page 1 of 1 pages
Posted by: Bramme on 19 July 2008 6:09am
Bramme's avatar

sorry, this isn’t in the svn but in version 1.6.3, forgot to change that.

Posted by: Derek Allard on 19 July 2008 8:10am
Derek Allard's avatar

OK Bramme, so I know something went wrong for you, but what is the bug you are reporting?  (I’ve changed the version to 1.6.3 for you).

Posted by: Bramme on 20 July 2008 5:36am
Bramme's avatar

function process_uploaded_image($filename){
    
    $large_path
= $this->config->item('portfolio_path').$filename;
    
$thumb_path = $this->config->item('thumbs_path').$filename;
    
    
//get image size
    
$img_size = getimagesize($large_path);
    
$orig_width = $img_size[0];
    
$orig_height = $img_size[1];
    
    if(
$orig_width > $orig_height) {
    
//horizontal picture
        
$res_width = 450;
        
$res_height = 10;
        
$set_master_dim = 'width';
    
} else {
    
//vertical picture
        
$res_width = 10;
        
$res_height = 400;
        
$set_master_dim = 'height';
    
}
    
    
//resizing the uploaded image
    
$resize_config['image_library'] = 'gd2';
    
$resize_config['source_image'] = $large_path;
    
$resize_config['maintain_ratio'] = TRUE;
    
$resize_config['width'] = $res_width;
    
$resize_config['height'] = $res_height;
    
$resize_config['master_dim'] = $set_master_dim;
    
    
$this->load->library('image_lib', $resize_config);
    
    if (!
$this->image_lib->resize()) {
        
echo "error at first resize";
        echo
$this->image_lib->display_errors();
        return
false;
    
}
    
// method continues

Where you see “error at first resize” the script throws an error “The image copy routine failed.”. Though the image is correctly copied, the script throws this error, presumably because the original image width was equal to the width it had to be resized to.

Though because the imglib returns false here (because of the error) the rest of my method fails, while actually it should continue: the image I wanted was correctly copied, even if it wasn’t technically resized.

I think the imglib should pretend like there’s nothing wrong and return true when it just copies the original image.

Posted by: onejaguar on 24 September 2008 4:37pm
onejaguar's avatar

I think there is problem in the library if you have not specified a new_image. The default value of new_image is ‘’. This line is used to see if a resize is necessary:

if (($this->orig_width == $this->width AND $this->orig_height == $this->height) AND ($this->source_image != $this->new_image))

And since source_image != ‘’ it tries to copy source image to a file named ‘’ which of course is not possible. The library code should probably be changed to:

if ($this->orig_width == $this->width AND $this->orig_height == $this->height)
{
  
if ($this->full_src_path == $this->full_dst_path)
  
{
    
return TRUE;
  
}

Name:

Email:

Location:

URL:

Remember my personal information

Notify me of follow-up comments?