Nos\Toolkit_Image¶Toolkit for image manipulation.
To get a Toolkit_Image, use method getToolkitImage on classes supporting it.
Nos\Toolkit_Image::transformations($transformations)¶Add multiple transformations to the image.
| Parameters: |
|
|---|---|
| Returns: | The current Toolkit_Image for chaining. |
Nos\Toolkit_Image::crop($x1, $y1, $x2, $y2)¶Add a crop transformation to the image.
| Parameters: |
|
|---|---|
| Returns: | The current Toolkit_Image for chaining. |
Nos\Toolkit_Image::resize($width, $height, $keepar = true, $pad = false)¶Resizes the image. If the width or height is null, it will resize retaining the original aspect ratio.
| Parameters: |
|
|---|---|
| Returns: | The current Toolkit_Image for chaining. |
Nos\Toolkit_Image::shrink($max_width, $max_height)¶Resizes the image only if too big
| Parameters: |
|
|---|---|
| Returns: | The current Toolkit_Image for chaining. |
Nos\Toolkit_Image::crop_resize($width, $height)¶Resizes the image. If the width or height is null, it will resize retaining the original aspect ratio.
| Parameters: |
|
|---|---|
| Returns: | The current Toolkit_Image for chaining. |
Nos\Toolkit_Image::rotate($degrees)¶Rotates the image
| Parameters: |
|
|---|---|
| Returns: | The current Toolkit_Image for chaining. |
Nos\Toolkit_Image::flip($direction)¶Creates a vertical / horizontal or both mirror image.
| Parameters: |
|
|---|---|
| Returns: | The current Toolkit_Image for chaining. |
Nos\Toolkit_Image::watermark($filename, $position, $padding = 5)¶Adds a watermark to the image.
| Parameters: |
|
|---|---|
| Returns: | The current Toolkit_Image for chaining. |
Nos\Toolkit_Image::border($size, $color = null)¶Adds a border to the image.
| Parameters: |
|
|---|---|
| Returns: | The current Toolkit_Image for chaining. |
Nos\Toolkit_Image::mask($maskimage)¶Masks the image using the alpha channel of the image input.
| Parameters: |
|
|---|---|
| Returns: | The current Toolkit_Image for chaining. |
Nos\Toolkit_Image::rounded($radius, $sides = null, $antialias = null)¶Adds rounded corners to the image.
| Parameters: |
|
|---|---|
| Returns: | The current Toolkit_Image for chaining. |
Nos\Toolkit_Image::grayscale()¶Turns the image into a grayscale version
| Returns: | The current Toolkit_Image for chaining. |
|---|
Nos\Toolkit_Image::url($absolute = true)¶Build and return the URL of the modify image
| Parameters: |
|
|---|---|
| Returns: | The URL of the modify image. |
Nos\Toolkit_Image::sizes()¶| Returns: | The dimensions of the modify image (an object containing width and height variables). |
|---|
Nos\Toolkit_Image::html($params = array())¶Creates an html image tag of the modify image
Sets width, height, alt attributes if not supplied.
| Parameters: |
|
|---|---|
| Returns: | The image tag |
Nos\Toolkit_Image::save()¶Apply transformations of the Image_URL instance on a file and save it
| Returns: | The save file path |
|---|
Nos\Toolkit_Image::parse($image_url)¶Parse an existing modify URL and set transformations in queue. Check if the hash part of the URL match.
| Parameters: |
|
|---|---|
| Returns: |
|
<?php
$all_media_png = \Nos\Media\Model_Media::find('all', array(
'where' => array(
array('media_ext', 'png'),
),
)); // Get all images PNG in media
// Display all PNG, shrinked in 200x100, grayscale and rounded with a 5px radius, in a <img class="css_class" /> tag.
foreach ($all_media_png as $media) {
echo $media->getToolkitImage()->shrink(200, 100)->grayscale()->rounded(5)->html(array(
'class' => 'css_class',
));
}