Download the PHP package wendrowycz/skoch-filter-file-resize without Composer
On this page you can find all versions of the php package wendrowycz/skoch-filter-file-resize. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download wendrowycz/skoch-filter-file-resize
More information about wendrowycz/skoch-filter-file-resize
Files in wendrowycz/skoch-filter-file-resize
Package skoch-filter-file-resize
Short Description Resize utility for the Zend Framework
License MIT
Informations about the package skoch-filter-file-resize
Skoch_Filter_File_Resize
Resize utility for the Zend Framework
Skoch_Filter_File_Resize
is a utility for integrating image resizing into the Zend Framework's Zend_Form
structure. It is implemented as a filter which you can attach to Zend_Form_Element_File
instances.
Installation
- Download the folder library/Skoch from github and add it to your library files
- Add
autoloaderNamespaces[] = "Skoch_"
to yourapplication.ini
Examples
The folders application
and public
contain examples for some basic usage. The most interesting file is application/forms/Image.php
.
You will need to have Zend-Framework installed to run the example.
Basic Usage
You can add the filter to your Zend_Form_Element_File
instance.
This will scale the image to a maximum of 200px length and a maximum of 300px height. One of both sides will probably be a bit smaller, because we set keepRatio to true
meaning that the aspect ratio (e.g. 3:4) shall be maintained. There also is a implicit defition of keepSmaller set to true
meaning that if the image is already smaller, it shall not be enlarged (because that would lead to a lot of strange pixels).
Multiple thumbnails
Often you want to create several thumbnails in different sizes. This can be done by using a so called filter chain and the directory option of the Skoch_Filter_File_Resize
.
If you specify directory, the value of setDestination()
will not be considered anymore. Thus, you have to pass the full path to the directory option.
This will create two thumbnails, one of maximum 600px length and 300px height and the other of 500px length and 200px height. In each case, the aspect ratio will be kept. The smaller thumbnail will be saved to the folder /var/www/skoch/upload/medium
while the larger one will use the default option set via Zend's setDestination()
method.
Options / Arguments
You may specify different options for the Resize Filter:
- width: The maximum width of the resized image
- height: The maximum height of the resized image
- keepRatio: Keep the aspect ratio and do not resize to both width and height (usually expected).
- keepSmaller: Do not resize if the image is already smaller than the given sizes.
- cropToFit: If the image dimensions do not match the given image, crop off some borders
- directory: Set a directory to store the thumbnail in. If nothing is given, the normal image will be overwritten.
- adapter: The adapter to use for resizing. You may specify a string or an instance of an adapter.
Further information
You can find further information in the article on my blog.
License
This software is licensed under the Simplified BSD License.