GithubHelp home page GithubHelp logo

imagefly's Introduction

Imagefly for Laravel 6 / 7

This module allows you to quickly create resized / cropped images directly through url parameters.
Modified images are cached after the initial request and served up thereafter to help reduce server strain.

Compatibility

Imagefly currently works with Laravel 6.x and 7.x

Installation

Install using composer:

composer require ivliev/imagefly

Add the service provider in app/config/app.php:

Ivliev\Imagefly\ImageflyServiceProvider::class,

And add the Imagefly alias to app/config/app.php:

'Imagefly' => Ivliev\Imagefly\Facades\Imagefly::class,

Configuration

The default config file is located in vendor/ivliev/imagefly/src/config/imagefly.php
You should copy this file to /config/imagefly.php or using artisan:

php artisan vendor:publish

and make changes there, in keeping with the cascading filesystem.

Configuration Options

cache_expire: 604800
Number of seconds before the browser checks the server for a new version of the modified image.

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

mimic_source_dir: TRUE
Mimic the source file folder structure within the cache directory.
Useful if you want to keep track of cached files and folders to perhaps periodically clear some cache folders but not others.

quality: 80
The default quality of images when not specified in the URL.

scale_up: FALSE
If the image should be scaled up beyond it's original dimensions on resize.

enforce_presets: FALSE
Will only allow param configurations set in the presets
Best enabled on production sites to reduce spamming of different sized images on the server.

presets
Imagefly params that are allowed when enforce_presets is set to TRUE
Any other param configuration will throw a 404 error.

// Example presets
'presets' => array(
    'w320-h240-c',
    'w640-w480-q60'
)

Usage Examples

Here are some examples of what you can do with Imagefly.

Resize to exactly 100px width and height cropping from the center
<img src="/imagefly/w100-c/path/to/image.jpg"> OR <img src="/imagefly/h100-c/path/to/image.jpg">

Resize to exactly 100px width and 150px height cropping from the center
<img src="/imagefly/w100-h150-c/path/to/image.jpg">

Resize proportionally until width is 100 pixels
<img src="/imagefly/w100/path/to/image.jpg">

Resize proportionally until height is 100 pixels
<img src="/imagefly/h100/path/to/image.jpg">

Resize proportionally until either the width or height is 100 pixels, whichever comes first
<img src="/imagefly/w100-h100/path/to/image.jpg">

Resize automatically proportionally until either the width or height is max. 100 pixels
<img src="/imagefly/w100-h100-a/path/to/image.jpg">

Resize proportionally until height is 100 pixels with JPEG quality set to 60
<img src="/imagefly/h100-q60/path/to/image.jpg">

imagefly's People

Contributors

ivliev avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

lukasz1991a

imagefly's Issues

Config error

Argument 1 passed to Intervention\Image\ImageManagerStatic::configure() must be of the type array, null given, called in \vendor\ivliev\imagefly\src\Ivliev\Imagefly\Imagefly.php on line 179 and defined

at line there is
$image->configure(config('image'));
must be
$image->configure(config('imagefly'));

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.