Coder Social home page Coder Social logo

codeigniter-image-cache's Introduction

CodeIgniter Image Cache

CodeIgniter library to generate and cache images on the fly.

Setup

  1. Edit config/image_cache.php file with appropiate settings
  2. Copy config, controller and model file to your CodeIgniter installation
  3. Load config/image_cache.php file in your config/autoload.php
  4. Create a directory for images and give CodeIgnite write permissions

Settings

Parametres inside config/image_cache.php

  • ic_upload_directory → Directory, from root application, where Image Cache will look for the source images
  • ic_resize_limit → Maximum number of versions that Image Cache will create of each image

How it works

Image Cache listens the “/img” requests with ‘w’ and ‘h’ get URL parameteres, look if there’s a cache version available and if not, creates it on the fly and saves it. You can call the images with parameters from the template itself.

To avoid brute force attacks, you can set a limit of versions of each image that Image Cache will create.

Call the image without parameters shows a 404 error.

Example of use

Call an image from your templates with ‘w’ and ‘h’ get URL parameteres. Image Cache will create an image with the size, filling all the pixels from the source image.

Resize + Crop:
<img src=“/img/picture_1.jpg?w=500&h=300” />

Resize:
<img src=“/img/picture_2.jpg?w=700” />
<img src=“/img/picture_2.jpg?h=400” />

You can call for images in subdirectories as well:
<img src=“/img/news/new_1/picture_1.jpg?w=500&h=300” />

codeigniter-image-cache's People

Contributors

joaquinmarti avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

codeigniter-image-cache's Issues

Did not compress image?

I will compress image width 4000px to 300px
But, I get this error message:


Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 16384 bytes) in /home/panglim3/public_html/system/libraries/Image_lib.php on line 1466

Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 16384 bytes) in /home/panglim3/public_html/system/core/Exceptions.php on line 267

Any solution?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.