PHPackages                             afxsoft/phpimagecache - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. afxsoft/phpimagecache

ActiveLibrary[Caching](/categories/caching)

afxsoft/phpimagecache
=====================

Fork of https://github.com/nielse63/php-image-cache using psr-4 autoload and removing unused stuff.

1.0.0(11y ago)034Creative Commons AttributionPHPPHP &gt;=5.3.0

Since Sep 30Pushed 7y ago1 watchersCompare

[ Source](https://github.com/Afxsoft/php-image-cache)[ Packagist](https://packagist.org/packages/afxsoft/phpimagecache)[ Docs](http://nielse63.github.io/php-image-cache)[ RSS](/packages/afxsoft-phpimagecache/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (3)Used By (0)

Image Cache v. 2.0
==================

[](#image-cache-v-20)

Image Cache is a very simple PHP class that accepts an image source and will compress and cache the file, move it to a new directory, and returns the new source for the image.

Installation
------------

[](#installation)

Install [Composer](http://getcomposer.org) by opening Terminal and navigating to the directory in which you'd like to install Image Cache.

Installation Execute this bash command from your project’s root directory:

```
composer require afxsoft/phpimagecache:dev-master

```

Basic Usage The class is pretty small, and very basic. First, include the file and initialize the class:

```
require_once 'ImageCache.php';
$imagecache = new Afxsoft\App\ImageCache();

```

Optional: Set the location of the directory to house your cached images:

```
$imagecache->cached_image_directory = dirname(__FILE__) . '/images/cached';

```

Next, reference the image that you want compressed and store the new image source in a variable. Echo this variable within the 'src' attribute of an image tag:

```
$cached_src = $imagecache->cache( 'images/unsplash1.jpeg' );
///
