Welcome Guest, Not a member yet? Register   Sign In
resize images using image library (hit or miss) (works sometimes) (tempramental)
#1

[eluser]Unknown[/eluser]
I am using the code below which is basically from a NETTUTS tutorial on image upload and manipulation. It works on 95% of the images I upload. The problem is this: certain images won't resize to a thumbnail using $this->image_lib->resize();

The code uploads the image, resizes it for a thumbnail gallery, and stores the full size image in another directory. Like I said, 95% of the time it works, but the other 5% of the time, the image won't resize to a thumbnail.

My testing demonstrates that it's only certain images that have a problem. For example, if an image works it works every time. If an image fails to work it will never work. There is nothing to indicate that the image file is corrupt. The images that won't resize seem to view fine in Windows Explorer or Picture Viewer. To the normal end user, he or she would experience the same thing: some images will upload and resize, some will not. Below is a snippet of the thumbnail code.

I've tried searching the net, and autoloading the image library, adding the 'gd2' explicitly, but the behavior of the codeigniter app has been unchanged: some files work and some don't.

Code:
$config = array(
   'source_image' => $image_data['full_path'],
   'new_image' => $this->gallery_path . '/thumbs',
   'maintain_ratio' => true,
   'width' => 150,
   'height' => 100,
   'image_library' => 'gd2'
  );
  
  // $this->load->library('image_lib', $config);
  $this->image_lib->initialize($config);
  $this->image_lib->resize();

Is this a bug?




Theme © iAndrew 2016 - Forum software by © MyBB