code
stringlengths
17
247k
docstring
stringlengths
30
30.3k
func_name
stringlengths
1
89
language
stringclasses
1 value
repo
stringlengths
7
63
path
stringlengths
7
153
url
stringlengths
51
209
license
stringclasses
4 values
protected function _commentCB($m) { $hasSurroundingWs = (trim($m[0]) !== $m[1]); $m = $m[1]; // $m is the comment content w/o the surrounding tokens, // but the return value will replace the entire comment. if ($m === 'keep') { return '/**/'; } if ($m === '" "') { // component of http://tantek.com/CSS/Examples/midpass.html return '/*" "*/'; } if (preg_match('@";\\}\\s*\\}/\\*\\s+@', $m)) { // component of http://tantek.com/CSS/Examples/midpass.html return '/*";}}/* */'; } if ($this->_inHack) { // inversion: feeding only to one browser if (preg_match('@ ^/ # comment started like /*/ \\s* (\\S[\\s\\S]+?) # has at least some non-ws content \\s* /\\* # ends like /*/ or /**/ @x', $m, $n)) { // end hack mode after this comment, but preserve the hack and comment content $this->_inHack = false; return "/*/{$n[1]}/**/"; } } if (substr($m, -1) === '\\') { // comment ends like \*/ // begin hack mode and preserve hack $this->_inHack = true; return '/*\\*/'; } if ($m !== '' && $m[0] === '/') { // comment looks like /*/ foo */ // begin hack mode and preserve hack $this->_inHack = true; return '/*/*/'; } if ($this->_inHack) { // a regular comment ends hack mode but should be preserved $this->_inHack = false; return '/**/'; } // Issue 107: if there's any surrounding whitespace, it may be important, so // replace the comment with a single space return $hasSurroundingWs // remove all other comments ? ' ' : ''; }
Process a comment and return a replacement @param array $m regex matches @return string
_commentCB
php
boonex/dolphin.pro
plugins/minify/lib/Minify/CSS/Compressor.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/minify/lib/Minify/CSS/Compressor.php
MIT
protected function _fontFamilyCB($m) { $m[1] = preg_replace('/ \\s* ( "[^"]+" # 1 = family in double qutoes |\'[^\']+\' # or 1 = family in single quotes |[\\w\\-]+ # or 1 = unquoted family ) \\s* /x', '$1', $m[1]); return 'font-family:' . $m[1] . $m[2]; }
Process a font-family listing and return a replacement @param array $m regex matches @return string
_fontFamilyCB
php
boonex/dolphin.pro
plugins/minify/lib/Minify/CSS/Compressor.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/minify/lib/Minify/CSS/Compressor.php
MIT
public function __construct(Size $size) { $this->size = $size; }
Create a new constraint based on size @param Size $size
__construct
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Constraint.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Constraint.php
MIT
public function fix($type) { $this->fixed = ($this->fixed & ~(1 << $type)) | (1 << $type); }
Fix the given argument in current constraint @param integer $type @return void
fix
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Constraint.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Constraint.php
MIT
public function isFixed($type) { return (bool) ($this->fixed & (1 << $type)); }
Checks if given argument is fixed in current constraint @param integer $type @return boolean
isFixed
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Constraint.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Constraint.php
MIT
public function aspectRatio() { $this->fix(self::ASPECTRATIO); }
Fixes aspect ratio in current constraint @return void
aspectRatio
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Constraint.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Constraint.php
MIT
public function upsize() { $this->fix(self::UPSIZE); }
Fixes possibility to size up in current constraint @return void
upsize
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Constraint.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Constraint.php
MIT
public static function getManager() { return self::$manager ? self::$manager : new ImageManager; }
Get or create new ImageManager instance @return ImageManager
getManager
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/ImageManagerStatic.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/ImageManagerStatic.php
MIT
public static function make($data) { return self::getManager()->make($data); }
Statically initiates an Image instance from different input types @param mixed $data @return \Intervention\Image\Image
make
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/ImageManagerStatic.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/ImageManagerStatic.php
MIT
public static function canvas($width, $height, $background = null) { return self::getManager()->canvas($width, $height, $background); }
Statically creates an empty image canvas @param integer $width @param integer $height @param mixed $background @return \Intervention\Image\Image
canvas
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/ImageManagerStatic.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/ImageManagerStatic.php
MIT
public static function cache(Closure $callback, $lifetime = null, $returnObj = false) { return self::getManager()->cache($callback, $lifetime, $returnObj); }
Create new cached image and run callback statically @param Closure $callback @param integer $lifetime @param boolean $returnObj @return mixed
cache
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/ImageManagerStatic.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/ImageManagerStatic.php
MIT
public function format($type) { switch (strtolower($type)) { case 'rgba': return $this->getRgba(); case 'hex': return $this->getHex('#'); case 'int': case 'integer': return $this->getInt(); case 'array': return $this->getArray(); case 'obj': case 'object': return $this; default: throw new \Intervention\Image\Exception\NotSupportedException( "Color format ({$type}) is not supported." ); } }
Formats current color instance into given format @param string $type @return mixed
format
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/AbstractColor.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/AbstractColor.php
MIT
private function cacheIsInstalled() { return class_exists('Intervention\\Image\\ImageCache'); }
Determines if Intervention Imagecache is installed @return boolean
cacheIsInstalled
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/ImageServiceProviderLaravel5.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/ImageServiceProviderLaravel5.php
MIT
public function boot() { $this->publishes(array( __DIR__.'/../../config/config.php' => config_path('image.php') )); // setup intervention/imagecache if package is installed $this->cacheIsInstalled() ? $this->bootstrapImageCache() : null; }
Bootstrap the application events. @return void
boot
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/ImageServiceProviderLaravel5.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/ImageServiceProviderLaravel5.php
MIT
public function set($width, $height) { $this->width = $width; $this->height = $height; }
Set the width and height absolutely @param integer $width @param integer $height
set
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Size.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Size.php
MIT
public function getRatio() { return $this->width / $this->height; }
Calculate the current aspect ratio @return float
getRatio
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Size.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Size.php
MIT
public function resize($width, $height, Closure $callback = null) { if (is_null($width) && is_null($height)) { throw new \Intervention\Image\Exception\InvalidArgumentException( "Width or height needs to be defined." ); } // new size with dominant width $dominant_w_size = clone $this; $dominant_w_size->resizeHeight($height, $callback); $dominant_w_size->resizeWidth($width, $callback); // new size with dominant height $dominant_h_size = clone $this; $dominant_h_size->resizeWidth($width, $callback); $dominant_h_size->resizeHeight($height, $callback); // decide which size to use if ($dominant_h_size->fitsInto(new self($width, $height))) { $this->set($dominant_h_size->width, $dominant_h_size->height); } else { $this->set($dominant_w_size->width, $dominant_w_size->height); } return $this; }
Resize to desired width and/or height @param integer $width @param integer $height @param Closure $callback @return Size
resize
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Size.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Size.php
MIT
private function resizeWidth($width, Closure $callback = null) { $constraint = $this->getConstraint($callback); if ($constraint->isFixed(Constraint::UPSIZE)) { $max_width = $constraint->getSize()->getWidth(); $max_height = $constraint->getSize()->getHeight(); } if (is_numeric($width)) { if ($constraint->isFixed(Constraint::UPSIZE)) { $this->width = ($width > $max_width) ? $max_width : $width; } else { $this->width = $width; } if ($constraint->isFixed(Constraint::ASPECTRATIO)) { $h = intval(round($this->width / $constraint->getSize()->getRatio())); if ($constraint->isFixed(Constraint::UPSIZE)) { $this->height = ($h > $max_height) ? $max_height : $h; } else { $this->height = $h; } } } }
Scale size according to given constraints @param integer $width @param Closure $callback @return Size
resizeWidth
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Size.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Size.php
MIT
private function resizeHeight($height, Closure $callback = null) { $constraint = $this->getConstraint($callback); if ($constraint->isFixed(Constraint::UPSIZE)) { $max_width = $constraint->getSize()->getWidth(); $max_height = $constraint->getSize()->getHeight(); } if (is_numeric($height)) { if ($constraint->isFixed(Constraint::UPSIZE)) { $this->height = ($height > $max_height) ? $max_height : $height; } else { $this->height = $height; } if ($constraint->isFixed(Constraint::ASPECTRATIO)) { $w = intval(round($this->height * $constraint->getSize()->getRatio())); if ($constraint->isFixed(Constraint::UPSIZE)) { $this->width = ($w > $max_width) ? $max_width : $w; } else { $this->width = $w; } } } }
Scale size according to given constraints @param integer $height @param Closure $callback @return Size
resizeHeight
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Size.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Size.php
MIT
public function relativePosition(Size $size) { $x = $this->pivot->x - $size->pivot->x; $y = $this->pivot->y - $size->pivot->y; return new Point($x, $y); }
Calculate the relative position to another Size based on the pivot point settings of both sizes. @param Size $size @return \Intervention\Image\Point
relativePosition
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Size.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Size.php
MIT
public function fit(Size $size, $position = 'center') { // create size with auto height $auto_height = clone $size; $auto_height->resize($this->width, null, function ($constraint) { $constraint->aspectRatio(); }); // decide which version to use if ($auto_height->fitsInto($this)) { $size = $auto_height; } else { // create size with auto width $auto_width = clone $size; $auto_width->resize(null, $this->height, function ($constraint) { $constraint->aspectRatio(); }); $size = $auto_width; } $this->align($position); $size->align($position); $size->setPivot($this->relativePosition($size)); return $size; }
Resize given Size to best fitting size of current size. @param Size $size @return \Intervention\Image\Size
fit
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Size.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Size.php
MIT
public function fitsInto(Size $size) { return ($this->width <= $size->width) && ($this->height <= $size->height); }
Checks if given size fits into current size @param Size $size @return boolean
fitsInto
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Size.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Size.php
MIT
public function align($position, $offset_x = 0, $offset_y = 0) { switch (strtolower($position)) { case 'top': case 'top-center': case 'top-middle': case 'center-top': case 'middle-top': $x = intval($this->width / 2); $y = 0 + $offset_y; break; case 'top-right': case 'right-top': $x = $this->width - $offset_x; $y = 0 + $offset_y; break; case 'left': case 'left-center': case 'left-middle': case 'center-left': case 'middle-left': $x = 0 + $offset_x; $y = intval($this->height / 2); break; case 'right': case 'right-center': case 'right-middle': case 'center-right': case 'middle-right': $x = $this->width - $offset_x; $y = intval($this->height / 2); break; case 'bottom-left': case 'left-bottom': $x = 0 + $offset_x; $y = $this->height - $offset_y; break; case 'bottom': case 'bottom-center': case 'bottom-middle': case 'center-bottom': case 'middle-bottom': $x = intval($this->width / 2); $y = $this->height - $offset_y; break; case 'bottom-right': case 'right-bottom': $x = $this->width - $offset_x; $y = $this->height - $offset_y; break; case 'center': case 'middle': case 'center-center': case 'middle-middle': $x = intval($this->width / 2); $y = intval($this->height / 2); break; default: case 'top-left': case 'left-top': $x = 0 + $offset_x; $y = 0 + $offset_y; break; } $this->pivot->setPosition($x, $y); return $this; }
Aligns current size's pivot point to given position and moves point automatically by offset. @param string $position @param integer $offset_x @param integer $offset_y @return \Intervention\Image\Size
align
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Size.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Size.php
MIT
private function getConstraint(Closure $callback = null) { $constraint = new Constraint(clone $this); if (is_callable($callback)) { $callback($constraint); } return $constraint; }
Runs constraints on current size @param Closure $callback @return \Intervention\Image\Constraint
getConstraint
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Size.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Size.php
MIT
public function init($data) { return $this->decoder->init($data); }
Initiates new image from given input @param mixed $data @return \Intervention\Image\Image
init
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/AbstractDriver.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/AbstractDriver.php
MIT
public function executeCommand($image, $name, $arguments) { $commandName = $this->getCommandClassName($name); $command = new $commandName($arguments); $command->execute($image); return $command; }
Executes named command on given image @param Image $image @param string $name @param array $arguments @return \Intervention\Image\Commands\AbstractCommand
executeCommand
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/AbstractDriver.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/AbstractDriver.php
MIT
private function getCommandClassName($name) { $drivername = $this->getDriverName(); $classnameLocal = sprintf('\Intervention\Image\%s\Commands\%sCommand', $drivername, ucfirst($name)); $classnameGlobal = sprintf('\Intervention\Image\Commands\%sCommand', ucfirst($name)); if (class_exists($classnameLocal)) { return $classnameLocal; } elseif (class_exists($classnameGlobal)) { return $classnameGlobal; } throw new \Intervention\Image\Exception\NotSupportedException( "Command ({$name}) is not available for driver ({$drivername})." ); }
Returns classname of given command name @param string $name @return string
getCommandClassName
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/AbstractDriver.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/AbstractDriver.php
MIT
public function getDriverName() { $reflect = new \ReflectionClass($this); $namespace = $reflect->getNamespaceName(); return substr(strrchr($namespace, "\\"), 1); }
Returns name of current driver instance @return string
getDriverName
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/AbstractDriver.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/AbstractDriver.php
MIT
public function border($width, $color = null) { $this->border_width = is_numeric($width) ? intval($width) : 0; $this->border_color = is_null($color) ? '#000000' : $color; }
Set border width and color of current shape @param integer $width @param string $color @return void
border
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/AbstractShape.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/AbstractShape.php
MIT
public function hasBorder() { return ($this->border_width >= 1); }
Determines if current shape has border @return boolean
hasBorder
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/AbstractShape.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/AbstractShape.php
MIT
public function __construct(Image $image, $format = null, $quality = null) { $this->image = $image; $this->format = $format ? $format : $image->mime; $this->quality = $quality ? $quality : 90; }
Creates a new instance of response @param Image $image @param string $format @param integer $quality
__construct
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Response.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Response.php
MIT
public function make() { $this->image->encode($this->format, $this->quality); $data = $this->image->getEncoded(); $mime = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $data); $length = strlen($data); if (function_exists('app') && is_a($app = app(), 'Illuminate\Foundation\Application')) { $response = \Response::make($data); $response->header('Content-Type', $mime); $response->header('Content-Length', $length); } else { header('Content-Type: ' . $mime); header('Content-Length: ' . $length); $response = $data; } return $response; }
Builds response according to settings @return mixed
make
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Response.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Response.php
MIT
public function setFileInfoFromPath($path) { $info = pathinfo($path); $this->dirname = array_key_exists('dirname', $info) ? $info['dirname'] : null; $this->basename = array_key_exists('basename', $info) ? $info['basename'] : null; $this->extension = array_key_exists('extension', $info) ? $info['extension'] : null; $this->filename = array_key_exists('filename', $info) ? $info['filename'] : null; if (file_exists($path) && is_file($path)) { $this->mime = finfo_file(finfo_open(FILEINFO_MIME_TYPE), $path); } return $this; }
Sets all instance properties from given path @param string $path
setFileInfoFromPath
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/File.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/File.php
MIT
public function color($color) { $this->color = $color; }
Set color of text to be written @param mixed $color @return void
color
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/AbstractFont.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/AbstractFont.php
MIT
protected function hasApplicableFontFile() { if (is_string($this->file)) { return file_exists($this->file); } return false; }
Checks if current font has access to an applicable font file @return boolean
hasApplicableFontFile
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/AbstractFont.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/AbstractFont.php
MIT
public function countLines() { return count(explode(PHP_EOL, $this->text)); }
Counts lines of text to be written @return integer
countLines
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/AbstractFont.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/AbstractFont.php
MIT
public function isGdResource() { if (is_resource($this->data)) { return (get_resource_type($this->data) == 'gd'); } return false; }
Determines if current source data is GD resource @return boolean
isGdResource
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/AbstractDecoder.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/AbstractDecoder.php
MIT
public function isImagick() { return is_a($this->data, 'Imagick'); }
Determines if current source data is Imagick object @return boolean
isImagick
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/AbstractDecoder.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/AbstractDecoder.php
MIT
public function isInterventionImage() { return is_a($this->data, '\Intervention\Image\Image'); }
Determines if current source data is Intervention\Image\Image object @return boolean
isInterventionImage
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/AbstractDecoder.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/AbstractDecoder.php
MIT
public function isSplFileInfo() { return is_a($this->data, 'SplFileInfo'); }
Determines if current data is SplFileInfo object @return boolean
isSplFileInfo
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/AbstractDecoder.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/AbstractDecoder.php
MIT
public function isSymfonyUpload() { return is_a($this->data, 'Symfony\Component\HttpFoundation\File\UploadedFile'); }
Determines if current data is Symfony UploadedFile component @return boolean
isSymfonyUpload
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/AbstractDecoder.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/AbstractDecoder.php
MIT
public function isFilePath() { if (is_string($this->data)) { return is_file($this->data); } return false; }
Determines if current source data is file path @return boolean
isFilePath
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/AbstractDecoder.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/AbstractDecoder.php
MIT
public function isUrl() { return (bool) filter_var($this->data, FILTER_VALIDATE_URL); }
Determines if current source data is url @return boolean
isUrl
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/AbstractDecoder.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/AbstractDecoder.php
MIT
public function isStream() { if (!is_resource($this->data)) return false; if (get_resource_type($this->data) !== 'stream') return false; return true; }
Determines if current source data is a stream resource @return boolean
isStream
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/AbstractDecoder.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/AbstractDecoder.php
MIT
public function isBinary() { if (is_string($this->data)) { $mime = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $this->data); return (substr($mime, 0, 4) != 'text' && $mime != 'application/x-empty'); } return false; }
Determines if current source data is binary data @return boolean
isBinary
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/AbstractDecoder.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/AbstractDecoder.php
MIT
public function isDataUrl() { $data = $this->decodeDataUrl($this->data); return is_null($data) ? false : true; }
Determines if current source data is data-url @return boolean
isDataUrl
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/AbstractDecoder.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/AbstractDecoder.php
MIT
public function isBase64() { return base64_encode(base64_decode($this->data)) === $this->data; }
Determines if current source data is base64 encoded @return boolean
isBase64
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/AbstractDecoder.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/AbstractDecoder.php
MIT
public function initFromInterventionImage($object) { return $object; }
Initiates new Image from Intervention\Image\Image @param Image $object @return \Intervention\Image\Image
initFromInterventionImage
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/AbstractDecoder.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/AbstractDecoder.php
MIT
private function decodeDataUrl($data_url) { $pattern = "/^data:(?:image\/[a-zA-Z\-\.]+)(?:charset=\".+\")?;base64,(?P<data>.+)$/"; preg_match($pattern, $data_url, $matches); if (is_array($matches) && array_key_exists('data', $matches)) { return base64_decode($matches['data']); } return null; }
Parses and decodes binary image data from data-url @param string $data_url @return string
decodeDataUrl
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/AbstractDecoder.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/AbstractDecoder.php
MIT
public function init($data) { $this->data = $data; switch (true) { case $this->isGdResource(): return $this->initFromGdResource($this->data); case $this->isImagick(): return $this->initFromImagick($this->data); case $this->isInterventionImage(): return $this->initFromInterventionImage($this->data); case $this->isSplFileInfo(): return $this->initFromPath($this->data->getRealPath()); case $this->isBinary(): return $this->initFromBinary($this->data); case $this->isUrl(): return $this->initFromUrl($this->data); case $this->isStream(): return $this->initFromStream($this->data); case $this->isFilePath(): return $this->initFromPath($this->data); case $this->isDataUrl(): return $this->initFromBinary($this->decodeDataUrl($this->data)); case $this->isBase64(): return $this->initFromBinary(base64_decode($this->data)); default: throw new Exception\NotReadableException("Image source not readable"); } }
Initiates new image from mixed data @param mixed $data @return \Intervention\Image\Image
init
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/AbstractDecoder.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/AbstractDecoder.php
MIT
public function __toString() { return (string) $this->data; }
Decoder object transforms to string source data @return string
__toString
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/AbstractDecoder.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/AbstractDecoder.php
MIT
public function __construct($app) { parent::__construct($app); $this->provider = $this->getProvider(); }
Create a new service provider instance. @param \Illuminate\Contracts\Foundation\Application $app @return void
__construct
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/ImageServiceProvider.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/ImageServiceProvider.php
MIT
private function getProvider() { if (version_compare(Application::VERSION, '5.0', '<')) { $provider = '\Intervention\Image\ImageServiceProviderLaravel4'; } else { $provider = '\Intervention\Image\ImageServiceProviderLaravel5'; } return new $provider($this->app); }
Return ServiceProvider according to Laravel version @return \Intervention\Image\Provider\ProviderInterface
getProvider
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/ImageServiceProvider.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/ImageServiceProvider.php
MIT
public function make($data) { return $this->createDriver()->init($data); }
Initiates an Image instance from different input types @param mixed $data @return \Intervention\Image\Image
make
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/ImageManager.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/ImageManager.php
MIT
public function cache(Closure $callback, $lifetime = null, $returnObj = false) { if (class_exists('Intervention\\Image\\ImageCache')) { // create imagecache $imagecache = new ImageCache($this); // run callback if (is_callable($callback)) { $callback($imagecache); } return $imagecache->get($lifetime, $returnObj); } throw new \Intervention\Image\Exception\MissingDependencyException( "Please install package intervention/imagecache before running this function." ); }
Create new cached image and run callback (requires additional package intervention/imagecache) @param Closure $callback @param integer $lifetime @param boolean $returnObj @return Image
cache
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/ImageManager.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/ImageManager.php
MIT
private function createDriver() { $drivername = ucfirst($this->config['driver']); $driverclass = sprintf('Intervention\\Image\\%s\\Driver', $drivername); if (class_exists($driverclass)) { return new $driverclass; } throw new \Intervention\Image\Exception\NotSupportedException( "Driver ({$drivername}) could not be instantiated." ); }
Creates a driver instance according to config settings @return \Intervention\Image\AbstractDriver
createDriver
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/ImageManager.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/ImageManager.php
MIT
private function checkRequirements() { if ( ! function_exists('finfo_buffer')) { throw new \Intervention\Image\Exception\MissingDependencyException( "PHP Fileinfo extension must be installed/enabled to use Intervention Image." ); } }
Check if all requirements are available @return void
checkRequirements
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/ImageManager.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/ImageManager.php
MIT
protected function processDataUrl() { $mime = $this->image->mime ? $this->image->mime : 'image/png'; return sprintf('data:%s;base64,%s', $mime, base64_encode($this->process($this->image, $mime, $this->quality)) ); }
Processes and returns encoded image as data-url string @return string
processDataUrl
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/AbstractEncoder.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/AbstractEncoder.php
MIT
public function __call($name, $arguments) { $command = $this->driver->executeCommand($this, $name, $arguments); return $command->hasOutput() ? $command->getOutput() : $this; }
Magic method to catch all image calls usually any AbstractCommand @param string $name @param Array $arguments @return mixed
__call
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Image.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Image.php
MIT
public function encode($format = null, $quality = 90) { return $this->driver->encode($this, $format, $quality); }
Starts encoding of current image @param string $format @param integer $quality @return \Intervention\Image\Image
encode
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Image.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Image.php
MIT
public function save($path = null, $quality = null) { $path = is_null($path) ? $this->basePath() : $path; if (is_null($path)) { throw new Exception\NotWritableException( "Can't write to undefined path." ); } $data = $this->encode(pathinfo($path, PATHINFO_EXTENSION), $quality); $saved = @file_put_contents($path, $data); if ($saved === false) { throw new Exception\NotWritableException( "Can't write image data to path ({$path})" ); } // set new file info $this->setFileInfoFromPath($path); return $this; }
Saves encoded image in filesystem @param string $path @param integer $quality @return \Intervention\Image\Image
save
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Image.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Image.php
MIT
public function filter(Filters\FilterInterface $filter) { return $filter->applyFilter($this); }
Runs a given filter on current image @param FiltersFilterInterface $filter @return \Intervention\Image\Image
filter
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Image.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Image.php
MIT
public function getCore() { return $this->core; }
Returns current image resource/obj @return mixed
getCore
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Image.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Image.php
MIT
public function getBackups() { return $this->backups; }
Returns all backups attached to image @return array
getBackups
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Image.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Image.php
MIT
public function isEncoded() { return ! is_null($this->encoded); }
Checks if current image is already encoded @return boolean
isEncoded
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Image.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Image.php
MIT
public function getEncoded() { return $this->encoded; }
Returns encoded image data of current image @return string
getEncoded
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Image.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Image.php
MIT
public function getWidth() { return $this->getSize()->width; }
Calculates current image width @return integer
getWidth
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Image.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Image.php
MIT
public function getHeight() { return $this->getSize()->height; }
Calculates current image height @return integer
getHeight
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Image.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Image.php
MIT
public function basePath() { if ($this->dirname && $this->basename) { return ($this->dirname .'/'. $this->basename); } return null; }
Get fully qualified path to image @return string
basePath
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Image.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Image.php
MIT
public function __toString() { return $this->encoded; }
Returns encoded image data in string conversion @return string
__toString
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Image.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Image.php
MIT
public function __construct(Decoder $decoder = null, Encoder $encoder = null) { if ( ! $this->coreAvailable()) { throw new \Intervention\Image\Exception\NotSupportedException( "GD Library extension not available with this PHP installation." ); } $this->decoder = $decoder ? $decoder : new Decoder; $this->encoder = $encoder ? $encoder : new Encoder; }
Creates new instance of driver @param Decoder $decoder @param Encoder $encoder
__construct
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Gd/Driver.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Gd/Driver.php
MIT
public function parseColor($value) { return new Color($value); }
Reads given string into color object @param string $value @return AbstractColor
parseColor
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Gd/Driver.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Gd/Driver.php
MIT
protected function coreAvailable() { return (extension_loaded('gd') && function_exists('gd_info')); }
Checks if core module installation is available @return boolean
coreAvailable
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Gd/Driver.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Gd/Driver.php
MIT
public function initFromPath($path) { $info = @getimagesize($path); if ($info === false) { throw new \Intervention\Image\Exception\NotReadableException( "Unable to read image from file ({$path})." ); } // define core switch ($info[2]) { case IMAGETYPE_PNG: $core = imagecreatefrompng($path); $this->gdResourceToTruecolor($core); break; case IMAGETYPE_JPEG: $core = imagecreatefromjpeg($path); $this->gdResourceToTruecolor($core); break; case IMAGETYPE_GIF: $core = imagecreatefromgif($path); $this->gdResourceToTruecolor($core); break; default: throw new \Intervention\Image\Exception\NotReadableException( "Unable to read image type. GD driver is only able to decode JPG, PNG or GIF files." ); } // build image $image = $this->initFromGdResource($core); $image->mime = $info['mime']; $image->setFileInfoFromPath($path); return $image; }
Initiates new image from path in filesystem @param string $path @return \Intervention\Image\Image
initFromPath
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Gd/Decoder.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Gd/Decoder.php
MIT
public function initFromGdResource($resource) { return new Image(new Driver, $resource); }
Initiates new image from GD resource @param Resource $resource @return \Intervention\Image\Image
initFromGdResource
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Gd/Decoder.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Gd/Decoder.php
MIT
public function initFromImagick(\Imagick $object) { throw new \Intervention\Image\Exception\NotSupportedException( "Gd driver is unable to init from Imagick object." ); }
Initiates new image from Imagick object @param Imagick $object @return \Intervention\Image\Image
initFromImagick
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Gd/Decoder.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Gd/Decoder.php
MIT
public function initFromBinary($binary) { $resource = @imagecreatefromstring($binary); if ($resource === false) { throw new \Intervention\Image\Exception\NotReadableException( "Unable to init from given binary data." ); } $image = $this->initFromGdResource($resource); $image->mime = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $binary); return $image; }
Initiates new image from binary data @param string $data @return \Intervention\Image\Image
initFromBinary
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Gd/Decoder.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Gd/Decoder.php
MIT
public function gdResourceToTruecolor(&$resource) { $width = imagesx($resource); $height = imagesy($resource); // new canvas $canvas = imagecreatetruecolor($width, $height); // fill with transparent color imagealphablending($canvas, false); $transparent = imagecolorallocatealpha($canvas, 255, 255, 255, 127); imagefilledrectangle($canvas, 0, 0, $width, $height, $transparent); imagecolortransparent($canvas, $transparent); imagealphablending($canvas, true); // copy original imagecopy($canvas, $resource, 0, 0, 0, 0, $width, $height); imagedestroy($resource); $resource = $canvas; return true; }
Transform GD resource into Truecolor version @param resource $resource @return bool
gdResourceToTruecolor
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Gd/Decoder.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Gd/Decoder.php
MIT
protected function processJpeg() { ob_start(); imagejpeg($this->image->getCore(), null, $this->quality); $this->image->mime = image_type_to_mime_type(IMAGETYPE_JPEG); $buffer = ob_get_contents(); ob_end_clean(); return $buffer; }
Processes and returns encoded image as JPEG string @return string
processJpeg
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Gd/Encoder.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Gd/Encoder.php
MIT
protected function processPng() { ob_start(); $resource = $this->image->getCore(); imagealphablending($resource, false); imagesavealpha($resource, true); imagepng($resource, null, -1); $this->image->mime = image_type_to_mime_type(IMAGETYPE_PNG); $buffer = ob_get_contents(); ob_end_clean(); return $buffer; }
Processes and returns encoded image as PNG string @return string
processPng
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Gd/Encoder.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Gd/Encoder.php
MIT
protected function processGif() { ob_start(); imagegif($this->image->getCore()); $this->image->mime = image_type_to_mime_type(IMAGETYPE_GIF); $buffer = ob_get_contents(); ob_end_clean(); return $buffer; }
Processes and returns encoded image as GIF string @return string
processGif
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Gd/Encoder.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Gd/Encoder.php
MIT
protected function processTiff() { throw new \Intervention\Image\Exception\NotSupportedException( "TIFF format is not supported by Gd Driver." ); }
Processes and returns encoded image as TIFF string @return string
processTiff
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Gd/Encoder.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Gd/Encoder.php
MIT
protected function processBmp() { throw new \Intervention\Image\Exception\NotSupportedException( "BMP format is not supported by Gd Driver." ); }
Processes and returns encoded image as BMP string @return string
processBmp
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Gd/Encoder.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Gd/Encoder.php
MIT
protected function processIco() { throw new \Intervention\Image\Exception\NotSupportedException( "ICO format is not supported by Gd Driver." ); }
Processes and returns encoded image as ICO string @return string
processIco
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Gd/Encoder.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Gd/Encoder.php
MIT
protected function processPsd() { throw new \Intervention\Image\Exception\NotSupportedException( "PSD format is not supported by Gd Driver." ); }
Processes and returns encoded image as PSD string @return string
processPsd
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Gd/Encoder.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Gd/Encoder.php
MIT
private function getInternalFont() { $internalfont = is_null($this->file) ? 1 : $this->file; $internalfont = is_numeric($internalfont) ? $internalfont : false; if ( ! in_array($internalfont, array(1, 2, 3, 4, 5))) { throw new \Intervention\Image\Exception\NotSupportedException( sprintf('Internal GD font (%s) not available. Use only 1-5.', $internalfont) ); } return intval($internalfont); }
Filter function to access internal integer font values @return integer
getInternalFont
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Gd/Font.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Gd/Font.php
MIT
private function getInternalFontWidth() { return $this->getInternalFont() + 4; }
Get width of an internal font character @return integer
getInternalFontWidth
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Gd/Font.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Gd/Font.php
MIT
private function getInternalFontHeight() { switch ($this->getInternalFont()) { case 1: return 8; case 2: return 14; case 3: return 14; case 4: return 16; case 5: return 16; } }
Get height of an internal font character @return integer
getInternalFontHeight
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Gd/Font.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Gd/Font.php
MIT
public function getBoxSize() { $box = array(); if ($this->hasApplicableFontFile()) { // get bounding box with angle 0 $box = imagettfbbox($this->getPointSize(), 0, $this->file, $this->text); // rotate points manually if ($this->angle != 0) { $angle = pi() * 2 - $this->angle * pi() * 2 / 360; for ($i=0; $i<4; $i++) { $x = $box[$i * 2]; $y = $box[$i * 2 + 1]; $box[$i * 2] = cos($angle) * $x - sin($angle) * $y; $box[$i * 2 + 1] = sin($angle) * $x + cos($angle) * $y; } } $box['width'] = intval(abs($box[4] - $box[0])); $box['height'] = intval(abs($box[5] - $box[1])); } else { // get current internal font size $width = $this->getInternalFontWidth(); $height = $this->getInternalFontHeight(); if (strlen($this->text) == 0) { // no text -> no boxsize $box['width'] = 0; $box['height'] = 0; } else { // calculate boxsize $box['width'] = strlen($this->text) * $width; $box['height'] = $height; } } return $box; }
Calculates bounding box of current font setting @return Array
getBoxSize
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Gd/Font.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Gd/Font.php
MIT
public function applyToImage(Image $image, $posx = 0, $posy = 0) { // parse text color $color = new Color($this->color); if ($this->hasApplicableFontFile()) { if ($this->angle != 0 || is_string($this->align) || is_string($this->valign)) { $box = $this->getBoxSize(); $align = is_null($this->align) ? 'left' : strtolower($this->align); $valign = is_null($this->valign) ? 'bottom' : strtolower($this->valign); // correction on position depending on v/h alignment switch ($align.'-'.$valign) { case 'center-top': $posx = $posx - round(($box[6]+$box[4])/2); $posy = $posy - round(($box[7]+$box[5])/2); break; case 'right-top': $posx = $posx - $box[4]; $posy = $posy - $box[5]; break; case 'left-top': $posx = $posx - $box[6]; $posy = $posy - $box[7]; break; case 'center-center': case 'center-middle': $posx = $posx - round(($box[0]+$box[4])/2); $posy = $posy - round(($box[1]+$box[5])/2); break; case 'right-center': case 'right-middle': $posx = $posx - round(($box[2]+$box[4])/2); $posy = $posy - round(($box[3]+$box[5])/2); break; case 'left-center': case 'left-middle': $posx = $posx - round(($box[0]+$box[6])/2); $posy = $posy - round(($box[1]+$box[7])/2); break; case 'center-bottom': $posx = $posx - round(($box[0]+$box[2])/2); $posy = $posy - round(($box[1]+$box[3])/2); break; case 'right-bottom': $posx = $posx - $box[2]; $posy = $posy - $box[3]; break; case 'left-bottom': $posx = $posx - $box[0]; $posy = $posy - $box[1]; break; } } // enable alphablending for imagettftext imagealphablending($image->getCore(), true); // draw ttf text imagettftext($image->getCore(), $this->getPointSize(), $this->angle, $posx, $posy, $color->getInt(), $this->file, $this->text); } else { // get box size $box = $this->getBoxSize(); $width = $box['width']; $height = $box['height']; // internal font specific position corrections if ($this->getInternalFont() == 1) { $top_correction = 1; $bottom_correction = 2; } elseif ($this->getInternalFont() == 3) { $top_correction = 2; $bottom_correction = 4; } else { $top_correction = 3; $bottom_correction = 4; } // x-position corrections for horizontal alignment switch (strtolower($this->align)) { case 'center': $posx = ceil($posx - ($width / 2)); break; case 'right': $posx = ceil($posx - $width) + 1; break; } // y-position corrections for vertical alignment switch (strtolower($this->valign)) { case 'center': case 'middle': $posy = ceil($posy - ($height / 2)); break; case 'top': $posy = ceil($posy - $top_correction); break; default: case 'bottom': $posy = round($posy - $height + $bottom_correction); break; } // draw text imagestring($image->getCore(), $this->getInternalFont(), $posx, $posy, $this->text, $color->getInt()); } }
Draws font to given image at given position @param Image $image @param integer $posx @param integer $posy @return void
applyToImage
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Gd/Font.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Gd/Font.php
MIT
public function initFromInteger($value) { $this->a = ($value >> 24) & 0xFF; $this->r = ($value >> 16) & 0xFF; $this->g = ($value >> 8) & 0xFF; $this->b = $value & 0xFF; }
Initiates color object from integer @param integer $value @return \Intervention\Image\AbstractColor
initFromInteger
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Gd/Color.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Gd/Color.php
MIT
public function initFromString($value) { if ($color = $this->rgbaFromString($value)) { $this->r = $color[0]; $this->g = $color[1]; $this->b = $color[2]; $this->a = $this->alpha2gd($color[3]); } }
Initiates color object from given string @param string $value @return \Intervention\Image\AbstractColor
initFromString
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Gd/Color.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Gd/Color.php
MIT
public function initFromRgb($r, $g, $b) { $this->r = intval($r); $this->g = intval($g); $this->b = intval($b); $this->a = 0; }
Initiates color object from given R, G and B values @param integer $r @param integer $g @param integer $b @return \Intervention\Image\AbstractColor
initFromRgb
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Gd/Color.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Gd/Color.php
MIT
public function initFromRgba($r, $g, $b, $a = 1) { $this->r = intval($r); $this->g = intval($g); $this->b = intval($b); $this->a = $this->alpha2gd($a); }
Initiates color object from given R, G, B and A values @param integer $r @param integer $g @param integer $b @param float $a @return \Intervention\Image\AbstractColor
initFromRgba
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Gd/Color.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Gd/Color.php
MIT
public function initFromObject($value) { throw new \Intervention\Image\Exception\NotSupportedException( "GD colors cannot init from ImagickPixel objects." ); }
Initiates color object from given ImagickPixel object @param ImagickPixel $value @return \Intervention\Image\AbstractColor
initFromObject
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Gd/Color.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Gd/Color.php
MIT
public function getInt() { return ($this->a << 24) + ($this->r << 16) + ($this->g << 8) + $this->b; }
Calculates integer value of current color instance @return integer
getInt
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Gd/Color.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Gd/Color.php
MIT
public function getHex($prefix = '') { return sprintf('%s%02x%02x%02x', $prefix, $this->r, $this->g, $this->b); }
Calculates hexadecimal value of current color instance @param string $prefix @return string
getHex
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Gd/Color.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Gd/Color.php
MIT
public function getArray() { return array($this->r, $this->g, $this->b, round(1 - $this->a / 127, 2)); }
Calculates RGB(A) in array format of current color instance @return array
getArray
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Gd/Color.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Gd/Color.php
MIT
public function getRgba() { return sprintf('rgba(%d, %d, %d, %.2f)', $this->r, $this->g, $this->b, round(1 - $this->a / 127, 2)); }
Calculates RGBA in string format of current color instance @return string
getRgba
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Gd/Color.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Gd/Color.php
MIT
public function differs(AbstractColor $color, $tolerance = 0) { $color_tolerance = round($tolerance * 2.55); $alpha_tolerance = round($tolerance * 1.27); $delta = array( 'r' => abs($color->r - $this->r), 'g' => abs($color->g - $this->g), 'b' => abs($color->b - $this->b), 'a' => abs($color->a - $this->a) ); return ( $delta['r'] > $color_tolerance or $delta['g'] > $color_tolerance or $delta['b'] > $color_tolerance or $delta['a'] > $alpha_tolerance ); }
Determines if current color is different from given color @param AbstractColor $color @param integer $tolerance @return boolean
differs
php
boonex/dolphin.pro
plugins/intervention-image/Intervention/Image/Gd/Color.php
https://github.com/boonex/dolphin.pro/blob/master/plugins/intervention-image/Intervention/Image/Gd/Color.php
MIT