Welcome Guest, Not a member yet? Register   Sign In
quick image manipulation for prototyping
#1

[eluser]Loque[/eluser]
Hey all,

I am building a simple website for my sisters degree show (to save her hardcoding something nasty in a wysiwyg editor for over 120 students) and have everything going well, but we are not sure what size images we want to use in the front-end and was looking into using the image manipulation tools from CI to resize images as thumbnails whilst we prototype, and then do some batch jobs on images later to save the server load (altho, to be fair I dont anticipate much traffic)

I have built a few CI sites in the past (and love it) but I dont really know PHP (I am a humble front end dev) and was hoping I could push something together so that our view calls something like this:

$this->imageManip('path/to/img.jpg', '50', '50'); (and have it return my sexy resized image)

is it possible? I found an example function: http://ellislab.com/forums/viewthread/137593/

EDIT: long winded request for assistance finding a helper/documentation for an image helper.

Many thanks!
Loque
#2

[eluser]Loque[/eluser]
going to see if this helps me:

http://www.derekallard.com/blog/post/mos...lper-ever/

hrhrhr, loving the name :¬P

apologies for the spam ~
#3

[eluser]umefarooq[/eluser]
Hi try this helper will help you to solve your problem it will create copy of your desire thumb size even crop thumbnail also

Code:
function image_thumb($image_path, $height, $width,$crop = FALSE,$ratio = TRUE) {
        // Get the CodeIgniter super object
        $CI =& get_instance();
        $ext = strchr($image_path, '.');
        $file_name = substr(basename($image_path), 0, -strlen($ext));
        // Path to image thumbnail
        $image_thumb = dirname($image_path) . '/'.$file_name.'_' . $height . '_' . $width . $ext;

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

            // CONFIGURE IMAGE LIBRARY
            $config['image_library']    = 'gd2';
            $config['source_image']        = $image_path;
            $config['new_image']        = $image_thumb;
            $config['maintain_ratio']    = $ratio;
            $config['height']            = $height;
            $config['width']            = $width;
            $CI->image_lib->initialize($config);
            if($crop)
            $CI->image_lib->crop();
            else
            $CI->image_lib->resize();
            $CI->image_lib->clear();
        }

        return img($image_thumb);
    }

original version of helper is on following link but only for jpg but above will work for all extensions

Image thumb
#4

[eluser]Loque[/eluser]
Thanks so much, this is perfect! Words cannot describe how perfect this is actually :¬)

Loque

Edit: that's a really nice blog too, very helpful...




Theme © iAndrew 2016 - Forum software by © MyBB