2017 © Pedro Peláez
 

kohana-module kohana-imagecache

A Kohana module for create resized / cropped images.

image

validoll/kohana-imagecache

A Kohana module for create resized / cropped images.

  • Friday, October 17, 2014
  • by validoll
  • Repository
  • 2 Watchers
  • 3 Stars
  • 12 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 27 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

ImageCache

This module allows you to quickly create resized / cropped images. Modified images are cached after the initial request and served up thereafter to help reduce server strain,and also available, even when ImageCache switch off, on the same URL which was generated., (*1)

Compatibility

ImageCache currently works with Kohana 3.2 and 3.3, (*2)

Getting Started

In your application/bootstrap.php file modify the call to Kohana::modules and include the image and imagecache modules., (*3)

Kohana::modules(array(
    ...
    'image'    => MODPATH.'image',
    'imagecache' => MODPATH.'imagecache',
    ...
));

[!!] The image module is requried for the ImageCache module to work., (*4)

Configuration

The default config files is located in MODPATH/imagecache/config/*. - Main configuration - MODPATH/imagecache/config/imagecache.php - Configuration patterns for modify images - MODPATH/imagecache/config/imagecache_patterns.php, (*5)

You should copy this files to APPPATH/config/* and make changes there, in keeping with the cascading filesystem., (*6)

Configuration Options (imagecache.php)

Empty or undefined options will always fallack to their defaults., (*7)

cache_expire: 604800 Number of seconds before the browser checks the server for a new version of the modified image., (*8)

cache_dir: 'cache/' Path to the image cache directory you would like to use, don't forget the trailing slash!, (*9)

quality: 80 The default quality of images when not specified in the URL., (*10)

scale_up: FALSE If the image should be scaled up beyond it's original dimensions on resize., (*11)

default_image: FALSE Default image if the requested image is not available. For example:, (*12)

'default_image'    => 'files/misc/default.png',

watermarks Configure one or more watermarks. Each configuration key can be passed as a param through an Imagefly URL to apply the watermark., (*13)

If no offset is specified, the center of the axis will be used. If an offset of TRUE is specified, the bottom of the axis will be used., (*14)

// Example watermarks
'watermarks' => array(
    'first_watermark' => array(
        'image'    => 'path/to/first/watermark.png',
        'offset_x' => TRUE,
        'offset_y' => TRUE,
        'opacity'  => 80
    ),
    'second_watermark' => array(
        'image'    => 'path/to/second/watermark.png',
        'offset_x' => 5,
        'offset_y' => 5,
        'opacity'  => 50
    )
)

Patterns configuration (imagecache_patterns.php)

Example of pattern settings:, (*15)

'thumb' => array(
   'width' => '50%',
   'height' => '50px',
   'crop' => TRUE,
   'quality' => 80,
   'watermark' => 'custom_watermark',
),

width Width of cached image. Allow 'px' or '%' suffix., (*16)

height Height of cached image. Allow 'px' or '%' suffix., (*17)

crop Use crop for cached image. If 'FALSE', then use scale., (*18)

quality Quality of cached image., (*19)

watermark Name of one of watermark from the main config file., (*20)

Usage Examples

Here are some examples of what you can do with ImageCache., (*21)

At first set path of cache dir in your imagecache.php. For example:, (*22)

'cache_dir' => 'files/imagecache/',

At second set at least one pattern in your imagecache_patterns.php. For example:, (*23)

'thumb' => array(
    'width' => '80',
    'height' => '80',
    'crop' => TRUE,
),

Use this path for get resized image <img src="/files/imagecache/thumb/path/to/image.jpg">, (*24)

Notes

  • This is project based on Imagefly by Fady Khalife
  • ImageCache will not process images when the width and height prams are the same as the source
  • Don't forget to make your cache directory writable.
  • Inspired by the smart-lencioni-image-resizer by Joe Lencioni

The Versions

17/10 2014

dev-master

9999999-dev

A Kohana module for create resized / cropped images.

  Sources   Download

MIT

The Requires

 

framework image kohana imagecache