Welcome Guest, Not a member yet? Register   Sign In
saving external image and creating thumbnail locally problem
#1

[eluser]lexusgs430[/eluser]
Hi,

I have a database filled with links to external images, Id like to save those images locally and resize them to a thumbnail size. Im having trouble doing that. ive verified that the image link being passed to my function are correct, but it doesen't want to create the image on my server it seems (made sure priveleges were at 777 for the folder.

Any help would be much appreciated.

(Note that I am loading this as a helper)

Code:
<?php

function image_thumb($image_link, $height, $width, $image_name)
{
    // Get the CodeIgniter super object
    $CI =& get_instance();

    // Path to image thumbnail
    $base = base_url();
    $image_thumb = $image_link;
    $new_src = $base."images/".$image_name.".jpg";


    if( ! file_exists($image_thumb))
    {
        // LOAD LIBRARY
        $CI->load->library('image_lib');

        // CONFIGURE IMAGE LIBRARY
        $config['image_library']    = 'gd2';
        $config['source_image']        = $image_link;
        $config['new_image']        = $new_src;
        $config['create_thumb'] = TRUE;
        $config['maintain_ratio']    = TRUE;
        $config['height']            = $height;
        $config['width']            = $width;
        $CI->image_lib->initialize($config);
        $CI->image_lib->resize();
        $CI->image_lib->clear();
    }

    return '<img src="' . $new_src . '" />';
}


Messages In This Thread
saving external image and creating thumbnail locally problem - by El Forum - 06-21-2010, 12:13 PM



Theme © iAndrew 2016 - Forum software by © MyBB