2017 © Pedro Peláez
 

symfony-bundle image-proxy-bundle

Base Bundle for OWJA! Image Proxy

image

owja/image-proxy-bundle

Base Bundle for OWJA! Image Proxy

  • Monday, July 31, 2017
  • by hbroer
  • Repository
  • 1 Watchers
  • 1 Stars
  • 11 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 2 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

OWJA! Image Proxy Bundle

Latest Stable Version Latest Unstable Version License Build Status, (*1)

This Bundle is Open Source and under MIT license., (*2)

With this Bundle you can add some Image Resizing and Optimization Functionality to your Symfony Project. After Setup and Configuration you can access the Images on the same, or one or more other Servers, trough this Installation., (*3)

Accessing the images

Preset Mode

enable_presets must be set to true to use this. Default is true., (*4)

http://.../:preset/imagepath, (*5)

Var Value Required Info
preset string yes The preset code
imagepath string yes The public path to the Image

Example to get image "img/someimage.jpg" processed by preset "fullhd": http://example.com/:fullhd/img/someimage.jpg, (*6)

Dynamic Mode

enable_dynamic must be set to true to use this. Default is false., (*7)

IMPORTANT! Dynamic mode should not used in production environment!, (*8)

http://.../type/heightxwidth/imagepath, (*9)

Var Value Required Info
type resize or crop yes Resize will first resize the image to best fit and then crop to destination size.
height integer no Destination height of Image
width integer no Destination width of Image
imagepath string yes The public path to the Image

Examples

Resize and crop the Image to fit into a 100x100 Pixel square, (*10)

http://example.com/resize/100x100/img/someimage.jpg, (*11)

Cropping to fit into a 100x100 Pixel square, (*12)

http://example.com/resize/100x100/img/someimage.jpg, (*13)

Resize to 100 Pixel with and preserve original image Ratio, (*14)

http://example.com/resize/x100/img/someimage.jpg, (*15)

Resize to 100 Pixel height and preserve original image Ratio, (*16)

http://example.com/resize/100x/img/someimage.jpg, (*17)

Optimizations only:, (*18)

http://example.com/resize/x/img/someimage.jpg, (*19)

Installation

$ composer require owja/image-proxy-bundle

Load Bundles in app/AppKernel.php, (*20)

new Oneup\FlysystemBundle\OneupFlysystemBundle(),
new Owja\ImageProxyBundle\OwjaImageProxyBundle(),

Setup your app/config/config.yml, (*21)

oneup_flysystem:
    adapters:
        image_cache_adapter:
            local:
                directory: "%kernel.root_dir%/../var/images"

    filesystems:
        image_cache_filesystem:
            adapter: image_cache_adapter
            alias: owja_image_proxy.cache

owja_image_proxy:
    sites:
        default:
            url: "http://example.com/"

Set "http://example.com/" to the URL representing the source of your images., (*22)

Setup your app/config/routing.yml, (*23)

owja_image_proxy:
    resource: "@OwjaImageProxyBundle/Controller/"
    type:     annotation
    prefix:   /

Create the Directory for temporary Files which gets created while processing the Images:, (*24)

var/temp

Configuration Details

owja_image_proxy:
    remote:
        token: null
        timeout: 10
    limits:
        height: 1080
        width: 1920
    temp_dir: "%kernel.root_dir%/../var/temp/"
    cache_service: "owja_image_proxy.cache"
    optimization: true
    default_site: default
    enable_sites: false
    enable_dynamic: false
    enable_presets: true
CVar Default Info
remote : token null Send by Header 'owja-image-proxy'
remote : timeout 10 Request timeout to get the source image
limits : height 1080 Maximum allowed height of requested Image
limits : width 1920 Maximum allowed width of requested Image
temp_dir "%kernel.root_dir%/../var/temp/" Temporary directory for image processing
cache_service "owja_image_proxy.cache" The name of the cache filesystem (oneup_flysystem)
optimization true Enable/disable image optimization
default_site "default" Code of the default site. Has to be configured under sites
enable_sites false Set to true to enable more than the default site
enable_dynamic false Set to true to enable dynamic mode
enable_presets true Set to true to enable processing predefined presets

Multiple Sites

Simply add some sites and set enable_sites to true, (*25)

owja_image_proxy:
    enable_sites: true
    sites:
        default:
            url: "http://example.com/"
        othersite:
            url: "http://othersite.com/"
        whereever:
            url: "http://wherever.com/"

Accessing the images by sites

Same as explained above ("Accessing the images"), but with site parameter, (*26)

Dynamic Mode

http://.../site/type/widthxheight/imagepath, (*27)

http://example.com/default/resize/100x100/images/someimage.jpg
http://example.com/othersite/resize/100x100/images/someimage.jpg
http://example.com/wherever/resize/100x100/images/someimage.jpg

Preset Mode

http://.../site:preset/imagepath, (*28)

http://example.com/default:fullhd/images/someimage.jpg
http://example.com/othersite:fullhd/images/someimage.jpg
http://example.com/wherever:fullhd/images/someimage.jpg

Presets Configuration

Global Presets:, (*29)

owja_image_proxy:
    enable_presets: true
    presets:
        fullhd:
            width: 1920
            height: 1080
        banner:
            width: 1600
        profile:
            height: 50
            width: 50
        cuthd:
            width: 1280
            height: 720
            type: crop            

Per Site Presets:, (*30)

owja_image_proxy:
    enable_presets: true
    sites:
        default:
            url: "http://example.com/"
            presets:
                fullhd:
                    width: 1920
                    height: 1080
        whereever:
            url: "http://whereever.com/"
            presets:
                banner:
                    width: 1600
                    height: 200

Image Optimization

To enable image optimization you should install some optimizers., (*31)

# Ubuntu 16.04 LTS
apt install gifsicle jpegoptim pngquant optipng

If you have installed some optimizers but want to disable optimization you can do this at app/config/config.yml, (*32)

owja_image_proxy:
    optimization: false

Reporting & Collaboration

Issues and feature requests are tracked in this Github Issue Tracker. Pull Requests to enhance the code to add features or to fix bugs are very welcome. ;-), (*33)

License

This bundle is under the MIT license., (*34)

The Versions

14/07 2017

0.0.1

0.0.1.0

Base Bundle for OWJA! Image Proxy

  Sources   Download

MIT

The Requires

 

by Hauke Broer

proxy images processing compressor resizing