2017 © Pedro Peláez
 

library simplify-thumb

Thumbnail generation and image processing, extendable and with a fluent interface.

image

rutkoski/simplify-thumb

Thumbnail generation and image processing, extendable and with a fluent interface.

  • Thursday, March 31, 2016
  • by rutkoski
  • Repository
  • 1 Watchers
  • 0 Stars
  • 99 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Simplify Thumb

Thumbnail generation and image processing, extendable and with a fluent interface., (*1)

Usage:

Basic example:, (*2)

$thumb = new \Simplify\Thumb();

$filename = $thumb
    ->setBaseDir(dirname(__file__))
    ->setFilesPath('files/')
    ->setCachePath('files/cache/')
    ->load('dummy.jpg')
    ->resize(150, 150)
    ->cache()
    ->getCacheFilename();

The library uses the method's parameters (like resize/150/150) to check for an existing cache file and uses it instead of recreating the image., (*3)

Output

Get the cached filename, (*4)

$thumb->getCacheFilename();

or save it to a new location, (*5)

$thumb->save('path/newfile.php');

or overwrite current image, (*6)

$thumb->save();

or send the image to the browser, (*7)

$thumb->output();

Change formats

Just use the PHP constants (IMAGETYPE_PNG, IMAGETYPE_JPEG, ...):, (*8)

$thumb->cache(IMAGETYPE_PNG);

or, (*9)

$thumb->output(IMAGETYPE_PNG);

Available methods

Resize

$thumb->resize($width, $height, $mode, $far, $r, $g, $b, $a);

The third parameter in resize changes how images are resized. It defaults to Simplify_Thumb::FIT\_INSIDE. Options for $mode are:, (*10)

  • Simplify_Thumb::FIT_INSIDE - resize the image to fit inside a box defined by $width and $height
  • Simplify_Thumb::FIT_OUTSIDE - resize the image to fit outside a box defined by $width and $height
  • Simplify_Thumb::SCALE_TO_FIT - resize the image to exactly $width and $height
  • Simplify_Thumb::NO_SCALE - don't resize the image, that's usefull for enlarging the image canvas

The fourth parameters, $far (force aspect ratio), when true, forces the final image to be exactly $width by $height pixels. The $r, $g, $b and $a parameters set the color for the background, so, for example:, (*11)

$thumb->resize(150, 150, Simplify_Thumb::FIT_INSIDE, true, 0, 0, 0, 0);

on a 300 x 100px image, would fit the image inside a 150 x 150px box with a black background., (*12)

ZoomCrop

Crops the image so that it fills the dimensions you specify. The third parameter specifies wich part of the image will be used., (*13)

$thumb->zoomCrop($width, $height, Simplify_Thumb::CENTER);

PHP image filters

$thumb->brightness($level);
$thumb->grayscale();
$thumb->negate();
$thumb->contrast($level);
$thumb->colorize($red, $green, $blue, $alpha);
$thumb->edgedetect();
$thumb->emboss();
$thumb->gaussianBlur();
$thumb->selectiveBlur();
$thumb->meanRemoval();
$thumb->smooth($level);
$thumb->pixelate($blockSize, $advanced);

Offset

Shrink/enlarge the image canvas and fill background with color., (*14)

$thumb->offset($top, $right, $bottom, $left, $r = 0, $g = 0, $b = 0, $a = 0);

$top, $right, $bottom and left are relative. Positive numbers make the canvas bigger, negative numbers make it smaller (crops the image)., (*15)

Custom plugins

Implement custom plugins by extending Simplify_Thumb_Plugin and calling:, (*16)

$thumb->plugin($plugin);

where $plugin is the string representing the plugin class., (*17)

Example:, (*18)

Plugin that overlays an image on top of the current one:, (*19)

class \Simplify\Thumb\Plugin\Overlay extends \Simplify\Thumb\Plugin
{

    protected function process(\Simplify\Thumb\Processor $thumb, $overlayImage = null)
    {
        $overlay = \Simplify\Thumb\Functions::load($overlayImage);

        $w = imagesx($overlay);
        $h = imagesy($overlay);

        imagecopyresampled($thumb->image, $overlay, 0, 0, 0, 0, $w, $h, $w, $h);
    }

}

then:, (*20)

$thumb->plugin('\Simplify\Thumb\Plugin\Overlay', 'overlay.png');

The Versions

31/03 2016

dev-master

9999999-dev https://github.com/rutkoski/simplify-thumb

Thumbnail generation and image processing, extendable and with a fluent interface.

  Sources   Download

GPL

The Requires

 

by Rodrigo Rutkoski Rodrigues

image resize thumbnail effects

31/03 2016

v1.0.0

1.0.0.0 https://github.com/rutkoski/simplify-thumb

Thumbnail generation and image processing, extendable and with a fluent interface.

  Sources   Download

GPL

The Requires

 

by Rodrigo Rutkoski Rodrigues

image resize thumbnail effects