Welcome Guest, Not a member yet? Register   Sign In
Help understanding image_lib - resizing?!
#2

[eluser]tonanbarbarian[/eluser]
One of the strange characteristic I have noticed with the image library (and most of the core CI libraries that have config options) is that if you do not specify an option it resets to the default.

The reason you need to copy is you are not setting the new image config option, so it is trying to modify the original
You can either set the new image config option or use the create thumb option. Using create thumb will rename the file and put _thumb into the filename.

So here is what I would try
Code:
function generateThumbnail($source, $output, $width, $height, $watermark = true) {
        $base =& get_instance();
        $dir = dirname($output);
        if(!is_dir($dir))
            recursive_mkdir($dir);
            
        $config['library_path'] = '';
        $config['source_image'] = $source;
        $config['new_image'] = $source;
        $config['maintain_ratio'] = TRUE;
        $config['quality'] = 100;
        $config['width'] = (int)$width;
        $config['height'] = (int)$height;
            
        $base->load->library('image_lib', $config);
        if(!$base->image_lib->resize())
            die($base->image_lib->display_errors());
        
        if($watermark)
            applyWatermarkToImage($output);    
        
    }
I think this should do what you want. It should create a new image at the correct size. Without the new image all it was doing was resizing the image inside the old image thus the black border.

When working with this library my suggestion to to copy all of the config options listed in the user guide
http://ellislab.com/codeigniter/user-gui...e_lib.html
and set them as you think they should be until it displays as you expect, then remove those that you think are not needed until you have just the options that are needed to display correctly.


Messages In This Thread
Help understanding image_lib - resizing?! - by El Forum - 12-10-2007, 02:44 PM
Help understanding image_lib - resizing?! - by El Forum - 12-10-2007, 03:10 PM
Help understanding image_lib - resizing?! - by El Forum - 12-11-2007, 01:37 AM
Help understanding image_lib - resizing?! - by El Forum - 12-11-2007, 11:45 AM
Help understanding image_lib - resizing?! - by El Forum - 12-11-2007, 11:57 AM
Help understanding image_lib - resizing?! - by El Forum - 12-11-2007, 12:12 PM
Help understanding image_lib - resizing?! - by El Forum - 12-11-2007, 03:14 PM
Help understanding image_lib - resizing?! - by El Forum - 12-11-2007, 03:17 PM
Help understanding image_lib - resizing?! - by El Forum - 12-11-2007, 03:26 PM



Theme © iAndrew 2016 - Forum software by © MyBB