2017 © Pedro Peláez
 

library imgproxy

An image proxy for Laravel

image

spescina/imgproxy

An image proxy for Laravel

  • Tuesday, October 14, 2014
  • by simonpex
  • Repository
  • 2 Watchers
  • 18 Stars
  • 1,109 Installations
  • PHP
  • 0 Dependents
  • 1 Suggesters
  • 4 Forks
  • 4 Open issues
  • 15 Versions
  • 2 % Grown

The README.md

Build Status Coverage Status, (*1)

ImageProxy

Laravel 4 package for image cropping and resizing on the fly. It uses Timthumb under the hood., (*2)

Install && Usage

Add in composer.json, (*3)

"require": {
    "spescina/imgproxy": "2.x"
}

Run composer update, (*4)

Add the service provider in the app/config/app.php file, (*5)

"Spescina\Imgproxy\ImgproxyServiceProvider"

Publish the package assets running php artisan asset:publish spescina/imgproxy, (*6)

Publish the package config running php artisan config:publish spescina/imgproxy, (*7)

ImageProxy is configured to use Apache by default. If you are using nginx, add the following to your site configuration file:, (*8)

rewrite ^/packages/spescina/imgproxy/([0-9]+)/([0-9]+)/([0-9]+)/([0-9]+)/(.*) /packages/spescina/imgproxy/timthumb.php?w=$1&h=$2&zc=$3&q=$4&src=$5;

Use the package facade to generate the resource url, (*9)

ImgProxy::link("path/to/image.jpg", 100, 80)

This will generate a link like this, (*10)

http://www.yourdomain.com/packages/spescina/imgproxy/100/80/path/to/image.jpg

that generates an image with dimensions 100 x 80 using the original image.jpg stored in the public/path/to folder., (*11)

Parameters

The link function accepts 5 paramaters * image path * width * height * quality - optional [0..100] - Default: 90 * zoom/crop - optional [0,1,2,3] - Default: 1, (*12)

Zoom/Crop

These are the supported values * 0 - Resize to Fit specified dimensions (no cropping)
* 1 - Crop and resize to best fit the dimensions (default) * 2 - Resize proportionally to fit entire image into specified dimensions, and add borders if required * 3 - Resize proportionally adjusting size of scaled image so there are no borders gaps, (*13)

Config

Package config

After publishing the package config file it's possible to change the package behaviour in the app/config/packages/spescina/imgproxy/config.php file., (*14)

These are the current options: * rewrite - Default: true - If false querystring uri are generated instead of pretty ones, (*15)

Timthumb config

It's possible to edit timthumb config in the public/packages/spescina/imgproxy/timthumb-config.php file., (*16)

These, at the moment, are the default values, (*17)

define ("DEBUG_ON", false);

define ("DEBUG_LEVEL", 3);

define ("FILE_CACHE_MAX_FILE_AGE", 86400);

define ("FILE_CACHE_SUFFIX", ".imgproxy.cache");

define ("FILE_CACHE_PREFIX", "");

define ("FILE_CACHE_DIRECTORY", "../../../../app/storage/cache/imgproxy");

define ("NOT_FOUND_IMAGE", "./nophoto.gif");

define ("ERROR_IMAGE", "./nophoto.gif");

define ("PNG_IS_TRANSPARENT", FALSE);

define ("DEFAULT_Q", 90);

Full nginx example for Laravel Forge

server {
    rewrite_log on;

    listen 80;
    server_name my_site.com;
    root /home/forge/my_site.com/public;

    auth_basic "Restricted";
    auth_basic_user_file /home/forge/my_site.com/public/.htpasswd;

    # FORGE SSL (DO NOT REMOVE!)
    # ssl on;
    # ssl_certificate;
    # ssl_certificate_key;

    index index.html index.htm index.php;

    charset utf-8;

    location / {
        rewrite ^/packages/spescina/imgproxy/([0-9]+)/([0-9]+)/([0-9]+)/([0-9]+)/(.*) /packages/spescina/imgproxy/timthumb.php?w=$1&h=$2&zc=$3&q=$4&src=$5;
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    error_log  /var/log/nginx/my_site.com-error.log error;

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }
}

The Versions

14/10 2014

dev-master

9999999-dev

An image proxy for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Simone Pescina

laravel image proxy crop resizer

14/10 2014

2.1.6

2.1.6.0

An image proxy for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Simone Pescina

laravel image proxy crop resizer

14/10 2014

dev-develop

dev-develop

An image proxy for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Simone Pescina

laravel image proxy crop resizer

06/06 2014

2.1.5

2.1.5.0

An image proxy for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Simone Pescina

laravel image proxy crop resizer

28/04 2014

2.1.4

2.1.4.0

An image proxy for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Simone Pescina

laravel image proxy crop resizer

14/04 2014

2.1.3

2.1.3.0

An image proxy for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Simone Pescina

laravel image proxy crop resizer

14/04 2014

2.1.2

2.1.2.0

An image proxy for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Simone Pescina

laravel image proxy crop resizer

14/04 2014

2.1.1

2.1.1.0

An image proxy for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Simone Pescina

laravel image proxy crop resizer

11/04 2014

2.1.0

2.1.0.0

An image proxy for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Simone Pescina

laravel image proxy crop resizer

11/04 2014

2.0.2

2.0.2.0

An image proxy for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Simone Pescina

laravel image proxy crop resizer

11/04 2014

2.0.1

2.0.1.0

An image proxy for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Simone Pescina

laravel image proxy crop resizer

11/04 2014

2.0.0

2.0.0.0

An image proxy for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Simone Pescina

laravel image proxy crop resizer

11/04 2014

1.0.2

1.0.2.0

An image proxy for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Simone Pescina

laravel image proxy crop resizer

10/04 2014

1.0.0

1.0.0.0

  Sources   Download

The Requires

 

by Simone Pescina

10/04 2014

1.0.1

1.0.1.0

  Sources   Download

The Requires

 

by Simone Pescina