added elfinder module
This commit is contained in:
141
sites/all/libraries/elfinder/php/plugins/AutoResize/plugin.php
Normal file
141
sites/all/libraries/elfinder/php/plugins/AutoResize/plugin.php
Normal file
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
/**
|
||||
* elFinder Plugin AutoResize
|
||||
*
|
||||
* Auto resize on file upload.
|
||||
*
|
||||
* ex. binding, configure on connector options
|
||||
* $opts = array(
|
||||
* 'bind' => array(
|
||||
* 'upload.presave' => array(
|
||||
* 'Plugin.AutoResize.onUpLoadPreSave'
|
||||
* )
|
||||
* ),
|
||||
* // global configure (optional)
|
||||
* 'plugin' => array(
|
||||
* 'AutoResize' => array(
|
||||
* 'enable' => true, // For control by volume driver
|
||||
* 'maxWidth' => 1024, // Path to Water mark image
|
||||
* 'maxHeight' => 1024, // Margin right pixel
|
||||
* 'quality' => 95, // JPEG image save quality
|
||||
* 'preserveExif' => false, // Preserve EXIF data (Imagick only)
|
||||
* 'forceEffect' => false, // For change quality or make progressive JPEG of small images
|
||||
* 'targetType' => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP, // Target image formats ( bit-field )
|
||||
* 'offDropWith' => null, // Enabled by default. To disable it if it is dropped with pressing the meta key
|
||||
* // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value
|
||||
* // In case of using any key, specify it as an array
|
||||
* 'onDropWith' => null // Disabled by default. To enable it if it is dropped with pressing the meta key
|
||||
* // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value
|
||||
* // In case of using any key, specify it as an array
|
||||
* )
|
||||
* ),
|
||||
* // each volume configure (optional)
|
||||
* 'roots' => array(
|
||||
* array(
|
||||
* 'driver' => 'LocalFileSystem',
|
||||
* 'path' => '/path/to/files/',
|
||||
* 'URL' => 'http://localhost/to/files/'
|
||||
* 'plugin' => array(
|
||||
* 'AutoResize' => array(
|
||||
* 'enable' => true, // For control by volume driver
|
||||
* 'maxWidth' => 1024, // Path to Water mark image
|
||||
* 'maxHeight' => 1024, // Margin right pixel
|
||||
* 'quality' => 95, // JPEG image save quality
|
||||
* 'preserveExif' => false, // Preserve EXIF data (Imagick only)
|
||||
* 'forceEffect' => false, // For change quality or make progressive JPEG of small images
|
||||
* 'targetType' => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP, // Target image formats ( bit-field )
|
||||
* 'offDropWith' => null, // Enabled by default. To disable it if it is dropped with pressing the meta key
|
||||
* // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value
|
||||
* // In case of using any key, specify it as an array
|
||||
* 'onDropWith' => null // Disabled by default. To enable it if it is dropped with pressing the meta key
|
||||
* // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value
|
||||
* // In case of using any key, specify it as an array
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* );
|
||||
*
|
||||
* @package elfinder
|
||||
* @author Naoki Sawada
|
||||
* @license New BSD
|
||||
*/
|
||||
class elFinderPluginAutoResize extends elFinderPlugin {
|
||||
|
||||
public function __construct($opts) {
|
||||
$defaults = array(
|
||||
'enable' => true, // For control by volume driver
|
||||
'maxWidth' => 1024, // Path to Water mark image
|
||||
'maxHeight' => 1024, // Margin right pixel
|
||||
'quality' => 95, // JPEG image save quality
|
||||
'preserveExif' => false, // Preserve EXIF data (Imagick only)
|
||||
'forceEffect' => false, // For change quality or make progressive JPEG of small images
|
||||
'targetType' => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP, // Target image formats ( bit-field )
|
||||
'offDropWith' => null, // To disable it if it is dropped with pressing the meta key
|
||||
// Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value
|
||||
// In case of using any key, specify it as an array
|
||||
'disableWithContentSaveId' => true // Disable on URL upload with post data "contentSaveId"
|
||||
);
|
||||
|
||||
$this->opts = array_merge($defaults, $opts);
|
||||
|
||||
}
|
||||
|
||||
public function onUpLoadPreSave(&$thash, &$name, $src, $elfinder, $volume) {
|
||||
$opts = $this->getCurrentOpts($volume);
|
||||
|
||||
if (! $this->iaEnabled($opts, $elfinder)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$imageType = null;
|
||||
$srcImgInfo = null;
|
||||
if (extension_loaded('fileinfo') && function_exists('mime_content_type')) {
|
||||
$mime = mime_content_type($src);
|
||||
if (substr($mime, 0, 5) !== 'image') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (extension_loaded('exif') && function_exists('exif_imagetype')) {
|
||||
$imageType = exif_imagetype($src);
|
||||
} else {
|
||||
$srcImgInfo = getimagesize($src);
|
||||
if ($srcImgInfo === false) {
|
||||
return false;
|
||||
}
|
||||
$imageType = $srcImgInfo[2];
|
||||
}
|
||||
|
||||
// check target image type
|
||||
$imgTypes = array(
|
||||
IMAGETYPE_GIF => IMG_GIF,
|
||||
IMAGETYPE_JPEG => IMG_JPEG,
|
||||
IMAGETYPE_PNG => IMG_PNG,
|
||||
IMAGETYPE_BMP => IMG_WBMP,
|
||||
IMAGETYPE_WBMP => IMG_WBMP
|
||||
);
|
||||
if (! isset($imgTypes[$imageType]) || ! ($opts['targetType'] & $imgTypes[$imageType])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (! $srcImgInfo) {
|
||||
$srcImgInfo = getimagesize($src);
|
||||
}
|
||||
|
||||
if ($opts['forceEffect'] || $srcImgInfo[0] > $opts['maxWidth'] || $srcImgInfo[1] > $opts['maxHeight']) {
|
||||
return $this->resize($volume, $src, $srcImgInfo, $opts['maxWidth'], $opts['maxHeight'], $opts['quality'], $opts['preserveExif']);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function resize($volume, $src, $srcImgInfo, $maxWidth, $maxHeight, $jpgQuality, $preserveExif) {
|
||||
$zoom = min(($maxWidth/$srcImgInfo[0]),($maxHeight/$srcImgInfo[1]));
|
||||
$width = round($srcImgInfo[0] * $zoom);
|
||||
$height = round($srcImgInfo[1] * $zoom);
|
||||
$unenlarge = true;
|
||||
$checkAnimated = true;
|
||||
|
||||
return $volume->imageUtil('resize', $src, compact('width', 'height', 'jpgQuality', 'preserveExif', 'unenlarge', 'checkAnimated'));
|
||||
}
|
||||
}
|
132
sites/all/libraries/elfinder/php/plugins/AutoRotate/plugin.php
Normal file
132
sites/all/libraries/elfinder/php/plugins/AutoRotate/plugin.php
Normal file
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
/**
|
||||
* elFinder Plugin AutoRotate
|
||||
*
|
||||
* Auto rotation on file upload of JPEG file by EXIF Orientation.
|
||||
*
|
||||
* ex. binding, configure on connector options
|
||||
* $opts = array(
|
||||
* 'bind' => array(
|
||||
* 'upload.presave' => array(
|
||||
* 'Plugin.AutoRotate.onUpLoadPreSave'
|
||||
* )
|
||||
* ),
|
||||
* // global configure (optional)
|
||||
* 'plugin' => array(
|
||||
* 'AutoRotate' => array(
|
||||
* 'enable' => true, // For control by volume driver
|
||||
* 'quality' => 95, // JPEG image save quality
|
||||
* 'offDropWith' => null, // Enabled by default. To disable it if it is dropped with pressing the meta key
|
||||
* // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value
|
||||
* // In case of using any key, specify it as an array
|
||||
* 'onDropWith' => null // Disabled by default. To enable it if it is dropped with pressing the meta key
|
||||
* // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value
|
||||
* // In case of using any key, specify it as an array
|
||||
* )
|
||||
* ),
|
||||
* // each volume configure (optional)
|
||||
* 'roots' => array(
|
||||
* array(
|
||||
* 'driver' => 'LocalFileSystem',
|
||||
* 'path' => '/path/to/files/',
|
||||
* 'URL' => 'http://localhost/to/files/'
|
||||
* 'plugin' => array(
|
||||
* 'AutoRotate' => array(
|
||||
* 'enable' => true, // For control by volume driver
|
||||
* 'quality' => 95, // JPEG image save quality
|
||||
* 'offDropWith' => null, // Enabled by default. To disable it if it is dropped with pressing the meta key
|
||||
* // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value
|
||||
* // In case of using any key, specify it as an array
|
||||
* 'onDropWith' => null // Disabled by default. To enable it if it is dropped with pressing the meta key
|
||||
* // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value
|
||||
* // In case of using any key, specify it as an array
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* );
|
||||
*
|
||||
* @package elfinder
|
||||
* @author Naoki Sawada
|
||||
* @license New BSD
|
||||
*/
|
||||
class elFinderPluginAutoRotate extends elFinderPlugin {
|
||||
|
||||
public function __construct($opts) {
|
||||
$defaults = array(
|
||||
'enable' => true, // For control by volume driver
|
||||
'quality' => 95, // JPEG image save quality
|
||||
'offDropWith' => null, // To disable it if it is dropped with pressing the meta key
|
||||
// Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value
|
||||
// In case of using any key, specify it as an array
|
||||
'disableWithContentSaveId' => true // Disable on URL upload with post data "contentSaveId"
|
||||
);
|
||||
|
||||
$this->opts = array_merge($defaults, $opts);
|
||||
|
||||
}
|
||||
|
||||
public function onUpLoadPreSave(&$thash, &$name, $src, $elfinder, $volume) {
|
||||
$opts = $this->getCurrentOpts($volume);
|
||||
|
||||
if (! $this->iaEnabled($opts, $elfinder)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$imageType = null;
|
||||
$srcImgInfo = null;
|
||||
if (extension_loaded('fileinfo') && function_exists('mime_content_type')) {
|
||||
$mime = mime_content_type($src);
|
||||
if (substr($mime, 0, 5) !== 'image') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (extension_loaded('exif') && function_exists('exif_imagetype')) {
|
||||
$imageType = exif_imagetype($src);
|
||||
} else {
|
||||
$srcImgInfo = getimagesize($src);
|
||||
if ($srcImgInfo === false) {
|
||||
return false;
|
||||
}
|
||||
$imageType = $srcImgInfo[2];
|
||||
}
|
||||
|
||||
// check target image type
|
||||
if ($imageType !== IMAGETYPE_JPEG) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (! $srcImgInfo) {
|
||||
$srcImgInfo = getimagesize($src);
|
||||
}
|
||||
|
||||
return $this->rotate($volume, $src, $srcImgInfo, $opts['quality']);
|
||||
}
|
||||
|
||||
private function rotate($volume, $src, $srcImgInfo, $quality) {
|
||||
if (! function_exists('exif_read_data')) {
|
||||
return false;
|
||||
}
|
||||
$degree = 0;
|
||||
$exif = exif_read_data($src);
|
||||
if($exif && !empty($exif['Orientation'])) {
|
||||
switch($exif['Orientation']) {
|
||||
case 8:
|
||||
$degree = 270;
|
||||
break;
|
||||
case 3:
|
||||
$degree = 180;
|
||||
break;
|
||||
case 6:
|
||||
$degree = 90;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$opts = array(
|
||||
'degree' => $degree,
|
||||
'jpgQuality' => $quality,
|
||||
'checkAnimated' => true
|
||||
);
|
||||
return $volume->imageUtil('rotate', $src, $opts);
|
||||
}
|
||||
}
|
197
sites/all/libraries/elfinder/php/plugins/Normalizer/plugin.php
Normal file
197
sites/all/libraries/elfinder/php/plugins/Normalizer/plugin.php
Normal file
@@ -0,0 +1,197 @@
|
||||
<?php
|
||||
/**
|
||||
* elFinder Plugin Normalizer
|
||||
*
|
||||
* UTF-8 Normalizer of file-name and file-path etc.
|
||||
* nfc(NFC): Canonical Decomposition followed by Canonical Composition
|
||||
* nfkc(NFKC): Compatibility Decomposition followed by Canonical
|
||||
*
|
||||
* This plugin require Class "Normalizer" (PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
|
||||
* or PEAR package "I18N_UnicodeNormalizer"
|
||||
*
|
||||
* ex. binding, configure on connector options
|
||||
* $opts = array(
|
||||
* 'bind' => array(
|
||||
* 'upload.pre mkdir.pre mkfile.pre rename.pre archive.pre ls.pre' => array(
|
||||
* 'Plugin.Normalizer.cmdPreprocess'
|
||||
* ),
|
||||
* 'upload.presave' => array(
|
||||
* 'Plugin.Normalizer.onUpLoadPreSave'
|
||||
* )
|
||||
* ),
|
||||
* // global configure (optional)
|
||||
* 'plugin' => array(
|
||||
* 'Normalizer' => array(
|
||||
* 'enable' => true,
|
||||
* 'nfc' => true,
|
||||
* 'nfkc' => true,
|
||||
* 'umlauts' => false,
|
||||
* 'lowercase' => false,
|
||||
* 'convmap' => array()
|
||||
* )
|
||||
* ),
|
||||
* // each volume configure (optional)
|
||||
* 'roots' => array(
|
||||
* array(
|
||||
* 'driver' => 'LocalFileSystem',
|
||||
* 'path' => '/path/to/files/',
|
||||
* 'URL' => 'http://localhost/to/files/'
|
||||
* 'plugin' => array(
|
||||
* 'Normalizer' => array(
|
||||
* 'enable' => true,
|
||||
* 'nfc' => true,
|
||||
* 'nfkc' => true,
|
||||
* 'umlauts' => false,
|
||||
* 'lowercase' => false,
|
||||
* 'convmap' => array()
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* );
|
||||
*
|
||||
* @package elfinder
|
||||
* @author Naoki Sawada
|
||||
* @license New BSD
|
||||
*/
|
||||
class elFinderPluginNormalizer extends elFinderPlugin
|
||||
{
|
||||
private $replaced = array();
|
||||
private $keyMap = array(
|
||||
'ls' => 'intersect',
|
||||
'upload' => 'renames',
|
||||
'mkdir' => array('name', 'dirs')
|
||||
);
|
||||
|
||||
public function __construct($opts) {
|
||||
$defaults = array(
|
||||
'enable' => true, // For control by volume driver
|
||||
'nfc' => true, // Canonical Decomposition followed by Canonical Composition
|
||||
'nfkc' => true, // Compatibility Decomposition followed by Canonical
|
||||
'umlauts' => false, // Convert umlauts with their closest 7 bit ascii equivalent
|
||||
'lowercase' => false, // Make chars lowercase
|
||||
'convmap' => array()// Convert map ('FROM' => 'TO') array
|
||||
);
|
||||
|
||||
$this->opts = array_merge($defaults, $opts);
|
||||
}
|
||||
|
||||
public function cmdPreprocess($cmd, &$args, $elfinder, $volume) {
|
||||
$opts = $this->getCurrentOpts($volume);
|
||||
if (! $opts['enable']) {
|
||||
return false;
|
||||
}
|
||||
$this->replaced[$cmd] = array();
|
||||
$key = (isset($this->keyMap[$cmd]))? $this->keyMap[$cmd] : 'name';
|
||||
|
||||
if (is_array($key)) {
|
||||
$keys = $key;
|
||||
} else {
|
||||
$keys = array($key);
|
||||
}
|
||||
foreach($keys as $key) {
|
||||
if (isset($args[$key])) {
|
||||
if (is_array($args[$key])) {
|
||||
foreach($args[$key] as $i => $name) {
|
||||
if ($cmd === 'mkdir' && $key === 'dirs') {
|
||||
// $name need '/' as prefix see #2607
|
||||
$name = '/' . ltrim($name, '/');
|
||||
$_names = explode('/', $name);
|
||||
$_res = array();
|
||||
foreach($_names as $_name) {
|
||||
$_res[] = $this->normalize($_name, $opts);
|
||||
}
|
||||
$this->replaced[$cmd][$name] = $args[$key][$i] = join('/', $_res);
|
||||
} else {
|
||||
$this->replaced[$cmd][$name] = $args[$key][$i] = $this->normalize($name, $opts);
|
||||
}
|
||||
}
|
||||
} else if ($args[$key] !== '') {
|
||||
$name = $args[$key];
|
||||
$this->replaced[$cmd][$name] = $args[$key] = $this->normalize($name, $opts);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($cmd === 'ls' || $cmd === 'mkdir') {
|
||||
if (! empty($this->replaced[$cmd])) {
|
||||
// un-regist for legacy settings
|
||||
$elfinder->unbind($cmd, array($this, 'cmdPostprocess'));
|
||||
$elfinder->bind($cmd, array($this, 'cmdPostprocess'));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function cmdPostprocess($cmd, &$result, $args, $elfinder, $volume) {
|
||||
if ($cmd === 'ls') {
|
||||
if (! empty($result['list']) && ! empty($this->replaced['ls'])) {
|
||||
foreach($result['list'] as $hash => $name) {
|
||||
if ($keys = array_keys($this->replaced['ls'], $name)) {
|
||||
if (count($keys) === 1) {
|
||||
$result['list'][$hash] = $keys[0];
|
||||
} else {
|
||||
$result['list'][$hash] = $keys;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if ($cmd === 'mkdir') {
|
||||
if (! empty($result['hashes']) && ! empty($this->replaced['mkdir'])) {
|
||||
foreach($result['hashes'] as $name => $hash) {
|
||||
if ($keys = array_keys($this->replaced['mkdir'], $name)) {
|
||||
$result['hashes'][$keys[0]] = $hash;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: $thash is directory hash so it unneed to process at here
|
||||
public function onUpLoadPreSave(&$thash, &$name, $src, $elfinder, $volume) {
|
||||
$opts = $this->getCurrentOpts($volume);
|
||||
if (! $opts['enable']) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$name = $this->normalize($name, $opts);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function normalize($str, $opts) {
|
||||
if ($opts['nfc'] || $opts['nfkc']) {
|
||||
if (class_exists('Normalizer', false)) {
|
||||
if ($opts['nfc'] && ! Normalizer::isNormalized($str, Normalizer::FORM_C))
|
||||
$str = Normalizer::normalize($str, Normalizer::FORM_C);
|
||||
if ($opts['nfkc'] && ! Normalizer::isNormalized($str, Normalizer::FORM_KC))
|
||||
$str = Normalizer::normalize($str, Normalizer::FORM_KC);
|
||||
} else {
|
||||
if (! class_exists('I18N_UnicodeNormalizer', false)) {
|
||||
include_once 'I18N/UnicodeNormalizer.php';
|
||||
}
|
||||
if (class_exists('I18N_UnicodeNormalizer', false)) {
|
||||
$normalizer = new I18N_UnicodeNormalizer();
|
||||
if ($opts['nfc'])
|
||||
$str = $normalizer->normalize($str, 'NFC');
|
||||
if ($opts['nfkc'])
|
||||
$str = $normalizer->normalize($str, 'NFKC');
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($opts['umlauts']) {
|
||||
if (strpos($str = htmlentities($str, ENT_QUOTES, 'UTF-8'), '&') !== false) {
|
||||
$str = html_entity_decode(preg_replace('~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|tilde|uml);~i', '$1', $str), ENT_QUOTES, 'utf-8');
|
||||
}
|
||||
}
|
||||
if ($opts['convmap'] && is_array($opts['convmap'])) {
|
||||
$str = strtr($str, $opts['convmap']);
|
||||
}
|
||||
if ($opts['lowercase']) {
|
||||
if (function_exists('mb_strtolower')) {
|
||||
$str = mb_strtolower($str, 'UTF-8');
|
||||
} else {
|
||||
$str = strtolower($str);
|
||||
}
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
}
|
153
sites/all/libraries/elfinder/php/plugins/Sanitizer/plugin.php
Normal file
153
sites/all/libraries/elfinder/php/plugins/Sanitizer/plugin.php
Normal file
@@ -0,0 +1,153 @@
|
||||
<?php
|
||||
/**
|
||||
* elFinder Plugin Sanitizer
|
||||
*
|
||||
* Sanitizer of file-name and file-path etc.
|
||||
*
|
||||
* ex. binding, configure on connector options
|
||||
* $opts = array(
|
||||
* 'bind' => array(
|
||||
* 'upload.pre mkdir.pre mkfile.pre rename.pre archive.pre ls.pre' => array(
|
||||
* 'Plugin.Sanitizer.cmdPreprocess'
|
||||
* ),
|
||||
* 'upload.presave' => array(
|
||||
* 'Plugin.Sanitizer.onUpLoadPreSave'
|
||||
* )
|
||||
* ),
|
||||
* // global configure (optional)
|
||||
* 'plugin' => array(
|
||||
* 'Sanitizer' => array(
|
||||
* 'enable' => true,
|
||||
* 'targets' => array('\\','/',':','*','?','"','<','>','|'), // target chars
|
||||
* 'replace' => '_', // replace to this
|
||||
* 'callBack' => null // Or @callable sanitize function
|
||||
* )
|
||||
* ),
|
||||
* // each volume configure (optional)
|
||||
* 'roots' => array(
|
||||
* array(
|
||||
* 'driver' => 'LocalFileSystem',
|
||||
* 'path' => '/path/to/files/',
|
||||
* 'URL' => 'http://localhost/to/files/'
|
||||
* 'plugin' => array(
|
||||
* 'Sanitizer' => array(
|
||||
* 'enable' => true,
|
||||
* 'targets' => array('\\','/',':','*','?','"','<','>','|'), // target chars
|
||||
* 'replace' => '_', // replace to this
|
||||
* 'callBack' => null // Or @callable sanitize function
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* );
|
||||
*
|
||||
* @package elfinder
|
||||
* @author Naoki Sawada
|
||||
* @license New BSD
|
||||
*/
|
||||
class elFinderPluginSanitizer extends elFinderPlugin
|
||||
{
|
||||
private $replaced = array();
|
||||
private $keyMap = array(
|
||||
'ls' => 'intersect',
|
||||
'upload' => 'renames',
|
||||
'mkdir' => array('name', 'dirs')
|
||||
);
|
||||
|
||||
public function __construct($opts) {
|
||||
$defaults = array(
|
||||
'enable' => true, // For control by volume driver
|
||||
'targets' => array('\\','/',':','*','?','"','<','>','|'), // target chars
|
||||
'replace' => '_', // replace to this
|
||||
'callBack' => null // Or callable sanitize function
|
||||
);
|
||||
$this->opts = array_merge($defaults, $opts);
|
||||
}
|
||||
|
||||
public function cmdPreprocess($cmd, &$args, $elfinder, $volume) {
|
||||
$opts = $this->getCurrentOpts($volume);
|
||||
if (! $opts['enable']) {
|
||||
return false;
|
||||
}
|
||||
$this->replaced[$cmd] = array();
|
||||
$key = (isset($this->keyMap[$cmd]))? $this->keyMap[$cmd] : 'name';
|
||||
|
||||
if (is_array($key)) {
|
||||
$keys = $key;
|
||||
} else {
|
||||
$keys = array($key);
|
||||
}
|
||||
foreach($keys as $key) {
|
||||
if (isset($args[$key])) {
|
||||
if (is_array($args[$key])) {
|
||||
foreach($args[$key] as $i => $name) {
|
||||
if ($cmd === 'mkdir' && $key === 'dirs') {
|
||||
// $name need '/' as prefix see #2607
|
||||
$name = '/' . ltrim($name, '/');
|
||||
$_names = explode('/', $name);
|
||||
$_res = array();
|
||||
foreach($_names as $_name) {
|
||||
$_res[] = $this->sanitizeFileName($_name, $opts);
|
||||
}
|
||||
$this->replaced[$cmd][$name] = $args[$key][$i] = join('/', $_res);
|
||||
} else {
|
||||
$this->replaced[$cmd][$name] = $args[$key][$i] = $this->sanitizeFileName($name, $opts);
|
||||
}
|
||||
}
|
||||
} else if ($args[$key] !== '') {
|
||||
$name = $args[$key];
|
||||
$this->replaced[$cmd][$name] = $args[$key] = $this->sanitizeFileName($name, $opts);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($cmd === 'ls' || $cmd === 'mkdir') {
|
||||
if (! empty($this->replaced[$cmd])) {
|
||||
// un-regist for legacy settings
|
||||
$elfinder->unbind($cmd, array($this, 'cmdPostprocess'));
|
||||
$elfinder->bind($cmd, array($this, 'cmdPostprocess'));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function cmdPostprocess($cmd, &$result, $args, $elfinder, $volume) {
|
||||
if ($cmd === 'ls') {
|
||||
if (! empty($result['list']) && ! empty($this->replaced['ls'])) {
|
||||
foreach($result['list'] as $hash => $name) {
|
||||
if ($keys = array_keys($this->replaced['ls'], $name)) {
|
||||
if (count($keys) === 1) {
|
||||
$result['list'][$hash] = $keys[0];
|
||||
} else {
|
||||
$result['list'][$hash] = $keys;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if ($cmd === 'mkdir') {
|
||||
if (! empty($result['hashes']) && ! empty($this->replaced['mkdir'])) {
|
||||
foreach($result['hashes'] as $name => $hash) {
|
||||
if ($keys = array_keys($this->replaced['mkdir'], $name)) {
|
||||
$result['hashes'][$keys[0]] = $hash;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: $thash is directory hash so it unneed to process at here
|
||||
public function onUpLoadPreSave(&$thash, &$name, $src, $elfinder, $volume) {
|
||||
$opts = $this->getCurrentOpts($volume);
|
||||
if (! $opts['enable']) {
|
||||
return false;
|
||||
}
|
||||
$name = $this->sanitizeFileName($name, $opts);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function sanitizeFileName($filename, $opts) {
|
||||
if(!empty($opts['callBack']) && is_callable($opts['callBack'])) {
|
||||
return call_user_func_array($opts['callBack'], array($filename, $opts));
|
||||
}
|
||||
return str_replace($opts['targets'], $opts['replace'], $filename);
|
||||
}
|
||||
}
|
BIN
sites/all/libraries/elfinder/php/plugins/Watermark/logo.png
Normal file
BIN
sites/all/libraries/elfinder/php/plugins/Watermark/logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.7 KiB |
420
sites/all/libraries/elfinder/php/plugins/Watermark/plugin.php
Normal file
420
sites/all/libraries/elfinder/php/plugins/Watermark/plugin.php
Normal file
@@ -0,0 +1,420 @@
|
||||
<?php
|
||||
/**
|
||||
* elFinder Plugin Watermark
|
||||
*
|
||||
* Print watermark on file upload.
|
||||
*
|
||||
* ex. binding, configure on connector options
|
||||
* $opts = array(
|
||||
* 'bind' => array(
|
||||
* 'upload.presave' => array(
|
||||
* 'Plugin.Watermark.onUpLoadPreSave'
|
||||
* )
|
||||
* ),
|
||||
* // global configure (optional)
|
||||
* 'plugin' => array(
|
||||
* 'Watermark' => array(
|
||||
* 'enable' => true, // For control by volume driver
|
||||
* 'source' => 'logo.png', // Path to Water mark image
|
||||
* 'ratio' => 0.2, // Ratio to original image (ratio > 0 and ratio <= 1)
|
||||
* 'position' => 'RB', // Position L(eft)/C(enter)/R(ight) and T(op)/M(edium)/B(ottom)
|
||||
* 'marginX' => 5, // Margin horizontal pixel
|
||||
* 'marginY' => 5, // Margin vertical pixel
|
||||
* 'quality' => 95, // JPEG image save quality
|
||||
* 'transparency' => 70, // Water mark image transparency ( other than PNG )
|
||||
* 'targetType' => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP, // Target image formats ( bit-field )
|
||||
* 'targetMinPixel' => 200, // Target image minimum pixel size
|
||||
* 'interlace' => IMG_GIF|IMG_JPG, // Set interlacebit image formats ( bit-field )
|
||||
* 'offDropWith' => null, // Enabled by default. To disable it if it is dropped with pressing the meta key
|
||||
* // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value
|
||||
* // In case of using any key, specify it as an array
|
||||
* 'onDropWith' => null // Disabled by default. To enable it if it is dropped with pressing the meta key
|
||||
* // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value
|
||||
* // In case of using any key, specify it as an array
|
||||
* )
|
||||
* ),
|
||||
* // each volume configure (optional)
|
||||
* 'roots' => array(
|
||||
* array(
|
||||
* 'driver' => 'LocalFileSystem',
|
||||
* 'path' => '/path/to/files/',
|
||||
* 'URL' => 'http://localhost/to/files/'
|
||||
* 'plugin' => array(
|
||||
* 'Watermark' => array(
|
||||
* 'enable' => true, // For control by volume driver
|
||||
* 'source' => 'logo.png', // Path to Water mark image
|
||||
* 'ratio' => 0.2, // Ratio to original image (ratio > 0 and ratio <= 1)
|
||||
* 'position' => 'RB', // Position L(eft)/C(enter)/R(ight) and T(op)/M(edium)/B(ottom)
|
||||
* 'marginX' => 5, // Margin horizontal pixel
|
||||
* 'marginY' => 5, // Margin vertical pixel
|
||||
* 'quality' => 95, // JPEG image save quality
|
||||
* 'transparency' => 70, // Water mark image transparency ( other than PNG )
|
||||
* 'targetType' => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP, // Target image formats ( bit-field )
|
||||
* 'targetMinPixel' => 200, // Target image minimum pixel size
|
||||
* 'interlace' => IMG_GIF|IMG_JPG, // Set interlacebit image formats ( bit-field )
|
||||
* 'offDropWith' => null, // Enabled by default. To disable it if it is dropped with pressing the meta key
|
||||
* // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value
|
||||
* // In case of using any key, specify it as an array
|
||||
* 'onDropWith' => null // Disabled by default. To enable it if it is dropped with pressing the meta key
|
||||
* // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value
|
||||
* // In case of using any key, specify it as an array
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* );
|
||||
*
|
||||
* @package elfinder
|
||||
* @author Naoki Sawada
|
||||
* @license New BSD
|
||||
*/
|
||||
class elFinderPluginWatermark extends elFinderPlugin {
|
||||
|
||||
private $watermarkImgInfo = null;
|
||||
|
||||
public function __construct($opts) {
|
||||
$defaults = array(
|
||||
'enable' => true, // For control by volume driver
|
||||
'source' => 'logo.png', // Path to Water mark image
|
||||
'ratio' => 0.2, // Ratio to original image (ratio > 0 and ratio <= 1)
|
||||
'position' => 'RB', // Position L(eft)/C(enter)/R(ight) and T(op)/M(edium)/B(ottom)
|
||||
'marginX' => 5, // Margin horizontal pixel
|
||||
'marginY' => 5, // Margin vertical pixel
|
||||
'quality' => 95, // JPEG image save quality
|
||||
'transparency' => 70, // Water mark image transparency ( other than PNG )
|
||||
'targetType' => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP, // Target image formats ( bit-field )
|
||||
'targetMinPixel' => 200, // Target image minimum pixel size
|
||||
'interlace' => IMG_GIF|IMG_JPG, // Set interlacebit image formats ( bit-field )
|
||||
'offDropWith' => null, // To disable it if it is dropped with pressing the meta key
|
||||
// Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value
|
||||
// In case of using any key, specify it as an array
|
||||
'marginRight' => 0, // Deprecated - marginX should be used
|
||||
'marginBottom' => 0, // Deprecated - marginY should be used
|
||||
'disableWithContentSaveId' => true // Disable on URL upload with post data "contentSaveId"
|
||||
);
|
||||
|
||||
$this->opts = array_merge($defaults, $opts);
|
||||
|
||||
}
|
||||
|
||||
public function onUpLoadPreSave(&$thash, &$name, $src, $elfinder, $volume) {
|
||||
$opts = $this->getCurrentOpts($volume);
|
||||
|
||||
if (! $this->iaEnabled($opts, $elfinder)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$imageType = null;
|
||||
$srcImgInfo = null;
|
||||
if (extension_loaded('fileinfo') && function_exists('mime_content_type')) {
|
||||
$mime = mime_content_type($src);
|
||||
if (substr($mime, 0, 5) !== 'image') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (extension_loaded('exif') && function_exists('exif_imagetype')) {
|
||||
$imageType = exif_imagetype($src);
|
||||
} else {
|
||||
$srcImgInfo = getimagesize($src);
|
||||
if ($srcImgInfo === false) {
|
||||
return false;
|
||||
}
|
||||
$imageType = $srcImgInfo[2];
|
||||
}
|
||||
|
||||
// check target image type
|
||||
$imgTypes = array(
|
||||
IMAGETYPE_GIF => IMG_GIF,
|
||||
IMAGETYPE_JPEG => IMG_JPEG,
|
||||
IMAGETYPE_PNG => IMG_PNG,
|
||||
IMAGETYPE_BMP => IMG_WBMP,
|
||||
IMAGETYPE_WBMP => IMG_WBMP
|
||||
);
|
||||
if (! isset($imgTypes[$imageType]) || ! ($opts['targetType'] & $imgTypes[$imageType])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// check Animation Gif
|
||||
if ($imageType === IMAGETYPE_GIF && elFinder::isAnimationGif($src)) {
|
||||
return false;
|
||||
}
|
||||
// check Animation Png
|
||||
if ($imageType === IMAGETYPE_PNG && elFinder::isAnimationPng($src)) {
|
||||
return false;
|
||||
}
|
||||
// check water mark image
|
||||
if (! file_exists($opts['source'])) {
|
||||
$opts['source'] = dirname(__FILE__) . "/" . $opts['source'];
|
||||
}
|
||||
if (is_readable($opts['source'])) {
|
||||
$watermarkImgInfo = getimagesize($opts['source']);
|
||||
if (! $watermarkImgInfo) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (! $srcImgInfo) {
|
||||
$srcImgInfo = getimagesize($src);
|
||||
}
|
||||
|
||||
$watermark = $opts['source'];
|
||||
$quality = $opts['quality'];
|
||||
$transparency = $opts['transparency'];
|
||||
|
||||
// check target image size
|
||||
if ($opts['targetMinPixel'] > 0 && $opts['targetMinPixel'] > min($srcImgInfo[0], $srcImgInfo[1])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$watermark_width = $watermarkImgInfo[0];
|
||||
$watermark_height = $watermarkImgInfo[1];
|
||||
|
||||
// Specified as a ratio to the image size
|
||||
if ($opts['ratio'] && $opts['ratio'] > 0 && $opts['ratio'] <= 1) {
|
||||
$maxW = $srcImgInfo[0] * $opts['ratio'] - ($opts['marginX'] * 2);
|
||||
$maxH = $srcImgInfo[1] * $opts['ratio'] - ($opts['marginY'] * 2);
|
||||
$dx = $dy = 0;
|
||||
if (($maxW >= $watermarkImgInfo[0] && $maxH >= $watermarkImgInfo[0]) || ($maxW <= $watermarkImgInfo[0] && $maxH <= $watermarkImgInfo[0])) {
|
||||
$dx = abs($srcImgInfo[0] - $watermarkImgInfo[0]);
|
||||
$dy = abs($srcImgInfo[1] - $watermarkImgInfo[1]);
|
||||
} else if ($maxW < $watermarkImgInfo[0]) {
|
||||
$dx = -1;
|
||||
} else {
|
||||
$dy = -1;
|
||||
}
|
||||
if ($dx < $dy) {
|
||||
$ww = $maxW;
|
||||
$wh = $watermarkImgInfo[1] * ($ww / $watermarkImgInfo[0]);
|
||||
} else {
|
||||
$wh = $maxH;
|
||||
$ww = $watermarkImgInfo[0] * ($wh / $watermarkImgInfo[1]);
|
||||
}
|
||||
$watermarkImgInfo[0] = $ww;
|
||||
$watermarkImgInfo[1] = $wh;
|
||||
} else {
|
||||
$opts['ratio'] = null;
|
||||
}
|
||||
|
||||
$opts['position'] = strtoupper($opts['position']);
|
||||
|
||||
// Set vertical position
|
||||
if (strpos($opts['position'], 'T') !== false) {
|
||||
// Top
|
||||
$dest_x = $opts['marginX'];
|
||||
} else if (strpos($opts['position'], 'M') !== false) {
|
||||
// Middle
|
||||
$dest_x = ($srcImgInfo[0] - $watermarkImgInfo[0]) / 2;
|
||||
} else {
|
||||
// Bottom
|
||||
$dest_x = $srcImgInfo[0] - $watermarkImgInfo[0] - max($opts['marginBottom'], $opts['marginX']);
|
||||
}
|
||||
|
||||
// Set horizontal position
|
||||
if (strpos($opts['position'], 'L') !== false) {
|
||||
// Left
|
||||
$dest_y = $opts['marginY'];
|
||||
} else if (strpos($opts['position'], 'C') !== false) {
|
||||
// Middle
|
||||
$dest_y = ($srcImgInfo[1] - $watermarkImgInfo[1]) / 2;
|
||||
} else {
|
||||
// Right
|
||||
$dest_y = $srcImgInfo[1] - $watermarkImgInfo[1] - max($opts['marginRight'], $opts['marginY']);
|
||||
}
|
||||
|
||||
|
||||
// check interlace
|
||||
$opts['interlace'] = ($opts['interlace'] & $imgTypes[$imageType]);
|
||||
|
||||
if (class_exists('Imagick', false)) {
|
||||
return $this->watermarkPrint_imagick($src, $watermark, $dest_x, $dest_y, $quality, $transparency, $watermarkImgInfo, $opts);
|
||||
} else {
|
||||
elFinder::expandMemoryForGD(array($watermarkImgInfo, $srcImgInfo));
|
||||
return $this->watermarkPrint_gd($src, $watermark, $dest_x, $dest_y, $quality, $transparency, $watermarkImgInfo, $srcImgInfo, $opts);
|
||||
}
|
||||
}
|
||||
|
||||
private function watermarkPrint_imagick($src, $watermark, $dest_x, $dest_y, $quality, $transparency, $watermarkImgInfo, $opts) {
|
||||
|
||||
try {
|
||||
|
||||
// Open the original image
|
||||
$img = new Imagick($src);
|
||||
|
||||
// Open the watermark
|
||||
$watermark = new Imagick($watermark);
|
||||
|
||||
// zoom
|
||||
if ($opts['ratio']) {
|
||||
$watermark->scaleImage($watermarkImgInfo[0], $watermarkImgInfo[1]);
|
||||
}
|
||||
|
||||
// Set transparency
|
||||
if (strtoupper($watermark->getImageFormat()) !== 'PNG') {
|
||||
$watermark->setImageOpacity($transparency/100);
|
||||
}
|
||||
|
||||
// Overlay the watermark on the original image
|
||||
$img->compositeImage($watermark, imagick::COMPOSITE_OVER, $dest_x, $dest_y);
|
||||
|
||||
// Set quality
|
||||
if (strtoupper($img->getImageFormat()) === 'JPEG') {
|
||||
$img->setImageCompression(imagick::COMPRESSION_JPEG);
|
||||
$img->setCompressionQuality($quality);
|
||||
}
|
||||
|
||||
// set interlace
|
||||
$opts['interlace'] && $img->setInterlaceScheme(Imagick::INTERLACE_PLANE);
|
||||
|
||||
$result = $img->writeImage($src);
|
||||
|
||||
$img->clear();
|
||||
$img->destroy();
|
||||
$watermark->clear();
|
||||
$watermark->destroy();
|
||||
|
||||
return $result ? true : false;
|
||||
} catch (Exception $e) {
|
||||
$ermsg = $e->getMessage();
|
||||
$ermsg && trigger_error($ermsg);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private function watermarkPrint_gd($src, $watermark, $dest_x, $dest_y, $quality, $transparency, $watermarkImgInfo, $srcImgInfo, $opts) {
|
||||
|
||||
$watermark_width = $watermarkImgInfo[0];
|
||||
$watermark_height = $watermarkImgInfo[1];
|
||||
|
||||
$ermsg = '';
|
||||
switch ($watermarkImgInfo['mime']) {
|
||||
case 'image/gif':
|
||||
if (imagetypes() & IMG_GIF) {
|
||||
$oWatermarkImg = imagecreatefromgif($watermark);
|
||||
} else {
|
||||
$ermsg = 'GIF images are not supported as watermark image';
|
||||
}
|
||||
break;
|
||||
case 'image/jpeg':
|
||||
if (imagetypes() & IMG_JPG) {
|
||||
$oWatermarkImg = imagecreatefromjpeg($watermark) ;
|
||||
} else {
|
||||
$ermsg = 'JPEG images are not supported as watermark image';
|
||||
}
|
||||
break;
|
||||
case 'image/png':
|
||||
if (imagetypes() & IMG_PNG) {
|
||||
$oWatermarkImg = imagecreatefrompng($watermark) ;
|
||||
} else {
|
||||
$ermsg = 'PNG images are not supported as watermark image';
|
||||
}
|
||||
break;
|
||||
case 'image/wbmp':
|
||||
if (imagetypes() & IMG_WBMP) {
|
||||
$oWatermarkImg = imagecreatefromwbmp($watermark);
|
||||
} else {
|
||||
$ermsg = 'WBMP images are not supported as watermark image';
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$oWatermarkImg = false;
|
||||
$ermsg = $watermarkImgInfo['mime'].' images are not supported as watermark image';
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (! $ermsg) {
|
||||
// zoom
|
||||
if ($opts['ratio']) {
|
||||
$tmpImg = imagecreatetruecolor($watermarkImgInfo[0], $watermarkImgInfo[1]);
|
||||
imagealphablending($tmpImg, false);
|
||||
imagesavealpha($tmpImg, true);
|
||||
imagecopyresampled($tmpImg, $oWatermarkImg, 0, 0, 0, 0, $watermarkImgInfo[0], $watermarkImgInfo[1], imagesx($oWatermarkImg), imagesy($oWatermarkImg));
|
||||
imageDestroy($oWatermarkImg);
|
||||
$oWatermarkImg = $tmpImg;
|
||||
$tmpImg = null;
|
||||
}
|
||||
|
||||
switch ($srcImgInfo['mime']) {
|
||||
case 'image/gif':
|
||||
if (imagetypes() & IMG_GIF) {
|
||||
$oSrcImg = imagecreatefromgif($src);
|
||||
} else {
|
||||
$ermsg = 'GIF images are not supported as source image';
|
||||
}
|
||||
break;
|
||||
case 'image/jpeg':
|
||||
if (imagetypes() & IMG_JPG) {
|
||||
$oSrcImg = imagecreatefromjpeg($src) ;
|
||||
} else {
|
||||
$ermsg = 'JPEG images are not supported as source image';
|
||||
}
|
||||
break;
|
||||
case 'image/png':
|
||||
if (imagetypes() & IMG_PNG) {
|
||||
$oSrcImg = imagecreatefrompng($src) ;
|
||||
} else {
|
||||
$ermsg = 'PNG images are not supported as source image';
|
||||
}
|
||||
break;
|
||||
case 'image/wbmp':
|
||||
if (imagetypes() & IMG_WBMP) {
|
||||
$oSrcImg = imagecreatefromwbmp($src);
|
||||
} else {
|
||||
$ermsg = 'WBMP images are not supported as source image';
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$oSrcImg = false;
|
||||
$ermsg = $srcImgInfo['mime'].' images are not supported as source image';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($ermsg || false === $oSrcImg || false === $oWatermarkImg) {
|
||||
$ermsg && trigger_error($ermsg);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($srcImgInfo['mime'] === 'image/png') {
|
||||
if (function_exists('imagecolorallocatealpha')) {
|
||||
$bg = imagecolorallocatealpha($oSrcImg, 255, 255, 255, 127);
|
||||
imagefill($oSrcImg, 0, 0 , $bg);
|
||||
}
|
||||
}
|
||||
|
||||
if ($watermarkImgInfo['mime'] === 'image/png') {
|
||||
imagecopy($oSrcImg, $oWatermarkImg, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height);
|
||||
} else {
|
||||
imagecopymerge($oSrcImg, $oWatermarkImg, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, $transparency);
|
||||
}
|
||||
|
||||
// set interlace
|
||||
$opts['interlace'] && imageinterlace($oSrcImg, true);
|
||||
|
||||
switch ($srcImgInfo['mime']) {
|
||||
case 'image/gif':
|
||||
imagegif($oSrcImg, $src);
|
||||
break;
|
||||
case 'image/jpeg':
|
||||
imagejpeg($oSrcImg, $src, $quality);
|
||||
break;
|
||||
case 'image/png':
|
||||
if (function_exists('imagesavealpha') && function_exists('imagealphablending')) {
|
||||
imagealphablending($oSrcImg, false);
|
||||
imagesavealpha($oSrcImg, true);
|
||||
}
|
||||
imagepng($oSrcImg, $src);
|
||||
break;
|
||||
case 'image/wbmp':
|
||||
imagewbmp($oSrcImg, $src);
|
||||
break;
|
||||
}
|
||||
|
||||
imageDestroy($oSrcImg);
|
||||
imageDestroy($oWatermarkImg);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user