Image helper |
[eluser]sumanchalki[/eluser]
I made an image resizing helper to help resize images with exact width or height supplied by user, using Codeigniter's Image library. Image will be cropped if needed. It can be configured to crop from different positions of the image. Usage Code: $this->upload_image = BASEPATH.'../uploads/abc.jpg'; In the above example, $config['crop'] = true, means image will be cropped, otherwise it has to be used as background of a div, no cropping will happen. $config['crop_from'] = 'middle' means cropping will happen from middle; it behaves differently for landscape (width will be cropped) or portrait (height will be cropped) images. The detail configuration is as follows: @param array $config $config['source_image'] -> source image $config['thumb_marker'] -> thumb_marker $config['width'] -> resize width $config['height'] -> resize height $config['within_rectangle'] -> true/false, default false, if true, $config['crop']=false, config['small_image_resize']='inside'/'no_resize' $config['crop'] -> true/false, default false, decides file will be croped as well or only used in the background of a div $config['crop_from'] -> 'start'/'middle'/'end', default start $config['small_image_resize'] -> 'inside'/'bigger'/'no_resize', default bigger I am using it for my projects and find it is very useful. I checked an open source image manipulation library: http://wiki.github.com/masterexploder/PH...asic-usage But it has some limitations, which I tried to cover. Dependencies It uses two functions namely getThumbName() and getSmallerDimension() which are included in the attached file. Thanks Suman |
Welcome Guest, Not a member yet? Register Sign In |