Coder Social home page Coder Social logo

ci-compress-image's Introduction

Compress Image

Codeigniter Library to Compress Image

This library was developed with the purpose of optimizing the images in size and quality.

How to use

First you need to download the Compress.php file and put inside Codigniter library folder of your project (project/application/libraries)

Inside of your controller or other class that you want to use, add this code:

$this->load->library('Compress');  // load the codeginiter library

$file = 'path/to/file/filename.extension'; // file that you wanna compress
$new_name_image = 'new_name_of_file'; // name of new file compressed
$quality = 60; // Value that I chose
$destination = 'final_path/to/file/'; // This destination must be exist on your project

Initiate the class:

$compress = new Compress();

Add values to each element:

$compress->file_url = $file;
$compress->new_name_image = $new_name_image;
$compress->quality = $quality;
$compress->destination = $destination;

And finally let the library do the rest for you:

$result = $compress->compress_image();

Result

The library will always return for you a array with this specific data:

Item Description Examples
image New name of compressed image eg.: new_file_name.extension
real_file_path Real file path of a compressed image eg.: X:/path/to/folder/of/project/new_file_name.extension
url_file_path Site url file of a compressed image eg.: http://url/to/project/folder/new_file_name.extension

Don't use CI to create your projects?

You can use this composer library that I've created, it's almost the same thing.

ci-compress-image's People

Contributors

eihror avatar

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.