scanerrr/yii2-local-image

Resize images and save to cache.

dev-master 2018-12-23 17:57 UTC

This package is auto-updated.

Last update: 2025-06-24 08:52:16 UTC


README

Simple Yii2 extension for resizing images and saving them to cache

Installation

Add yii2-local-image to the require section of your composer.json file:

{
    "require": {
        "scanerrr/yii2-local-image": "dev-master"
    }
}

Or simply run

php composer.phar require "scanerrr/yii2-local-image @dev"

Usage

Html::img(Image::resize($pathToImage, $width, $height = null));

Resize image with saving aspect ratio, simply miss "height"

Html::img(Image::resize($pathToImage, 120))

/* 
* Original image with resolution 1920x1080
* Result image gonna be 120x67
*/

TODO

  • Add CHANGELOG.md [ ]
  • Implement crop function [ ]
  • Allow to disable caching [ ]
  • Add tests [ ]
  • Add comments [ x ]
  • Add more extensions [ ]
  • Try to rewrite with Imagick [ ]