Skip to content

Create Sharpen plugin #104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/PHPThumb/GD.php
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,14 @@ public function save($fileName, $format = null)
}
}

//Execute any plugins
if ($this->plugins) {
foreach ($this->plugins as $plugin) {
/* @var $plugin \PHPThumb\PluginInterface */
$plugin->execute($this);
}
}

// When the interlace option equals true or false call imageinterlace else leave it to default
if ($this->options['interlace'] === true) {
imageinterlace($this->oldImage, 1);
Expand Down
53 changes: 53 additions & 0 deletions src/PHPThumb/Plugins/Sharpen.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php
/**
* Sharpen Lib Plugin Definition File
*
* This file contains the plugin definition for the Sharpen Lib for PHP Thumb
*
* PHP Version 5 with GD 2.0+
* PhpThumb : PHP Thumb Library <http://phpthumb.gxdlabs.com>
* Copyright (c) 2009, Ian Selby/Gen X Design
*
* Author(s): Ian Selby <[email protected]>
*
* Licensed under the MIT License
* Redistributions of files must retain the above copyright notice.
*
* @author Ian Selby <[email protected]>
* @copyright Copyright (c) 2009 Gen X Design
* @link http://phpthumb.gxdlabs.com
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
* @version 3.0
* @package PhpThumb
* @filesource
*/


namespace PHPThumb\Plugins;

/**
* Sharpen Lib Plugin
*
* This plugin allows you to create a sharpened version of your image
* @author Remi Heens <[email protected]>
* @package PhpThumb
* @subpackage Plugins
*/
class Sharpen implements \PHPThumb\PluginInterface
{
public function execute($phpthumb)
{
// sharpen image
$sharpenMatrix = array (
array (-1,-1,-1),
array (-1,16,-1),
array (-1,-1,-1),
);

$divisor = 8;
$offset = 0;

imageconvolution ($phpthumb->getWorkingImage(), $sharpenMatrix, $divisor, $offset);

}
}