Skip to content
This repository was archived by the owner on May 22, 2019. It is now read-only.

Repository files navigation

OWJA! Image Proxy Bundle

Latest Stable VersionLatest Unstable VersionLicenseBuild Status

This Bundle is Open Source and under MIT license.

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.

Accessing the images

Preset Mode

enable_presets must be set to true to use this. Default is true.

http://.../:preset/imagepath

VarValueRequiredInfo
presetstringyesThe preset code
imagepathstringyesThe public path to the Image

Example to get image "img/someimage.jpg" processed by preset "fullhd": http://example.com/:fullhd/img/someimage.jpg

Dynamic Mode

enable_dynamic must be set to true to use this. Default is false.

IMPORTANT! Dynamic mode should not used in production environment!

http://.../type/heightxwidth/imagepath

VarValueRequiredInfo
typeresize or cropyesResize will first resize the image to best fit and then crop to destination size.
heightintegernoDestination height of Image
widthintegernoDestination width of Image
imagepathstringyesThe public path to the Image

Examples

Resize and crop the Image to fit into a 100x100 Pixel square

http://example.com/resize/100x100/img/someimage.jpg

Cropping to fit into a 100x100 Pixel square

http://example.com/resize/100x100/img/someimage.jpg

Resize to 100 Pixel with and preserve original image Ratio

http://example.com/resize/x100/img/someimage.jpg

Resize to 100 Pixel height and preserve original image Ratio

http://example.com/resize/100x/img/someimage.jpg

Optimizations only:

http://example.com/resize/x/img/someimage.jpg

Installation

$ composer require owja/image-proxy-bundle

Load Bundles in app/AppKernel.php

newOneup\FlysystemBundle\OneupFlysystemBundle(),
newOwja\ImageProxyBundle\OwjaImageProxyBundle(),

Setup your app/config/config.yml

oneup_flysystem:
adapters:
image_cache_adapter:
local:
directory: "%kernel.root_dir%/../var/images"filesystems:
image_cache_filesystem:
adapter: image_cache_adapteralias: owja_image_proxy.cacheowja_image_proxy:
sites:
default:
url: "http://example.com/"

Set "http://example.com/" to the URL representing the source of your images.

Setup your app/config/routing.yml

owja_image_proxy:
resource: "@OwjaImageProxyBundle/Controller/"type: annotationprefix: /

Create the Directory for temporary Files which gets created while processing the Images:

var/temp

Configuration Details

owja_image_proxy:
remote:
token: nulltimeout: 10limits:
height: 1080width: 1920temp_dir: "%kernel.root_dir%/../var/temp/"cache_service: "owja_image_proxy.cache"optimization: truedefault_site: defaultenable_sites: falseenable_dynamic: falseenable_presets: true
CVarDefaultInfo
remote : tokennullSend by Header 'owja-image-proxy'
remote : timeout10Request timeout to get the source image
limits : height1080Maximum allowed height of requested Image
limits : width1920Maximum 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)
optimizationtrueEnable/disable image optimization
default_site"default"Code of the default site. Has to be configured under sites
enable_sitesfalseSet to true to enable more than the default site
enable_dynamicfalseSet to true to enable dynamic mode
enable_presetstrueSet to true to enable processing predefined presets

Multiple Sites

Simply add some sites and set enable_sites to true

owja_image_proxy:
enable_sites: truesites:
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

Dynamic Mode

http://.../site/type/widthxheight/imagepath

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

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:

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

Per Site Presets:

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

Image Optimization

To enable image optimization you should install some optimizers.

# 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

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. ;-)

License

This bundle is under the MIT license.

About

Base Bundle for OWJA! Image Proxy

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages